-
Notifications
You must be signed in to change notification settings - Fork 27
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
xml_in is vulnerable to file inclusion if misused in request #22
Comments
The problem is in the initialize function that supports a lot of different types of input:
For example, you can pass an XML document as a string but you can also pass the name of an XML file. xml_in is happy with both of them. This is purely for convenience and I totally agree: it might become a problem under certain circumstances. At least the behavior is documented and checking user input is always important. I do not see an optimal way to fix this without breaking backwards compatibility. I could, for example, add functions such as xml_in_from_file and xml_in_from_string, but they would only help, if I'd remove xml_in. |
Adding functions for specific input types would help a lot to avoid an extra validation in the application. It is also important to mention that the validation must include the regular expression |
The method xml_in can be used to read system files in XML format instead of the expected user input.
Proof of Concept
Lets suppose we have in Sinatra the following code:
If we do:
And lets suppose that we also have a file in the same directory named "secrets.xml", with the following content:
If we do:
It is very easy to forget to validate the input, causing potential vulnerabilities when parsing input received by the clients.
The text was updated successfully, but these errors were encountered: