Skip to content

Update HAPI to 2.6.0 to close XXE vulnerability - #448

Open
mgaffigan wants to merge 2 commits into
OpenIntegrationEngine:mainfrom
mgaffigan:maint/hapi-260
Open

mgaffigan wants to merge 2 commits into
OpenIntegrationEngine:mainfrom
mgaffigan:maint/hapi-260

Conversation

@mgaffigan

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions

github-actions Bot commented Sep 19, 2026

Copy link
Copy Markdown

Test Results

124 files  + 1  124 suites  +1   2m 15s ⏱️ +26s
696 tests + 6  695 ✅ + 5  0 💤 ±0  1 ❌ +1 
720 runs  +18  719 ✅ +17  0 💤 ±0  1 ❌ +1 

For more details on these failures, see this check.

Results for commit be23f39. ± Comparison against base commit 9359d9a.

♻️ This comment has been updated with latest results.

Signed-off-by: Mitch Gaffigan <mitch.gaffigan@comcast.net>
Signed-off-by: Mitch Gaffigan <mitch.gaffigan@comcast.net>
Comment thread gradle/libs.versions.toml
hapi-structures-v27 = { module = "ca.uhn.hapi:hapi-structures-v27", version = "2.3" }
hapi-structures-v28 = { module = "ca.uhn.hapi:hapi-structures-v28", version = "2.3" }
hapi-structures-v281 = { module = "ca.uhn.hapi:hapi-structures-v281", version = "2.3" }
hapi-base = { module = "ca.uhn.hapi:hapi-base", version = "2.6.0" }

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.

This upgrade introduces silent data loss for valid HL7 XML containing CDATA. Reproduced through OIE's ER7Serializer on Java 17 and 21, changing only the HAPI libraries:

  • <HD.1><![CDATA[clinical]]></HD.1>: HAPI 2.3 preserves clinical; 2.6.0 produces an empty MSH-3 field.
  • <HD.1>before<![CDATA[clinical]]>after</HD.1>: 2.3 preserves beforeclinicalafter; 2.6.0 returns beforeafter.

Both conversions report success. These inputs contain no DOCTYPE or external entity.

Affected paths are fromXML with strict parsing enabled (validation on or off), and toXML for XML input with strict parsing and validation both enabled. HAPI 2.6.0's XMLUtils.parseDocument uses a DOM builder without enabling coalescing, while XMLParser.parsePrimitive only appends text nodes, so CDATA nodes are discarded.

The targeted XXE fix works in the tested engine paths: baseline file disclosure and network requests were reproduced, and 2.6.0 prevented both for external entity and DTD payloads. Please preserve CDATA field contents while retaining those restrictions, and add regression coverage for pure and mixed CDATA on both affected paths before merging.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Seems like an upstream bug. I agree with adding regression tests, but can someone get an upstream but open or linked?

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