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

Java version doesn't protect against billion laughs attack #586

Closed
meder opened this issue Dec 20, 2011 · 8 comments
Closed

Java version doesn't protect against billion laughs attack #586

meder opened this issue Dec 20, 2011 · 8 comments

Comments

@meder
Copy link

meder commented Dec 20, 2011

parsing the XML below with ruby, works as expected, however parsing this with JRuby and nokogiri java results in OutOfMemoryError. It seems like java version should set the security-manager property, see http://xerces.apache.org/xerces2-j/properties.html

`

]>
&lol9;`

@yokolet
Copy link
Member

yokolet commented Dec 21, 2011

Thanks for reporting. I got OutOfMemoryError while parsing above document. Fix will come soon.

@yokolet
Copy link
Member

yokolet commented Dec 21, 2011

I added security manager in rev. 3ace9dc. The behavior between Apache Xerces and libxml2 is different. Xerces processes entity reference while libxml2 doesn't. I'm not sure whether it is possible to coincide both behavior or not. However, I didn't get OutOfMemoryError anymore after the change. Perhaps, this means pure Java version can avoid jeopardizing system by DOS attack.

@meder
Copy link
Author

meder commented Dec 22, 2011

thanks @yokolet! should security manager be disabled if HUGE option is given?

@yokolet
Copy link
Member

yokolet commented Dec 22, 2011

Ah, that's a good idea. Perf seems to be got worse by that security manager. Huge document parsing has been slow on pure Java, so switching off feature will work, I think.

But, probably, a new option would be good. Not to confuse users.

@igrigorik
Copy link

Naive question: the above fix applies for the JVM version.. what about MRI, does the same issue surface there?

@yokolet
Copy link
Member

yokolet commented Dec 22, 2011

As far as I tested, MRI version doesn't have the problem. Probably, libxml has such security manager by default. But, Apache Xerces sets off by default.

@igrigorik
Copy link

Awesome, thanks @yokolet!

@jvshahid
Copy link
Member

Closing this issue.This was fixed at some point. There was a regression that I caused but there's a patch that @flavorjones is working to merge in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants