-
-
Notifications
You must be signed in to change notification settings - Fork 903
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
nokogiri vulnerable to XXE attack when used under c ruby #693
Comments
I'm very open to discussing whether this behavior should be changed; I only ask that further discussion take place on the nokogiri-talk mailing list (http://groups.google.com/group/nokogiri-talk) so that a wider audience can both be aware of the discussion and comment on the discussion. If you want Nokogiri to avoid making external connections, you may set the If you'd like to learn more about available options, see http://nokogiri.org/Nokogiri/XML/ParseOptions.html If you'd like to see examples of how to configure parse options, see http://nokogiri.org/tutorials/parsing_an_html_xml_document.html#parse_options . The short version is that you should do something like the following:
If you'd like to discuss why Team Nokogiri believes this is not a security vulnerability in the common sense of the term, then we should hold that discussion on the nokogiri-talk mailing list, in an open and transparent manner, as described on the "Getting Help" page here: http://nokogiri.org/tutorials/getting_help.html Lastly, if you are dealing with an untrusted document, it's recommended to use the |
I've started a discussion on this topic at https://groups.google.com/group/nokogiri-talk/browse_thread/thread/47eaa6931bfa2301 |
I've updated the rdoc strings for Document#parse and ParseOptions; and updated the parsing tutorial. These changes have been pushed to http://nokogiri.org/. I'm going to leave this ticket open for now, as it appears the nokogiri-talk thread is leading us to some code changes, which will be noted here. |
v1.5.4.rc2 addresses this vulnerability. |
Hi there, I think it isn't fixed for local entities:
|
Hello, 1.5.4 was a hurried release to address network implications, per the above descriptions. We will look into address local filesystem implications next. |
Will there be a ParseOption to address the file Entity vulnerability? ie: <!ENTITY file SYSTEM "file:///etc/passwd"> Trying to find a way to lock this out. |
Looking at libxml2 code (both 2.7.8 and 2.9.0), there doesn't appear to be any way to prevent libxml2 from reading a local entity file. This seems like an oversight, and I'll raise it on the libxml2 mailing list. Also - can someone determine whether Xerces has this same problem? @yokolet? @jvshahid? @tenderlove - do you have any additional context that might be helpful here? FWIW this is the snippet I'm using to determine libxml2 behavior:
|
I talked about this on Nokogiri-talk ml a couple months ago along with another issue. I believe John fixed "another" issue, but not sure he fixed this XXE. If not, Xerces has the same problem. |
I mean pure Java version has the same problem since Xerces itself doesn't protect from this sort of attack. |
@flavorjones I've looked through the libxml2 source and come to the same conclusion. I think I found the internal SAX callback for building the DOM, but I can't seem to find anything that would prevent reading from the filesystem. :( |
OK - I'll post to the libxml2 mailing list raising this as something with possible security implications. :-\ |
libxml2 thread: https://mail.gnome.org/archives/xml/2012-October/msg00002.html |
Actually this has been fixed in libxml2 version 2.9 see https://mail.gnome.org/archives/xml/2012-October/msg00045.html I gave it a short test with putting Result:
So a simple dependency update should fix this issue. |
Thanks for the suggestion, however versions 2.9.0 and 2.9.1 of libxml2 On Mon, Aug 19, 2013 at 1:12 PM, joernchen of Phenoelit <
|
I have recently come across some applications that use older versions of nokogiri that may be vulnerable to this issue. I wound up spending several hours investigating it, and came to the following conclusions that may be useful to others:
Therefore I think this issue can be closed. One last problem, though. As far as I can tell, no CVE ID was ever assigned to this issue. This is a problem because without CVE assignment, vendors won't realize the implications of this issue and patch their products using Nokogiri in a timely fashion. If I am wrong, please do let me know. I will send this analysis to the oss-security list requesting CVE assignment (MITRE should refuse if it's a duplicate). |
Thanks for the followup, I'll close this now. You're correct in that we did not get a CVE ID for this issue. That's going to be part of our process going forward. Apologies for the inconvenience. |
No problem - just to close the loop, MITRE has assigned CVE-2012-6685 to this issue. |
Using external xml entities you can specify URLs (e.g. HTTP) to be contacted when attacker-supplied XML is parsed. This can be used to trigger URLs on the internal network of a XML parsing service and potentially leak their responses.
External xml entities should be completely (file, http, etc.) disabled.
The text was updated successfully, but these errors were encountered: