Page MenuHomePhabricator

Allow Lua access to source code of SVG files
Open, Needs TriagePublicFeature

Description

I think the next obvious question is can we make mw.title.new("Media:foo.svg"):getContent() return the text of the svg if the file is below a certain size. Then we could have lua do post processing on svg files, to e.g. change the colour of something.

More generally it would be kind of cool to allow lua access to (small) uploaded files. You could imagine allowing uploads of csv files as an alternative to jsonData.

A more reasonable API might be as part of file metadata: mw.title.new("File:foo.svg").file.source, so that's it's recorded as a file usage. Or even better: mw.svg.newFromFile("foo.svg").

Event Timeline

Does this not run into the same security issue as described in T5593: [Epic] SVG client side rendering regarding scripts potentially uploaded before the dawn of sanitization?

Does this not run into the same security issue as described in T5593: [Epic] SVG client side rendering regarding scripts potentially uploaded before the dawn of sanitization?

Not really. The security of this is based on the idea that SVGs are being run in "secure animated mode" https://svgwg.org/specs/integration/#secure-animated-mode so sanitization is not really relavent.

Quite frankly it doesn't matter on the other ticket either. The risky part of SVGs is them being on upload.wikimedia.org. Using them on site in an <img> tag is not risky.

If there were malicious svgs from before the dawn of sanitization, it would be a problem *right now* because they are on upload.wikimedia.org which is where the risk is. Contrary to popular opinion, upload.wikimedia.org is not properly isolated from the main site so having malicious svgs there would be bad (And nobody seems particularly interested in fixing that, sadly).

The only thing that would increase risk here is if you could use the <svg> tags directly on a page instead of in an <img> tag. However i don't think anyone is proposing that in any of these tickets.

Edit: There is a minor risk in this scheme, where the user could right-click the image, and select download file, and then view the file locally, which if malicious might reveal their IP address.