Skip to content

x12sdk 3.1.0

Latest

Choose a tag to compare

@owgreen-dev owgreen-dev released this 29 Nov 04:08
· 6 commits to main since this release
1292573

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=False makes 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_rows and check take
    allow_paths (default True, unchanged); with it off, check also 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 example SMITH~NM1*PR*2*OTHER PAYER
    in a patient name, was written as new segments. x12() now raises a
    ValueError naming the field; composite and repeating elements also refuse
    the component and repetition separators.
  • Validation errors no longer quote the rejected value. Pydantic's
    messages included input_value=..., often PHI, which ends up in logs. The
    models now set hide_input_in_errors.
  • Decimal elements must be plain X12 decimals of at most 18 digits.
    Python's Decimal accepted forms such as 1E+999999999, which made the 835
    balancing check fail with a raw decimal.Overflow and 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 holds U, 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.
  • X12ParseException messages 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__.