SECURITY: strip xlink:href from uploaded SVGs (#21057)

This was inadvertently removed in 4c46c7e. In very specific scenarios,
this could be used execute arbitrary JavaScript.

Only affects instances where SVGs are allowed as uploads and CDN is not
configured.
This commit is contained in:
Penar Musaraj
2023-04-11 14:10:44 -04:00
committed by GitHub
parent 087ee8c5e2
commit 0ab3ba5f0d
2 changed files with 2 additions and 1 deletions

View File

@ -497,6 +497,7 @@ class UploadCreator
if use_el.attr("href")
use_el.remove_attribute("href") unless use_el.attr("href").starts_with?("#")
end
use_el.remove_attribute("xlink:href")
end
File.write(@file.path, doc.to_s)
@file.rewind