> Well, it's not really a thing. In a browser (the only kind of UA that'll really run any scripts in an SVG), SVG basically gets treated as SGML, all the DOM stuff is the same. If you include it as an image tag, the scripts don't tend to run, AFAIK
It breaks expectations. I havn't looked at it recently, but it used to be the case that hosting user submitted SVGs on your domain could yield JS-execution in the origin context. Embedding or iframing without sandbox isn't/wasn't secure either.
A quick google search on SVG XSS gives:
https://hackerone.com/reports/148853 https://phabricator.wikimedia.org/T85850
Re:An SVG that always shows today's date
by noblethrasher on Sunday February 25, 2018 @06:51PM
(#16461957)
On the other hand, I think it would be straightforward to strip script tags and attributes using XSLT. You could even go as far as just whitelisting certain tags/attributes.
Re:An SVG that always shows today's date
by microcolonel on Monday February 26, 2018 @03:24AM
(#16463936)
> I havn't looked at it recently, but it used to be the case that hosting user submitted SVGs on your domain could yield JS-execution in the origin context.
Oh definitely, though that's more an administrative problem than a platform problem. Webmasters (or whoever that task falls to today) must understand that SVGs are exactly as dangerous as HTML files in exactly the same ways. Where you would sanitize user-provided HTML, you must also sanitize user-provided SVG.
That's a relief. I see from the page it's embedded as an iframe, which I didn't know you could do. Changing the iframe to an img on the page does indeed prevent the script executing, at least on Firefox.
Re:An SVG that always shows today's date
by amenghra on Sunday February 25, 2018 @07:10PM
(#16462034)
Proof that it doesn't work when used in an <img> tag:
https://jsfiddle.net/8rcrfpwn/
Re:An SVG that always shows today's date
by four_serenity on Monday February 26, 2018 @07:27AM
(#16464796)
It does work with an <object> tag, though: https://jsfiddle.net/8rcrfpwn/4/
The script also works if the SVG is written inline. Sadly, WordPress makes that tricky on my site.
So let's say you use an img tag, but the user right clicks and chooses view image? Navigating to the svg seems to run the scripts.
> Navigating to the svg seems to run the scripts.
Now that seems like a bug.
Re:An SVG that always shows today's date
by WorldMaker on Monday February 26, 2018 @01:37PM
(#16467738)
If I recall correctly, Mozilla thought so too and recently disabled scripts in direct SVG navigation and data: URIs in recent versions of Firefox.
Re:An SVG that always shows today's date
by WorldMaker on Monday February 26, 2018 @01:44PM
(#16467803)
Well, direct navigation worked when I tried it now and I can't seem to turn up the blog post I thought commented on the situation, so my recollection here may be in question.
Well, it's not really a thing. In a browser (the only kind of UA that'll really run any scripts in an SVG), SVG basically gets treated as SGML, all the DOM stuff is the same. If you include it as an image tag, the scripts don't tend to run, AFAIK.
Added to clarify: The types of things you could exploit in a scripted SVG but which wouldn't also apply to HTML, would tend to be exploitable in a static SVG as well.