Created
August 26, 2008 18:20
-
-
Save rsanheim/7312 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.dirname(__FILE__) + '/../unit_test_helper' | |
describe "REXML" do | |
it "handles DOS vulnerability" do | |
# From http://p.ramaze.net/1887 | |
dom = REXML::Document.new('<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE member [ | |
<!ENTITY a "&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;"> | |
<!ENTITY b "&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;"> | |
<!ENTITY c "&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;"> | |
<!ENTITY d "&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;"> | |
<!ENTITY e "&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;"> | |
<!ENTITY f "&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;"> | |
<!ENTITY g "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"> | |
]> | |
<member> | |
&a; | |
</member>') | |
lambda { | |
dom.root.elements.to_a('//member').first.text | |
}.should.raise(RuntimeError).message.should == "Number of entity expansions exceeded, processing aborted." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment