Commit 4bbd072
Use PipeParser for inbound HL7 to remove XML/XXE attack surface (#6319)
Backport of #6223 to 2.9.x.
The hL7Parser bean was a HAPI GenericParser, which auto-detects message
encoding and routes XML-encoded payloads to HAPI's XML parser. On
hapi-base 2.1 that parser builds an unhardened LSParser (no
disallow-doctype-decl, external general/parameter entities enabled),
exposing XML external entity (XXE) processing: external file reads, SSRF
and entity-expansion DoS. Inbound HL7 parsing runs before authorization,
so the surface is reachable pre-auth.
OpenMRS only ever produces and consumes pipe-delimited (ER7) HL7v2, so the
XML branch is unused. Switch the bean to PipeParser, which rejects XML
payloads outright with an unsupported-encoding error. The HL7ServiceImpl
parser field and setter are widened to the common Parser supertype so the
existing XML setter injection still resolves. Adds a regression test.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent a490d5f commit 4bbd072
3 files changed
Lines changed: 29 additions & 4 deletions
File tree
- api/src
- main
- java/org/openmrs/hl7/impl
- resources
- test/java/org/openmrs/hl7
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
301 | 304 | | |
302 | 305 | | |
303 | 306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
189 | 211 | | |
190 | 212 | | |
191 | 213 | | |
| |||
0 commit comments