Skip to content

Remove redundant REXML pre-parse in Saml::Base.parse - #195

Open
baala3 wants to merge 3 commits into
digidentity:masterfrom
baala3:remove-rexml-preparse
Open

Remove redundant REXML pre-parse in Saml::Base.parse#195
baala3 wants to merge 3 commits into
digidentity:masterfrom
baala3:remove-rexml-preparse

Conversation

@baala3

@baala3 baala3 commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Closes #194 (see issue for full analysis/verification of why this is safe).

Nokogiri/libxml2 has natively blocked entity-expansion DoS, including the parameter-entity bypass, since Nokogiri 1.11.4, so the REXML pre-parse tripwire is redundant and can be removed, along with the rexml dependency it required.

Changes

  • lib/saml/base.rb: remove the REXML pre-parse and its now-unneeded REXML::ParseException rescue.
  • saml.gemspec: drop the rexml dependency, require nokogiri >= 1.11.4, < 2.0.
  • spec/lib/saml/base_spec.rb: update specs for the new behavior.
  • spec/lib/saml/complex_types/request_abstract_type_spec.rb: the SOAP header spec used Hash.from_xml, which relied on ActiveSupport's REXML backend — no longer a guaranteed dependency. Rewritten to assert on the generated SOAP header via Nokogiri directly.

Test plan

  • bundle exec rspec spec/lib/saml/base_spec.rb spec/lib/saml/complex_types/request_abstract_type_spec.rb passes

baala3 added 3 commits August 16, 2026 13:10
Nokogiri (via libxml2) has blocked entity-expansion DoS natively
since 2.9.2, and the parameter-entity bypass (CVE-2021-3541) has been
covered since Nokogiri 1.11.4. The REXML pre-parse was only needed
as a tripwire in 2014 before Nokogiri had these protections, and its
RuntimeError wasn't even caught by the rescue clause below it, so it
leaked an undocumented raw exception instead of the library's usual
Saml::Errors::UnparseableMessage.

Refs digidentity#194
rexml is no longer used now that base.rb only parses via Nokogiri.
The nokogiri floor is bumped to 1.11.4, the first version that fixes
the parameter-entity ("Parameter Laughs") bypass, CVE-2021-3541.

Refs digidentity#194
Hash.from_xml used ActiveSupport's REXML backend, which is no longer
a guaranteed dependency now that rexml has been dropped. Assert on
the generated SOAP header directly via Nokogiri instead.

Refs digidentity#194
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove redundant REXML pre-parse in Saml::Base.parse as nokogiri blocks entity expansion natively

2 participants