-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XXE DoS within SVG Parsing #122
Comments
Thanks for the report. Entities do have their uses. The SVG spec itself contains examples that use entity expansion. I am reluctant to completely disable them. Especially considering none of the browsers have either. But it does make sense to either: FMR: https://docs.oracle.com/javase/tutorial/jaxp/limits/using.html |
Fair enough! Thanks for that! Didn't actually know svgs use entities. Both approaches seem like a good idea! Thanks for being so prompt! |
Investigations have shown that the expat parser built into Android (which is used by the SAXParser which AndroidSVG uses) does not currently support any limits on entity expansion. It is still an open bug. Although there is a way to turn off external entity expansion, there doesn't seem to be a way to turn off the expansion of internal entities. Internal entities are those defined in the XML file itself. Expat doesn't seem to support the It might mean that I either: |
To be honest, considering there isn't much easily doable, adding a security warning seems reasonable. (Bonus if it's in red :) ) |
…ser, but switches to the SAXParser if entity declarations are found.
Fixed. This change will be in the 1.3 release. I have implemented a dual XML parser approach. The SVG parser now starts out using the faster XMLPullParser (which doesn't support entities). If it detects entity declarations, it will reset the input stream and switch to the SAX parser (which does support entities). If you want to disable entity parsing, for security reasons, you can now call the new method |
@BigBadaboom Is there a way to always use the one that supports entity parsing? I use it very extensively and don't want to pay the price of resetting the stream. My image sources are secure, I hand-write them. |
@TWiStErRob Not at the moment. If you are finding that this change has had a significant detrimental impact on your app's performance, please open a new issue. |
Haven't tested yet, maybe just being paranoid; I'll keep an eye out. Thank you! |
Issue
androidsvg is vulnerable to XXE attacks as some dangerous features are not disabled. This leads to a confirmed denial of service scenario (https://en.wikipedia.org/wiki/Billion_laughs_attack) and may lead to execution of commands on the server.
This issue occurs in the SVG parse section of the code:
androidsvg/androidsvg/src/main/java/com/caverock/androidsvg/SVGParser.java
Line 576 in 1f53713
Prior to parsing the XML, features like entities are not disabled. These should not be required at all within an SVG file.
androidsvg/androidsvg/src/main/java/com/caverock/androidsvg/SVGParser.java
Line 606 in 1f53713
Remediation
Implementing something down the lines of the following:
This ensures that the entities are no longer parsed and external dtd files are not either.
The text was updated successfully, but these errors were encountered: