Remove redundant REXML pre-parse in Saml::Base.parse - #195
Open
baala3 wants to merge 3 commits into
Open
Conversation
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
benoist
approved these changes
Aug 16, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
rexmldependency it required.Changes
lib/saml/base.rb: remove the REXML pre-parse and its now-unneededREXML::ParseExceptionrescue.saml.gemspec: drop therexmldependency, requirenokogiri >= 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 usedHash.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.rbpasses