Skip to content
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 in getsvgsize #152

Closed
prodigysml opened this issue Dec 13, 2017 · 4 comments
Closed

XXE DoS in getsvgsize #152

prodigysml opened this issue Dec 13, 2017 · 4 comments

Comments

@prodigysml
Copy link

Issue

Pepperminty-Wiki is vulnerable to XXE attacks due to the usage of the simplexml_load_file function without disabling entities. 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.

Where the Issue Occurred

If an uploaded svg, containing the billion laughs payload, makes its way to the simplexml_load_file function, the denial of service scenario is triggered. This exact locations in the code are given below:

$svg = simplexml_load_file($svgFilename); // Load it as XML

$svg = simplexml_load_file($svgFilename); // Load it as XML

Remediation

Prior to loading any xml, disable entities ensuring that the above-mentioned attacks will no longer be possible.
libxml_disable_entity_loader(true);

@sbrl
Copy link
Owner

sbrl commented Dec 13, 2017

Oooh, thanks for the detailed report! I'll fix that right away and release a patch. I'll also add you to the credits page.

How did you discover it, out of curiosity?

@prodigysml
Copy link
Author

I was actually just reading through your code and then realised it. Took a fair bit of searching before reporting to be sure. I guess I was more jist curious on how you handle the SVG files :)

@sbrl
Copy link
Owner

sbrl commented Dec 13, 2017

@prodigysml Cool! I'll have a patch out in 1/2 hour max. I wasn't sure how to handle an SVG correctly, so I brainstormed a few ways to simply check if a valid SVG is being uploaded, and ended up check to make sure it's valid XML and that it's got a valid size.

The whole file upload system is a bit of a mess, tbh - but I'm not sure how I could tidy it up any further without rewriting the whole thing :P

@sbrl
Copy link
Owner

sbrl commented Dec 13, 2017

Released v0.15.1: https://github.com/sbrl/Pepperminty-Wiki/releases/tag/v0.15.1

Thanks for taking the time to do such a thorough investigation into the issue, @prodigysml! I didn't even know that XML entities were a thing :P

@sbrl sbrl closed this as completed Dec 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants