Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions changelog.d/5540-anon-c0-escape-paths.security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- **The anonymizer refuses a C0 control byte that reached a rule-written field by an escape
route, on both adapters** (BACKLOG #5540). A field a surrogate rule writes was refused for a raw
C0 byte, but a byte the message's MSH-2 declared as its escape character was exempt, and an
escape sequence the engine's reader decodes to a C0 byte was not read, so sender text a rule
copies, such as a kept CX.4, could carry either one out. Both are now refused with the same
body-free `SurrogateSeparatorRefused`; the escape sequences refused include at least a hex
escape such as `\X07\` or `\X09\`, a line-break command such as `\.br\`, which decodes to CR,
and such a sequence spanning a subcomponent separator. A C0 byte written raw as an MSH-2
separator the message declares still passes, as the field's structure. An OBX-5 value the free-text rule would
keep, a number or a code, is redacted when it holds such a byte, raw or escaped, rather than
kept. DEL and the C1 controls are still not refused. The check runs before the site-code scrub,
which, with a site prefix configured, can re-pair escapes so that one decodes to a C0 byte in the
output. On a message's last line the engine trims some trailing control bytes and keeps the OBX-5
value.
15 changes: 9 additions & 6 deletions docs/PHI.md
Original file line number Diff line number Diff line change
Expand Up @@ -2779,7 +2779,7 @@ both are described below:
| A known partner, vendor or site token, or a routable IPv4 address, survives | The whole message |
| A routable IPv6 address appears. An IPv6 address the check can read counts unless it is unspecified, loopback, link-local, unique-local, multicast without the P flag, or in a documentation range (`2001:db8::/32`, `3fff::/20`). A multicast address with the P flag set is refused, whether or not it embeds a prefix: that includes the RFC 3306 and RFC 3956 forms and source-specific `ff3x::/32`. An IPv4-mapped or IPv4-compatible one counts when its IPv4 part is routable. An allowed address is not routable on the internet, but it can still name a site or a device: a unique-local address carries its site's random Global ID, and a link-local one built from a MAC carries that MAC. The forms it cannot read are below (BACKLOG #5654) | Fields no rule maps, what a retarget of a default field leaves past its first component, and the components an `id`, `mrn`, `ssn` or `dln` rule keeps past its first, as for the SSN and phone rows. In the MSH header, MSH-2 past its four encoding characters and every field from MSH-3 on that no rule rewrites, a field under a `keep` included, as written and decoded, and the part past component 1 of a header field an `id`, `mrn`, `ssn` or `dln` rule rewrites. Not checked, at least: MSH-1, the encoding characters, and component 1 of a field a rule rewrites, which holds the surrogate |
| The header's `MSH-12` version is made of digits and dots, and one run of digits is longer than 32 (`AnonError`, raised by the anonymizer before the leak-check runs) | The header |
| A rule's surrogate would hold the message's own field separator, CR, LF, an MLLP frame byte, NUL or another C0 control character, TAB included, or what a surrogate writes itself could hold a component, repetition or subcomponent separator or the escape character the message's `MSH-2` declares (`AnonError`, raised by the anonymizer before the leak-check runs; BACKLOG #5540). A field a surrogate rule writes, sender text it copies included, is refused for a C0 control character the message does not declare as its field separator, an `MSH-2` separator or its escape character, on both adapters, with at least the exception at the end of the message listed below (BACKLOG #5533 item 14). Not checked, at least: a field no rule writes, such as one a keep leaves or an OBX-5 value the free-text rule preserves. Not refused, at least: DEL, a C1 control and an escape sequence such as `\X09\`. What it could write is judged, not the one value the salt picked: the whole pool a `name`, `address` or `provider` rule draws from, so a space component separator refuses every address; any digit, for a `phone` or `dob` rule; and the fill and offset placeholder of a date. A field separator a surrogate could write is judged the same way. Text a surrogate copies from the sender is not checked for the `MSH-2` delimiters, at least a kept CX component, an SSN's dashes and a date's year, except at least the date of birth's fraction dot, which is checked; a phone number's dashes are written at fixed places and are checked. A keep on that field would emit the captured value; an overlay that points the field at `drop` clears it | The fields a rule rewrites |
| A rule's surrogate would hold the message's own field separator, CR, LF, an MLLP frame byte, NUL or another C0 control character, TAB included, or what a surrogate writes itself could hold a component, repetition or subcomponent separator or the escape character the message's `MSH-2` declares (`AnonError`, raised by the anonymizer before the leak-check runs; BACKLOG #5540). A field a surrogate rule writes, sender text it copies included, is refused for a C0 control character written as one, unless it is an `MSH-2` separator the message declares, and for an escape sequence the engine's reader decodes to one, at least a hex escape such as `\X09\`, a line-break command such as `\.br\`, and such a sequence spanning a subcomponent separator, on both adapters, with at least the exception at the end of the message listed below (BACKLOG #5533 item 14, #5540). A C0 byte the message declares as its escape character is refused too. An OBX-5 value the free-text rule would keep is redacted instead when it holds any C0 byte this sentence's refusal would refuse, written or decoded. A sequence spanning a component or repetition separator is not judged, as the engine's reader never pairs across one. Not checked, at least: a field no rule writes, such as one a keep leaves, and what the site-code scrub writes after this check: with a site prefix configured, replacing a subcomponent that holds an unclosed escape character can re-pair later escapes, so a rule-written field or kept OBX-5 value can leave holding a sequence that decodes to a C0 byte. Not refused, at least: DEL and a C1 control. What it could write is judged, not the one value the salt picked: the whole pool a `name`, `address` or `provider` rule draws from, so a space component separator refuses every address; any digit, for a `phone` or `dob` rule; and the fill and offset placeholder of a date. A field separator a surrogate could write is judged the same way. Text a surrogate copies from the sender is not checked for the `MSH-2` delimiters, at least a kept CX component, an SSN's dashes and a date's year, except at least the date of birth's fraction dot, which is checked; a phone number's dashes are written at fixed places and are checked. A keep on that field would emit the captured value; an overlay that points the field at `drop` clears it | The fields a rule rewrites |
| A dashed SSN (`NNN-NN-NNNN`) appears inside one field, or across fields the message's own field separator cut it into | Fields no rule maps, what a retarget of a default field leaves past its first component, and the components an `id`, `mrn`, `ssn` or `dln` rule keeps past its first. A cut shape counts when at least one of its fields is one no rule maps |
| A punctuated US phone number (`NNN-NNN-NNNN` or `(NNN) NNN-NNNN`) appears inside one field, or across fields the message's own field separator cut it into | Fields no rule maps, what a retarget of a default field leaves past its first component, and the components an `id`, `mrn`, `ssn` or `dln` rule keeps past its first. A cut shape counts when at least one of its fields is one no rule maps |
| A repetition with a non-empty first component and an `MR` or `MRN` id type: any component that is `MR` or `MRN` whole or as its first subcomponent, such as `12345^MR` or `12345^MR&L`, or components 5, 7 and 13, where CX.5, XON.7 and XCN.13 carry an id type, in any of their subcomponents too, such as `ID^^^AUTH^MR&local`. Those components are read so in every field whatever its type, so `70553^MRI^C4^^PET&MR` in `OBR-4`, a coded field and not a CX, is refused. An `MR` subcomponent past the first in any other component, such as the modality in `70553^PET&MR^C4`, does not count (BACKLOG #5654) | Fields no rule maps, except the header line, which this check skips whole |
Expand Down Expand Up @@ -3017,15 +3017,18 @@ that line.
- Whitespace after the last field of the last line. The engine's parser trims it before a rule
reads the value, and the tee does not. So a date in that field is filled by the engine and
emptied by the tee. A control byte there that the parser's trim removes, at least TAB, FF,
GS, RS and US, is trimmed by the engine the same way. Unless `MSH-1` or `MSH-2` declares it,
the tee refuses it where the surrogate copies it into the field it writes, at least in the
GS, RS and US, is trimmed by the engine the same way. Unless `MSH-1` or `MSH-2` declares it as
a separator, the tee refuses it where the surrogate copies it into the field it writes, at least in the
first component under an `id`, `mrn` or `dln` rule and in a component an identifier rule
keeps. It does not where the surrogate replaces or blanks that text, for example an `ssn`
rule's first component or a component an identifier rule blanks, and there the two adapters
can emit different surrogates: each keys its surrogate on the value it read, and the shape can
differ too, as for a dashed SSN the tee writes undashed. Where the message declares the byte,
neither adapter refuses it, and the two can emit different surrogates the same way. In a field
no rule maps, the tee emits the byte (BACKLOG #5533 item 14).
differ too, as for a dashed SSN the tee writes undashed. Where the message declares the byte as
a separator, neither adapter refuses it, and the two can emit different surrogates the same
way; a byte it declares as its escape character is refused as an undeclared one is. An OBX-5
value the free-text rule would keep is kept by the engine without the byte and redacted by the
tee, which reads the byte. In a field no rule maps, the tee emits the byte (BACKLOG #5533 item
14, #5540).

**The coverage report is the record of those fields.** It lists the address of every present
field that no rule mapped, never its value. A caller gets it through `on_report` on the clean path
Expand Down
Loading
Loading