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

Fix ReDoS by using repeated space characters inside <!DOCTYPE name [<!ATTLIST>]> #176

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rexml/parsers/baseparser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def pull_event
contents = md[0]

pairs = {}
values = md[0].scan( ATTDEF_RE )
values = md[0].strip.scan( ATTDEF_RE )
values.each do |attdef|
unless attdef[3] == "#IMPLIED"
attdef.compact!
Expand Down
17 changes: 17 additions & 0 deletions test/parse/test_attlist.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require "test/unit"
require "core_assertions"

require "rexml/document"

module REXMLTests
class TestParseAttlist < Test::Unit::TestCase
include Test::Unit::CoreAssertions

def test_gt_linear_performance_attlist
kou marked this conversation as resolved.
Show resolved Hide resolved
seq = [10000, 50000, 100000, 150000, 200000]
assert_linear_performance(seq, rehearsal: 10) do |n|
REXML::Document.new('<!DOCTYPE schema SYSTEM "foo.dtd" [<!ATTLIST ' + " " * n + ' root v CDATA #FIXED "test">]>')
end
end
end
end
Loading