News for hackers. Stuff that matters.
Re:SVG has more potential by CiPHPerCoder on Monday September 26, 2016 @02:52PM (#12584543)
SVG also has more risk: stored XSS, which isn't something you'd expect from a file whose MIME type starts with "image/".

https://github.com/w3c/svgwg/issues/266

Re:SVG has more potential by dsacco on Monday September 26, 2016 @02:57PM (#12584589)
Ah, you beat me to it.

A practical demonstration of XSS in an SVG is the following:

  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

  <svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg">
    <polygon id="triangle" points="0,0 0,50 50,0" fill="#009900" stroke="#004400"/>
    <script type="text/javascript">
      alert(document.cookie);
    </script>
  </svg>
I see this in the wild all the time, though these days it's becoming less harmful as more developers learn to host their images (and all user uploaded files, really) on a separate CDN.
Re:SVG has more potential by duaneb on Monday September 26, 2016 @05:59PM (#12585975)
Wait, what? Why is embedding a script into an image allowed? WTF? I do not expect my images to be turing complete.
Re:SVG has more potential by comex on Monday September 26, 2016 @06:34PM (#12586186)
Note that it's disabled if the image is loaded with an img tag, so allowing users to embed arbitrary URLs as images is safe. The issue is if you allow uploading of svg files to your own domain, someone can then have their own site redirect to the svg or load it in a frame, at which point it can run scripts from your origin.
Re:SVG has more potential by pdkl95 on Tuesday September 27, 2016 @03:19AM (#12587943)
> Why is embedding a script into an image allowed?

Because it lets you create vector games:

http://public.codenazi.fastmail.fm/asteroids_dynamic.svg

(a better use would be stuff like D3-style interactive charts)

Warning: I never finished that project because SVG rendering was too slow ~6 years ago. Frames would drop on every reflow after any DOM change. Arrows move, space shoots. Collision checks are on so the shield (x) works, but the death animation is disabled in that version.

I actually agree that images shouldn't be Turing complete. That's unnecessary in almost every normal situation and only adds attack surface. However, there is a place for animated vector graphics.

Re:SVG has more potential by wongarsu on Monday September 26, 2016 @08:30PM (#12586764)
>I do not expect my images to be turing complete.

An image of type "image/svg+xml" is as powerful as a text of type "text/html". In both cases their mime-type could be considered a misnomer.

In general I find it more helpful to think of SVG as a xhtml-like format with tags for arbitrary shapes. It has full support for interaction, state, javascript, css and almost anything else you expect from a html document.

Re:SVG has more potential by dredmorbius on Monday September 26, 2016 @08:53PM (#12586842)
SVG is vector, not raster, and in one way of thinking, is embedding instructions on how to present and manipulate an image or set of graphics directives.

How close it is to Turing complete I'm not sure -- I've played with them a tad, enough to find them quite adaptable and useful, but have also seen stuff, much of it from David Daley (https://ello.co/ddailey) which boggles my poor little brain.

Re:SVG has more potential by TazeTSchnitzel on Tuesday September 27, 2016 @06:46AM (#12588552)
SVG lets you use ECMAScript, and ECMAScript is Turing-complete.
Re:SVG has more potential by dredmorbius on Tuesday September 27, 2016 @07:31PM (#12594198)
Thanks.
Re:SVG has more potential by tamana on Tuesday September 27, 2016 @05:39PM (#12593465)
That's exactly the same as regular HTML
Re:SVG has more potential by ogig on Monday September 26, 2016 @03:55PM (#12585015)
And more. I got a bug bounty by uploading a malicious svg witch would get parsed and fetch external resources, even read local images.

If your app receives and parses svg server side you might have a hole there.

Re:SVG has more potential by joepvd on Monday September 26, 2016 @05:32PM (#12585766)
> a malicious svg witch

You got me interested there ;)

Re:SVG has more potential by happyslobro on Monday September 26, 2016 @07:34PM (#12586506)
Forgive my ignorance, but why would anyone ever need to parse an SVG server side?

Now that you got me thinking, SVG might be a decent, if somewhat large, format for accepting sketches from users. Something like "draw a map, and we'll find it on Google maps for you". But I am certain that that (SVG user input) isn't a thing yet.

Re:SVG has more potential by nitrogen on Monday September 26, 2016 @07:44PM (#12586546)
Maybe you need PNG thumbnails for user-uploaded SVGs.