Skip to content

WW-5621 Harden XML parsers against Entity Expansion (Billion Laughs) attacks#1642

Open
lukaszlenart wants to merge 1 commit intomainfrom
harden/xml-entity-expansion-protection
Open

WW-5621 Harden XML parsers against Entity Expansion (Billion Laughs) attacks#1642
lukaszlenart wants to merge 1 commit intomainfrom
harden/xml-entity-expansion-protection

Conversation

@lukaszlenart
Copy link
Copy Markdown
Member

@lukaszlenart lukaszlenart commented Mar 29, 2026

Summary

Fixes WW-5621

Defense-in-depth hardening of XML parsers against Entity Expansion (Billion Laughs) attacks. This is not an exploitable vulnerability — modern JDKs (7u45+) already enforce a 64K entity expansion limit, and all XML sources come from the classpath, not user input.

Changes

  • Enable FEATURE_SECURE_PROCESSING in DomHelper and Tiles DigesterDefinitionsReader
  • Remove unused parseStringAsXML feature from StringAdapter to eliminate theoretical attack surface
  • Deprecate getParseStringAsXML() / setParseStringAsXML() for future removal

Tests

  • Add Billion Laughs protection test to DomHelperTest (core)
  • Add Billion Laughs protection test to TestDigesterDefinitionsReader (tiles)
  • Add StringAdapterTest covering the deprecated no-op parseStringAsXML contract

Test plan

  • mvn test -DskipAssembly -pl core -Dtest=DomHelperTest — 5 tests pass
  • mvn test -DskipAssembly -pl plugins/xslt -Dtest=StringAdapterTest — 2 tests pass
  • mvn test -DskipAssembly -pl plugins/tiles -Dtest=TestDigesterDefinitionsReader — 3 tests pass

🤖 Generated with Claude Code

@lukaszlenart lukaszlenart force-pushed the harden/xml-entity-expansion-protection branch from d5080f5 to 2254b73 Compare March 29, 2026 05:47
…attacks

Modern JDKs (7u45+) already protect against this attack with a built-in
64K entity expansion limit. These changes add defense-in-depth hardening
and remove unnecessary attack surface.

- Remove unused parseStringAsXML feature from StringAdapter to eliminate
  a theoretical XML Entity Expansion vector
- Deprecate setParseStringAsXML() and getParseStringAsXML() for removal
- Enable SECURE_PROCESSING feature in DigesterDefinitionsReader
- Add unit test verifying JDK's entity expansion limit rejects
  Billion Laughs payloads
- Add research document with vulnerability analysis

Co-Authored-By: Claude <noreply@anthropic.com>
@lukaszlenart lukaszlenart force-pushed the harden/xml-entity-expansion-protection branch from 2254b73 to 80c2c13 Compare March 29, 2026 06:05
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
75.0% Coverage on New Code (required ≥ 80%)
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@lukaszlenart lukaszlenart marked this pull request as ready for review March 29, 2026 06:15
lukaszlenart added a commit that referenced this pull request Mar 29, 2026
…attacks

Backport of #1642 from Struts 7 to Struts 6.

Modern JDKs (7u45+) already protect against this attack with a built-in
64K entity expansion limit. These changes add defense-in-depth hardening
and remove unnecessary attack surface.

- Enable FEATURE_SECURE_PROCESSING in DomHelper SAX parser
- Enable FEATURE_SECURE_PROCESSING in DigesterDefinitionsReader
- Remove unused parseStringAsXML feature from StringAdapter to eliminate
  a theoretical XML Entity Expansion vector
- Deprecate setParseStringAsXML() and getParseStringAsXML() for removal
- Add Billion Laughs protection tests for DomHelper and DigesterDefinitionsReader

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant