Skip to content

Db contrib/veracode CWE-611 (Improper Restriction of XML External Entity Reference) - #294

Open
daniel-marian-buga-a-db wants to merge 2 commits into
finos:mainfrom
deutschebank:db-contrib/veracode-CWE-ID-611
Open

Db contrib/veracode CWE-611 (Improper Restriction of XML External Entity Reference)#294
daniel-marian-buga-a-db wants to merge 2 commits into
finos:mainfrom
deutschebank:db-contrib/veracode-CWE-ID-611

Conversation

@daniel-marian-buga-a-db

Copy link
Copy Markdown

Summary

This PR fixes CWE-611 (Improper Restriction of XML External Entity Reference) for XML transformation/writer paths in spin/dataformat-xml-dom.

Code changes

File: DomXmlDataFormat.java

Added enableSecureProcessing(TransformerFactory) method to harden transformer configuration.

Hardened defaultTransformerFactory() by configuring:

transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");

This protects both transformation sinks used by DomXmlDataFormatWriter:

  • Pretty-print path:

    getFormattingTransformer().transform(...)
  • Non-pretty-print path:

    getTransformer().transform(...)

Test changes

File: DomXmlDataFormatProtectionTest.java

Added test:

shouldDenyExternalStylesheetAccessInFormattingConfiguration()

The test:

  • Creates an XSL that attempts to include an external stylesheet via: xsl:include href="file:..."
  • Verifies configuration fails with SpinXmlDataFormatException
  • Confirms external stylesheet resolution is blocked by secure transformer settings

Why this fix

Parser-side hardening already existed (DocumentBuilderFactory), but the writer-side TransformerFactory was not explicitly hardened.

This PR closes that gap and aligns with OWASP/JAXP XXE prevention guidance.

Validation

The implementation has been validated through:

  • ✅ Successful local builds
  • ✅ Successful mvn -pl spin/dataformat-all -am verify validation of the affected modules
  • ✅ Successful full repository mvn verify
  • ✅ Targeted, additional unit tests covering the newly introduced XXE protection logic

Impact Assessment

  • Security hardening only: XXE/external resource resolution prevention in transformer path
  • No functional behavior changes: valid internal XML/XSL processing is unaffected

…ansformerFactory and adding regression test

Merge in FLUXNOVA/fluxnova-bpm-platform from feature/veracode-CWE-ID-611 to db-feature/veracode-CWE-ID-611

* commit '6a313cd72e78ea5c54debc4f6dc36de3a124a724':
  fix Improper Restriction of XML External Entity Reference (CWE ID 611)
@daniel-marian-buga-a-db
daniel-marian-buga-a-db requested a review from a team as a code owner September 1, 2026 11:29
@daniel-marian-buga-a-db
daniel-marian-buga-a-db requested a review from a team September 1, 2026 11:29
@daniel-marian-buga-a-db daniel-marian-buga-a-db changed the title Db contrib/veracode CWE id 611 Db contrib/veracode CWE-611 (Improper Restriction of XML External Entity Reference) Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant