Skip to content

[backport camel-4.18.x] CAMEL-24299: disable DTD support in XmlStreamDetector for consistency with other XML parsers - #25320

Merged
oscerd merged 1 commit into
apache:camel-4.18.xfrom
oscerd:backport/25279-to-camel-4.18.x
Aug 4, 2026
Merged

[backport camel-4.18.x] CAMEL-24299: disable DTD support in XmlStreamDetector for consistency with other XML parsers#25320
oscerd merged 1 commit into
apache:camel-4.18.xfrom
oscerd:backport/25279-to-camel-4.18.x

Conversation

@oscerd

@oscerd oscerd commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Backport of #25279

Cherry-pick of #25279 onto camel-4.18.x (clean, no conflicts).

Original PR: #25279CAMEL-24299: disable DTD support in XmlStreamDetector for consistency with other XML parsers
Original author: @oscerd
Target branch: camel-4.18.x

What

XmlStreamDetector created its StAX XMLInputFactory with IS_SUPPORTING_EXTERNAL_ENTITIES=false but left SUPPORT_DTD at its default. This adds factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE), for consistency with XmlConverter / StaxConverter, as defence-in-depth against DTD-based attacks (e.g. entity-expansion DoS). Non-breaking: Camel route XML does not use DTDs.

Sanity build: full-reactor mvn clean install -DskipTests green on camel-4.18.x; XmlStreamDetectorTest (7 tests incl. the DTD-rejection case) passes.

… with other XML parsers (apache#25279)

XmlStreamDetector created its StAX XMLInputFactory with IS_SUPPORTING_EXTERNAL_ENTITIES=false
but left SUPPORT_DTD at its default. For consistency with XmlConverter / StaxConverter (which
disable DTDs) and as defence-in-depth against DTD-based attacks (e.g. entity-expansion DoS), set
XMLInputFactory.SUPPORT_DTD=false. External entities were already blocked; the detector only
pre-scans XML to determine the root element, so rejecting DTD-bearing input is safe.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@oscerd oscerd added the backport indicate that a Pull request is a backport from a fix from the main branch label Aug 4, 2026
@oscerd oscerd added the enhancement New feature or request label Aug 4, 2026
@oscerd oscerd self-assigned this Aug 4, 2026
@oscerd oscerd added this to the 4.18.4 milestone Aug 4, 2026
@oscerd
oscerd merged commit f4dce1f into apache:camel-4.18.x Aug 4, 2026
3 checks passed
@oscerd
oscerd deleted the backport/25279-to-camel-4.18.x branch August 4, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport indicate that a Pull request is a backport from a fix from the main branch enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants