Skip to content

Harden XML parsing via commons-secure-xml - #289

Draft
ppkarwasz wants to merge 1 commit into
masterfrom
feat/use-commons-xml
Draft

Harden XML parsing via commons-secure-xml#289
ppkarwasz wants to merge 1 commit into
masterfrom
feat/use-commons-xml

Conversation

@ppkarwasz

Copy link
Copy Markdown
Member

Warning

This PR was submitted automatically to smoke-test
Apache Commons Secure XML
and has not yet been verified by a human.
It will stay a draft until a committer reviews it and marks it ready.

Creates SAX parser and document builder factories through org.apache.commons:commons-secure-xml (1.0.0-SNAPSHOT until its first release) in commons-digester3-core. The secure factories enable XML secure processing and install a non-removable entity-resolver floor: external DTD, entity, schema and XInclude lookups that a caller-set resolver does not resolve are resolved to empty content instead of being fetched, and internal entity expansion is bounded.

  • Digester.getFactory() and DigesterLoader go through SecureSAXParserFactory, NodeCreateRule through SecureDocumentBuilderFactory. The caller-facing configuration (namespace and XInclude awareness, validation, schema, features and properties) keeps working, and getFactory() still returns a plain SAXParserFactory.
  • Digester itself acts as the entity resolver of the readers it creates, and resolvers installed by the caller keep precedence over the floor, so registered entities, relative DTDs and DTD validation resolve exactly as before; the floor only takes effect for parsers whose resolver chain leaves a lookup unresolved. All DTD-validation, entity-resolution, XInclude and schema tests pass unchanged.
  • Callers supplying their own SAXParser or XMLReader keep full control of their parser configuration.
  • CI and CodeQL run with -Puse-apache-snapshots so the SNAPSHOT dependency resolves.

🤖 Generated with Claude Code

Create SAX parser and document builder factories through
org.apache.commons:commons-secure-xml. The secure factories enable
FEATURE_SECURE_PROCESSING and install a non-removable entity-resolver
floor on every parser they produce: external DTD, entity, schema and
XInclude lookups that a caller-set resolver does not resolve are
resolved to empty content instead of being fetched, and internal entity
expansion is bounded, regardless of the JAXP implementation on the
classpath.

Changes:
- Add the commons-secure-xml dependency (1.0.0-SNAPSHOT until its first
  release) to commons-digester3-core.
- Route factory creation through SecureSAXParserFactory in
  Digester.getFactory() and DigesterLoader, and through
  SecureDocumentBuilderFactory in NodeCreateRule. The caller-facing
  configuration (namespace and XInclude awareness, validation, schema,
  features and properties) keeps working, and getFactory() still
  returns a plain SAXParserFactory.
- Digester itself acts as the entity resolver of the readers it
  creates, and resolvers installed by the caller keep precedence over
  the floor, so registered entities, relative DTDs and DTD validation
  resolve exactly as before; the floor only takes effect for parsers
  whose resolver chain leaves a lookup unresolved.
- Callers supplying their own SAXParser or XMLReader (constructors and
  DigesterLoader.newDigester overloads) keep full control of their
  parser configuration.
- Run the CI and CodeQL builds with -Puse-apache-snapshots (inherited
  from the org.apache:apache parent POM) so the commons-secure-xml
  SNAPSHOT resolves; CodeQL's autobuild receives the profile through
  MAVEN_ARGS.

Assisted-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MHgnMnGWHQoH2zD2jFdoMT
@ppkarwasz
ppkarwasz force-pushed the feat/use-commons-xml branch from 846b7a6 to ccd7f6f Compare August 31, 2026 15:09
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