Skip to content

XML Parser Hardening v6#3078

Merged
rrayst merged 5 commits into
6.Xfrom
xml-parser-hardening-v6
Jul 10, 2026
Merged

XML Parser Hardening v6#3078
rrayst merged 5 commits into
6.Xfrom
xml-parser-hardening-v6

Conversation

@predic8

@predic8 predic8 commented Jul 10, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Security Enhancements

    • Strengthened XML and SOAP processing to block external DTDs, schemas, and entity resolution.
    • Improved XML protection when detecting and handling external DTD references.
    • Added secure parsing and schema validation safeguards across supported XML workflows.
  • Tests

    • Added coverage confirming external XML resources are never fetched.
    • Expanded validation for DTD removal, rejection, and secure parser behavior.

predic8 added 2 commits June 26, 2026 14:36
- Introduced `HardenedSaxParser` and `HardenedSchemaFactory` for XXE-protected XML parsing and schema validation.
- Updated existing validators and utilities to leverage hardened parsers.
- Added comprehensive test coverage to ensure external entity prevention across parsing and validation workflows.
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a8787241-60b4-42bc-a6e0-23104632dc57

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Changes

The XML processing paths now use hardened SAX and schema factories, block external DTD access, detect external DTD subsets in XMLProtector, and add tests covering parser, validator, SOAP, and DTD-protection behavior.

XML security hardening

Layer / File(s) Summary
Hardened parser utilities
core/src/main/java/com/predic8/membrane/core/util/xml/parser/*, core/src/test/java/com/predic8/membrane/core/util/xml/parser/*
Adds hardened SAX and schema factory utilities and tests secure parsing, validation, and blocked external DTD access.
Hardened XML and SOAP integrations
core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/*, core/src/main/java/com/predic8/membrane/core/interceptor/soap/*, core/src/main/java/com/predic8/membrane/core/util/{MessageUtil,SOAPUtil}.java, core/src/test/java/com/predic8/membrane/core/interceptor/{schemavalidation,soap}/*
Routes schema validation and SOAP XML processing through shared hardened parser configurations and verifies that external DTDs are not fetched.
DTD subset detection and protection
core/src/main/java/com/predic8/membrane/core/interceptor/xmlprotection/XMLProtector.java, core/src/test/java/com/predic8/membrane/core/interceptor/xmlprotection/XMLProtectorTest.java
Detects external DTD subset references, blocks resolver access, and validates or removes DTD events according to configuration with expanded parsing tests.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SOAPRequest
  participant XMLSchemaValidator
  participant HardenedSaxParser
  participant HardenedSchemaFactory
  participant Validator
  SOAPRequest->>XMLSchemaValidator: provide XML message body
  XMLSchemaValidator->>HardenedSaxParser: create hardened XMLReader
  XMLSchemaValidator->>HardenedSchemaFactory: create hardened schema factory
  HardenedSchemaFactory->>Validator: configure validator
  XMLSchemaValidator->>Validator: validate SAXSource
Loading

Suggested reviewers: rrayst

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the main change: hardening XML parsing and validation utilities.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch xml-parser-hardening-v6

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@predic8

predic8 commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@membrane-ci-server

Copy link
Copy Markdown

This pull request needs "/ok-to-test" from an authorized committer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
core/src/test/java/com/predic8/membrane/core/interceptor/schemavalidation/SOAPUtilTest.java (1)

32-33: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Consider extracting shared test helpers into a dedicated utility.

freePort/startRecordingServer are consumed here and in XMLSchemaValidatorTest and SoapOperationExtractorTest via static imports from HardenedSaxParserTest. Depending on another test class couples unrelated test lifecycles; moving these into a small shared test-support class would decouple them.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@core/src/test/java/com/predic8/membrane/core/interceptor/schemavalidation/SOAPUtilTest.java`
around lines 32 - 33, Extract freePort and startRecordingServer from
HardenedSaxParserTest into a dedicated shared test-support utility, then update
SOAPUtilTest, XMLSchemaValidatorTest, and SoapOperationExtractorTest to use
static imports from that utility instead. Remove the cross-test-class dependency
while preserving the helpers’ behavior and visibility.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@core/src/test/java/com/predic8/membrane/core/interceptor/schemavalidation/SOAPUtilTest.java`:
- Around line 32-33: Extract freePort and startRecordingServer from
HardenedSaxParserTest into a dedicated shared test-support utility, then update
SOAPUtilTest, XMLSchemaValidatorTest, and SoapOperationExtractorTest to use
static imports from that utility instead. Remove the cross-test-class dependency
while preserving the helpers’ behavior and visibility.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 27a9ec20-c5d8-4b80-a8d9-446ebb5301a5

📥 Commits

Reviewing files that changed from the base of the PR and between 4d45439 and adb1412.

📒 Files selected for processing (14)
  • core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/AbstractXMLSchemaValidator.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/XMLSchemaValidator.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/soap/SoapOperationExtractor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/xmlprotection/XMLProtector.java
  • core/src/main/java/com/predic8/membrane/core/util/MessageUtil.java
  • core/src/main/java/com/predic8/membrane/core/util/SOAPUtil.java
  • core/src/main/java/com/predic8/membrane/core/util/xml/parser/HardenedSaxParser.java
  • core/src/main/java/com/predic8/membrane/core/util/xml/parser/HardenedSchemaFactory.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/schemavalidation/SOAPUtilTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/schemavalidation/XMLSchemaValidatorTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/soap/SoapOperationExtractorTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/xmlprotection/XMLProtectorTest.java
  • core/src/test/java/com/predic8/membrane/core/util/xml/parser/HardenedSaxParserTest.java
  • core/src/test/java/com/predic8/membrane/core/util/xml/parser/HardenedSchemaFactoryTest.java

@rrayst

rrayst commented Jul 10, 2026

Copy link
Copy Markdown
Member

/ok-to-test

@rrayst rrayst merged commit 9683e8c into 6.X Jul 10, 2026
3 checks passed
@rrayst rrayst deleted the xml-parser-hardening-v6 branch July 10, 2026 14:45
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.

2 participants