Repository navigation
Security
Found in a review of how the library treats input from someone else; the new
Handling untrusted input
page summarises the protections, and SECURITY.md says how to report a
vulnerability privately.
allow_paths=Falsemakes the reading functions treat input as X12 text
only. Every reading function accepts X12 text or a path to a file, so a
service passing on a string it received could be made to read a file on its
own disk.X12ModelReader,X12SegmentReader,iter_lines,read_lines,
to_dataframe,write_csv,match_claims,match_rowsandchecktake
allow_paths(defaultTrue, unchanged); with it off,checkalso stops
saying whether a path exists. The MCP server and the playground use it.
With paths allowed, only regular files are opened: a named pipe or device
could block forever.- Writing X12 refuses a value that contains a delimiter (X12 injection).
A segment terminator or element separator inside a value ended the element
early, so the rest of the value, for exampleSMITH~NM1*PR*2*OTHER PAYER
in a patient name, was written as new segments.x12()now raises a
ValueErrornaming the field; composite and repeating elements also refuse
the component and repetition separators. - Validation errors no longer quote the rejected value. Pydantic's
messages includedinput_value=..., often PHI, which ends up in logs. The
models now sethide_input_in_errors. - Decimal elements must be plain X12 decimals of at most 18 digits.
Python'sDecimalaccepted forms such as1E+999999999, which made the 835
balancing check fail with a rawdecimal.Overflowand could make writing
build a string of a billion digits. They are now a validation error. - The file cannot choose what is imported. ST01 was put into the name of
the parser module imported for a transaction; it must now be a three-digit
code of a supported set. Unsupported versions and codes are reported
without quoting values that do not look like version identifiers. - An unknown segment is logged by name only when the name looks like a
segment identifier, without a traceback, so a malformed file cannot write
its content into the application's logs. - Interchange delimiters must differ and must not be letters, digits or
spaces (the 4010 repetition position, which holdsU, is exempt). - The MCP server's generators make at most 10,000 claims, members or
patients per call, so an assistant cannot be talked into tying up the
machine. X12ParseExceptionmessages no longer quote the file. 3.0.0 said the
message named the segment, loop and HL "but not the file's content". It
could still include the HL number exactly as written, even when a
malformed file put other text there, and the original error's text, which
can quote a value. Files carry PHI, and error messages end up in logs. The
HL number is now shown only when it is a plain number, and the original
error is named by type only; it is still attached as__cause__.