Skip to content

DICOM log redaction is fail-closed: an unrecognised library line is withheld (BACKLOG #6637) - #3208

Open
wshallwshall wants to merge 58 commits into
mainfrom
b629/6637-dicom-redactor
Open

wshallwshall wants to merge 58 commits into
mainfrom
b629/6637-dicom-redactor

Conversation

@wshallwshall

Copy link
Copy Markdown
Collaborator

Batch 629, row #6637 item 10. Stacked on PR 3197: land that first, then retarget this to main. It replaces the DICOM log screen's list of known-bad lines with a default-deny screen.

Merge danger

Reversible: yes. A revert of this squash restores the old screen. No schema, store or settings change.

Blast radius: messagefoundry/transports/dicom.py, new messagefoundry/transports/_dicom_log_lines.py, docs/DICOM.md, docs/PHI.md, the census guard and tests.

Visible behaviour:

  • Every pynetdicom and pydicom logger is default-deny at every level, against 236 pinned value-free lines and 131 templates (pynetdicom 3.0.4, pydicom 3.0.2). A line matching neither is withheld. On a pinned line, a failing field reads [redacted] and the fixed text stays.
  • Operators lose: C-FIND, C-GET and C-MOVE progress lines and identifier dumps, the text of any library exception matching no template (including OS socket text), all exception notes and group members, and any line a library upgrade adds until it is pinned.
  • A TCP initialisation failure keeps neither class nor raising place, so an operator cannot tell refused from timeout or DNS failure.
  • A delivery-outcome change: a confirmed C-STORE Success or Warning followed by a failed release is now delivered, and the association is aborted (decision d20261123T195845254-6d02c2). A re-send would store the object again for the whole retry budget.
  • _c_store scrubs library text from a DeliveryError chain, using an engine-owned exception that holds only the class name.

Evidence

  • Failed before, pass after: tests/test_dicom_log_screen.py, including late-created and non-propagating loggers, cause and context chains, the failed-release cases and the unnameable-class cases. test_no_dicom_log_template_has_a_nested_quantifier was shown red on a mutated slot.
  • Existing tests changed: test_dicom_peer_value_logs.py, test_dicom_scp_receipt_bounds.py and test_dicom_scu_abort_bound.py. No-leak assertions were kept. test_a_tag_and_quote... now asserts withheld, which reverses what it pinned, by design.
  • Checks at head 80ecefbeabf: ruff, ruff format, all four mypy legs, pytest --dist loadfile -n 6 with -k "dicom or redact or logging or boundaries or last_resort or phi or changelog or security_static": 5816 passed, 10 skipped, 38 xfailed.
  • Not run: the full suite. Unread hosted legs: all of them. No CI result has been read for this head.

Proposed ledger banner

PARTIAL on the row. Item 10: every pynetdicom and pydicom logger is default-deny at every level against pinned templates, tracebacks included, with an AST census guard. Stays open under item 10: a library exception the SCU does not wrap can print library text through the engine's worker fault log when a non-driver store fault follows, reaches last_error, and on Test Connection reaches the result detail. Stated limit: the screen assumes a library exception's class behaves as ordinary Python; a class with hostile attribute, __str__ or metaclass code can still get text past it, and a class name is written. Also open on this row: items 8, 9, 12, 13, 16, 17, 18 and 20, and any item PR 3197 leaves open.

Paths by which a value could still leave on a first deployment

  1. An unwrapped library exception reaches the store (measured). last_error at wiring_runner.py:11804 (CONTINUE) and 11786-11790 (STOP). The batch arm has the same shape near lines 12300 and 12319 (read, not measured).
  2. The same exception reaches the worker fault log (measured) at wiring_runner.py:11371, when a non-driver store fault follows.
  3. Test Connection: an exception from send_c_echo or _associate reaches the result detail through safe_exc at api/app.py:4612. Measured on the exception, not a live API call.
  4. A hostile library exception class: under the stated limit. Reviewers reproduced a metaclass name returning text, a str subclass from __str__, and a BaseException from __str__.

Items 1 and 2 need a runner change outside this PR, and need a row.

Open findings at this head, none repaired

Items 1 and 2 need your classification and may go to the owner:

  1. False control statement. dicom.py:703: an Exception from the diagnostic logger.debug escapes _screen_record before the rewrite (needs DEBUG on and a host filter that raises; reviewer reproduced), so the docstring and docs/DICOM.md claim that such an exception withholds the line is too wide. Line 720 has the same ordering.
  2. Log forging. dicom.py:706 and 719: a class name holding a newline is written unescaped to the withheld line and exc_text.
  3. The marker test raises only in the message stage, so the traceback half is unpinned.
  4. A retry after a BaseException re-screens its own output and can lose a valid line (fails closed).
  5. Nothing statically guards the fullmatch dependency. At least one template is slow under .search (973 ms against 0.12 ms at 16,000 characters).
  6. The traceback renders from exc.__traceback__ and ignores the record's exc_info.
  7. type(exc).__name__ remains at lines 602, 954, 1551 and 1574. By reading, a raising name at 1551 or 1574 would skip the abort or reject with DEBUG on.
  8. docs/DICOM.md:389 restates line 375's fact about class names with a different safety implication, and "outside" the screen could lead a reader to remove defenses _UNNAMEABLE still pins.
  9. The two-run claim is only partly pinned: the test excludes quoted_uid.
  10. Earlier, still open: the failed-release helper sends no A-RELEASE-RQ; the gives cases repeat one assertion; library_class duplicates __qualname__; the template staleness guard compares 16 characters; the linear-cost test uses a wall-clock bound; see_url keeps any path under dicom.nema.org; a test's logger-absence control fails on a rerun in one process.

…ation dumps

pynetdicom's DEBUG dump of an A-ASSOCIATE-RQ, received or sent, prints a
user identity's Username and Password in clear, on pynetdicom._handlers.
On a first deployment at DEBUG that would write a peer's credential to the
log. Both lines now keep their label and lose the value, whatever it
spells. Tests plant a synthetic pair on the wire and read the formatted
output, with a control that sees it unfiltered.

BACKLOG #6637 item 6.
…om.dimse

When a received DIMSE message does not convert to its primitive,
pynetdicom.dimse logs the refusal and its traceback, each naming the value.
The SCU reaches this from a peer's response, so on a first deployment a
peer could put a value of its choosing in the log. The dimse logger now
carries the refused-value shape. The test sends a real C-ECHO-RSP from a
peer and reads the formatted output, traceback included.

BACKLOG #6637 item 4.
Traceback redaction was keyed on the logger and its own shapes, so a
refusal raised inside an exception logged on another logger, at least
pynetdicom.association and pynetdicom.events, would have reached the log
whole, and so would pydicom's shape on pynetdicom.dul. The refusal shapes
are now one list read on every filtered logger, anywhere in the text,
and the filter is on each pynetdicom module that logs an exception. A
test pins that list against pynetdicom's source. Where one message holds
two shapes, the earliest head decides, so the second goes with the first.

BACKLOG #6637 item 5.
pydicom's Specific Character Set lines and its VR IS and DS line name a
value a peer sent, and pynetdicom.association's "No presentation context
for" ERROR names an object's SOP class and transfer syntax. On a first
deployment each would write that value to the log, and pydicom's copy as a
UserWarning to stderr. The pydicom lines lose the value, as lines and as
refusals in an exception, and their warning copies are ignored. The
no-context line stays whole only where both of its values are conformant
or in pydicom's UID dictionary, so a real SOP class is still named.

BACKLOG #6637 item 7.
A codec error on a filtered logger names a byte of what it failed on.
The engine's log chain renders it safely, but a host's handlers need not,
so the filter now does it too, in the message, its args and the traceback.
The SCU re-installs the pydicom warnings filter before each association,
so a destinations-only host that reset the filters no longer gets the copy
on stderr. The engine's own C-STORE decode, encode and delivery errors now
redact a refusal they quote, since redact() does not recognise a UID.

BACKLOG #6637 items 11, 14 and 15.
The DS and IS warning pattern was quadratic on a crafted value, and it is
the first filter every UserWarning meets. It is now matched from the start
of the text. Each warning pattern sits on its shape, so the two lists
cannot drift. The SCU reinstalls the filters only when they are not
already first, since each filterwarnings call resets every module's
once-per-location record and would repeat other warnings once per send.

BACKLOG #6637.
The fixed threshold sat above what the old pattern cost on this text, so
it could not fail on the unfixed code. The test now times the quadratic
form on the same text as its control, so load slows both.

BACKLOG #6637.
The engine's error text now reads the refusal shapes before redact(),
which rewrote pydicom's head and would have kept the value. The SCU
installs the warning ignores before it reads the object, and always does
so under context-aware warnings, where warnings.filters is not the list in
force. A traceback whose chain has notes or group members is withheld,
since this walk does not read them. The fake-peer helper is one copy now,
and the filter cost test reads the patterns rather than a clock.

BACKLOG #6637
Proposed PR title: DICOM log redaction: peer credentials, chained
refusals, charset and IS/DS lines (BACKLOG #6637)
Proposed banner: PARTIAL. Part A fixes items 4, 5, 6, 7, 11, 14, 15.
Stay open: 1 to 3 and 19 (next Builder), 8, 9, 10 (design), 12, 13, 16,
17, 18, 20.
pydicom's length refusal quotes a numeric element's raw bytes, so it is
now a known refusal. The association dumps lose the hex of an extended
negotiation item's application information. Traceback replaces run
longest first, so a short message cannot break the match of one holding
it. The SCP puts the warning ignores back at each C-STORE, and DICOM.md
states which points do and do not, and the context-aware cost.

BACKLOG #6637
Proposed PR title: DICOM log redaction: peer credentials, chained
refusals, charset and IS/DS lines (BACKLOG #6637)
Proposed banner: PARTIAL. Part A fixes items 4, 5, 6, 7, 11, 14, 15.
Stay open: 1 to 3 and 19 (next Builder), 8, 9, 10 (design), 12, 13, 16,
17, 18, 20, and the SCU's SOPInstanceUID read outside its bad-object try.
Part B of the row, the leak findings Part A left open, each planted and
failing first:

- pynetdicom.association's no-service-class line names the SOP class a
  peer's command carries, reachable on the SCP. It now keeps a conformant
  or dictionary-named class and redacts anything else.
- pydicom's "is not a valid private creator" line, its UserWarning copy
  and the KeyError it raises would each carry a multi-valued creator
  whole. All three are redacted. The shape's head is general, so it counts
  only on a line that holds the fixed end.
- The SCU's add_requested_context and SOPInstanceUID read sat outside
  every try, so a refused class or a UID that does not convert escaped
  as an internal error with its value in last_error, and under the STOP
  policy could stop the lane. Both are now a permanent bad-object.
Row items 1 to 3. Choice, in one line: a floor setting on the SCP,
min_message_bytes_per_second, not a permanent SCU classification,
because the setting delivers the object, where a classification could
only dead-letter it, and the SCU cannot tell this abort from any other.

The default stays 64 KiB a second. A set value must be a whole number of
at least 8192, so None, zero and every other spelling of off are refused
when the connection is built, and the slow-sender deadline stays bounded.
The ended-association line now names the setting.

A test sends a 200 KiB object over a throttled 32 KiB/s loopback link:
the shipped rate cuts it, and a rate under the link delivers it on the
first attempt.

Measured while building this: the engine's own SCU applies its
timeout_seconds from the start of a store to the response, so it cuts a
slow store itself. docs/DICOM.md says to raise it on such a link too.
Row item 19, measured and fixed. With delays that hold pynetdicom's
window open, the reactor took the one store's response and dropped it,
so the send waited out its DIMSE timeout and would re-send an object the
peer had stored. The SCU now clears the reactor checkpoint on
EVT_ACCEPTED, before the association reads as established, so the first
reactor pass stops there. The new test fails without the hold, and its
control shows the same delays still lose a response when it is removed.
… over

The _Shape docstring said no pattern can backtrack; a warning pattern can,
though each stays linear. docs/DICOM.md now states the two lines this
branch covers, and lists pydicom's Unknown VR debug line as not covered.
BACKLOG #6637
Proposed PR title: DICOM: peer values and credentials out of the log,
and a remedy for the slow-link deadline band (BACKLOG #6637)
Proposed banner: PARTIAL. Remedy chosen: a bounded SCP setting,
min_message_bytes_per_second (default 64 KiB/s, minimum 8 KiB/s, cannot
be off), because it delivers the object where an SCU classification
could only dead-letter it. Fixed: items 1 to 3, 4, 5, 6, 7, 11, 14, 15,
19, plus the no-service-class and private creator lines and the SCU's
two unguarded reads. Stay open: 8, 9, 10 (design), 12, 13, 16, 17, 18,
20. A later commit on this branch supersedes this text if it differs.
No behaviour change. The per-message rate constant is named for what it
now is, the default. The tally takes its rate as a required keyword, so
a caller cannot silently miss the setting. One anchor field replaces a
second copy of the same text on the shape. The rate reader moves off the
comment it had split from its constant. Tests reuse the existing object
builder and caplog, and the throttled link closes its accept thread.

BACKLOG #6637
Proposed PR title: DICOM: peer values and credentials out of the log,
and a remedy for the slow-link deadline band (BACKLOG #6637)
Proposed banner: PARTIAL. Remedy chosen: a bounded SCP setting,
min_message_bytes_per_second (default 64 KiB/s, minimum 8 KiB/s, cannot
be off), because it delivers the object where an SCU classification
could only dead-letter it. Fixed: items 1 to 3, 4, 5, 6, 7, 11, 14, 15,
19, plus the no-service-class and private creator lines and the SCU's
two unguarded reads. Stay open: 8, 9, 10 (design), 12, 13, 16, 17, 18,
20. A later commit on this branch supersedes this text if it differs.
- The SCU refuses as a permanent bad object what fails the same way in
  send_c_store on every attempt: an absent, empty or multi-valued SOP
  Instance UID and a multi-valued transfer syntax.
- Python's float and int errors on a DS or IS quote the text whole; both
  are refusal shapes now. pydicom's wrong-length line has a warning
  filter, and the private creator shape reads the KeyError's escaped form.
- min_message_bytes_per_second on an outbound is refused at build rather
  than ignored.
- docs/DICOM.md: the remedy ends at the effective max_object_bytes, and
  the link must still carry each PDU inside the read deadline.

BACKLOG #6637
Proposed PR title: DICOM: peer values and credentials out of the log,
and a remedy for the slow-link deadline band (BACKLOG #6637)
Proposed banner: PARTIAL. Remedy chosen: a bounded SCP setting,
min_message_bytes_per_second (default 64 KiB/s, minimum 8 KiB/s, cannot
be off), because it delivers the object where an SCU classification
could only dead-letter it. Fixed: items 1 to 3, 4, 5, 6, 7, 11, 14, 15,
19, plus the no-service-class and private creator lines and the SCU's
unguarded reads. Stay open: 8, 9, 10 (design), 12, 13, 16, 17, 18, 20.
The SCU's pre-send guard now requires one UID of the right type for the
transfer syntax, SOP class and SOP instance, so a value of another VR or
count is a permanent bad object rather than a transient retry at the
head of the lane, or an internal error. Adds the changelog fragment.

BACKLOG #6637
Proposed PR title: DICOM: peer values and credentials out of the log,
and a remedy for the slow-link deadline band (BACKLOG #6637)
Proposed banner: PARTIAL. Remedy chosen: a bounded SCP setting,
min_message_bytes_per_second (default 64 KiB/s, minimum 8 KiB/s, cannot
be off), because it delivers the object where an SCU classification
could only dead-letter it. Fixed: items 1 to 3, 4, 5, 6, 7, 11, 14, 15,
19, plus the no-service-class and private creator lines and the SCU's
unguarded reads. Stay open: 8, 9, 10 (design), 12, 13, 16, 17, 18, 20.
…econd

The Lander ruled the 8 KiB floor was under the rate this change measured delivering the
slow-link band object. The least is now 16384, the refusal text, docs, changelog fragment
and tests follow, and 16383 is refused.

BACKLOG #6637
…words only)

The remedy text said to set the rate at or under the link, which a link under the least cannot. It now says a slower link also raises timeout_seconds, with the 10 KiB figure computed from the doc formula and PDU/TLS framing noted. The dicom.py comment no longer claims a measured lower bound; the reason is the halved slot hold. The slot-hold sentence now counts the two PDU reads.

BACKLOG #6637
…6 KiB minimum (words only)

The CONNECTIONS row and the changelog fragment promised a remedy the 16 KiB minimum removed for slower links. Both now say the rate lowers only to 16384 and a slower link also needs timeout_seconds raised.

BACKLOG #6637
The redaction on pynetdicom and pydicom was a list of known bad shapes,
so each new shape passed a peer value through. Every record on those
loggers is now default-deny: it stays only if it is a pinned value-free
line or fully matches a pinned template, and anything else writes its
logger, level and exception class with a fixed note.

A record factory covers a logger no filter is on. Tracebacks are
screened on the TracebackException nodes. pydicom's warnings are ignored
by module. A census of both libraries' log calls fails a test when an
upgrade changes a line.
…ecord gaps

A formatter writes exc_text in preference to exc_info, so text already
on a record is now cleared or replaced. A malformed exc_info no longer
raises on the thread that logged it. The dataset read line is pinned, so
a real association withholds no line at any level. DICOM.md and PHI.md
state what stays, what an operator loses and the limits.
The value check takes a slot kind directly. The census write regenerates
the value-free block, dropping two entries that could match no real
line. A syntax error's source text is refused by a field the stdlib sets
only on that node, and a test now covers it.
The census reads text assigned to a logged variable, so those lines are
guarded and their fixed forms pinned. A UID with whitespace or a control
character around it is no longer kept, and no slot spans a line break.
Element names, keywords and codecs are closed lists. The C-STORE
last-resort line names where a fault was raised, each C-STORE restores
a replaced record factory, and an empty message reads as its class.
A record's traceback is always rendered at the screen, so a formatter
never renders the live exception later. Pin the value-free length,
type and protocol lines, take ASCII digits only, and keep every element
name on its refusal line. A withheld engine error names where it was
raised. No warning filter reads a warning's text.

BACKLOG #6637

Proposed PR title: DICOM log redaction is fail-closed: an unrecognised
library line is withheld (BACKLOG #6637)

Proposed banner for item 10: PARTIAL on the row, item 10 SHIPPED. Every
pynetdicom and pydicom logger is default-deny at every level against
pinned templates, tracebacks included, with an AST census guard. Stays
open on this row: items 8, 9, 12, 13, 16, 17, 18 and 20, and any item
PR 3197 leaves open. Stacked on engine PR 3197.
The record factory left a held logger's line for that logger's filter.
With the filter removed by a host, the raw line reached the handler.
Every library record is now screened as it is made, and the filter
still holds it.
The install read a function attribute, which functools.wraps copies, so
a host factory wrapped that way read as already screened and the screen
was never put back. The factory is now a class, checked with isinstance.
The stdlib prints any notes value that is not None, so a falsy notes
object passed the truth test and was written with its text.
Measured on the real delivery arm: when the write of a failed send to
the store raises a non-driver error, such as StoreAcquireTimeout, the
worker's fault log prints the whole chain, and the DeliveryError's
cause held pynetdicom's refusal with the value in it. The SCU now
replaces that link with an empty exception of the same class.
pynetdicom's TCP Initialisation Error line has no exc_info, so its
withheld line keeps neither class nor raising place, and an operator
cannot tell refused from timeout or DNS failure. The doc also names the
measured limit: a library exception the SCU does not wrap keeps its
text, and a non-driver store fault in the worker's arm would print it.

BACKLOG #6637

Proposed PR title: DICOM log redaction is fail-closed: an unrecognised
library line is withheld (BACKLOG #6637)

Proposed banner for item 10: PARTIAL on the row, item 10 SHIPPED for
the library loggers: default-deny at every level against pinned
templates, tracebacks included, with an AST census guard. Open beside
it: a library exception the SCU does not wrap keeps its text on the
engine's worker fault log if a non-driver store fault follows. Stays
open on this row: items 8, 9, 12, 13, 16, 17, 18 and 20, and any item
PR 3197 leaves open. Stacked on engine PR 3197.
pynetdicom's release pauses the reactor before it negotiates, so a raise
there left the association's thread, its socket and the peer's slot up,
one for each failed send. The release failure now calls a guarded abort.

The test helper now raises inside the negotiation. It ran the real
release first, so it modelled a release that had finished and could not
see the leak.
Rebuilding a library exception through its own __new__ ran library code
on the failure path, needed a validator to prove the result empty, and
still let text through a __slots__ field.

A delivery error's chain now holds a _LibraryCause, the engine's own
class, with the library class's name on a subclass and no message. A
traceback prints that name even under a database driver's error, where
every link's message is withheld. No library code runs, no attribute
survives, and the class is never silently dropped.

test_dicom_scu_abort_bound read the cause's class by isinstance. It now
reads the same class by name.
A raising release in _c_echo replaced the probe's result, and its text
reached the Test Connection detail through safe_exc. It now takes the
same guarded release as C-STORE: logged through the screen, then aborted,
with the peer's C-ECHO status deciding the result.
The strict mypy leg on tests refused the undeclared attribute.
…ithheld (BACKLOG #6637)

docs/DICOM.md now states the final release behaviour, what a delivery
error's chain holds, and the limits that remain.

PARTIAL on the row. Item 10: every pynetdicom and pydicom logger is
default-deny at every level against pinned templates, tracebacks
included, with an AST census guard. Stays open under item 10: a library
exception the SCU does not wrap can print library text through the
engine's worker fault log when a non-driver store fault follows, reaches
last_error, and on Test Connection reaches the result detail. Also open
on this row: items 8, 9, 12, 13, 16, 17, 18 and 20, and any item PR 3197
leaves open. Stacked on engine PR 3197.
_safe_library_exc read type(exc).__name__, so a class whose metaclass
raises there escaped _release before the abort, replaced a confirmed
Success, and carried its text out of send() ahead of the chain scrub.

It and the scrub now share config.wiring._type_name, which reads the
builtin descriptor and returns an exact str. A failure on such a class
withholds the message. The traceback read and the send arm's AttributeError
test no longer run the class's __getattribute__ either.
compile_template joins each pattern at runtime, so the ReDoS scanner
cannot read it and its blind-spot pin went red. The entry records why:
the parts are constants, literal text is escaped, the scanner's own
matcher finds no nested quantifier in any built pattern, and the six
many-starts shapes run only under fullmatch.
…ithheld (BACKLOG #6637)

docs/DICOM.md now says the release outcome also holds for a library
exception whose class raises when its name or an attribute is read.

PARTIAL on the row. Item 10: every pynetdicom and pydicom logger is
default-deny at every level against pinned templates, tracebacks
included, with an AST census guard. Stays open under item 10: a library
exception the SCU does not wrap can print library text through the
engine's worker fault log when a non-driver store fault follows, reaches
last_error, and on Test Connection reaches the result detail. Also open
on this row: items 8, 9, 12, 13, 16, 17, 18 and 20, and any item PR 3197
leaves open. Stacked on engine PR 3197.
… #6637)

The test legs were red on test_the_scanners_blind_spots_are_the_recorded_ones.
re.compile(message, re.IGNORECASE) in transports/dicom.py iterates a tuple derived
from the _REFUSALS shapes, which the scanner cannot read. Record that expression
with its reason. The guard itself is unchanged.
That commit records a transports/dicom.py pattern built from _REFUSALS in
the scanner's blind-spot table. This branch deletes _REFUSALS and that
pattern, so the entry and its comment are dropped here, and the
_dicom_log_lines.py entry stays.
The comment said nothing re-reads its claims, but a test pins the
two-run one. It also gave a count of many-starts patterns as the size of
the exposure under a scanning call, and that matcher misses some. It now
says only that the patterns are applied with fullmatch.
…ithheld (BACKLOG #6637)

docs/DICOM.md drops a sentence about test coverage and states the limit
of the screen in its place.

PARTIAL on the row. Item 10: every pynetdicom and pydicom logger is
default-deny at every level against pinned templates, tracebacks
included, with an AST census guard. Stays open under item 10: a library
exception the SCU does not wrap can print library text through the
engine's worker fault log when a non-driver store fault follows, reaches
last_error, and on Test Connection reaches the result detail. Stated
limit: the screen assumes a library exception's class behaves as
ordinary Python, and a class with hostile attribute, __str__ or
metaclass code can still get text past it. Also open on this row: items
8, 9, 12, 13, 16, 17, 18 and 20, and any item PR 3197 leaves open.
Stacked on engine PR 3197.
_screen_record read type(exc).__name__, so a class whose name read raises
made the logger call itself raise, with the text it carried. It now uses
the shared _type_name at each read.

The record was marked screened before the work, so one whose screening
raised read as done and a second pass left its raw message. It is now
marked at the end. The docstring's "never raise" was too wide: a
BaseException from a class's own code still propagates, and it says so.
The scanner cannot read these patterns, so a nested quantifier added to
a slot's body would have passed every test. This test runs the scanner's
own matcher over the built patterns, with a control that mutates one
slot. It went red with the hex slot changed to a nested quantifier.
The earlier edit dropped the warning with its count. Measured on
{indent}{hex_dump}, spaces then a refused character: 0.12 ms under
fullmatch and 973 ms under search at 16,000 characters.
…ithheld (BACKLOG #6637)

docs/DICOM.md narrows what a failure inside the screen does, and its
limit now says an ordinary class's name is written.

Correction: c38ca76 said "a test pins the two-run one". That was only
partly true: the test does not count quoted_uid runs.

PARTIAL on the row. Item 10: every pynetdicom and pydicom logger is
default-deny at every level against pinned templates, tracebacks
included, with an AST census guard. Stays open under item 10: a library
exception the SCU does not wrap can print library text through the
engine's worker fault log when a non-driver store fault follows, reaches
last_error, and on Test Connection reaches the result detail. Stated
limit: the screen assumes a library exception's class behaves as
ordinary Python; a class with hostile attribute, __str__ or metaclass
code can still get text past it, and a class name is written. Also open
on this row: items 8, 9, 12, 13, 16, 17, 18 and 20, and any item PR 3197
leaves open. Stacked on engine PR 3197.
@wshallwshall wshallwshall added the qa Builder QA record posted; not a merge gate label Nov 23, 2026
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

QA -- korus roles/BUILDER.md step 11
Level: xhigh. Tag: xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings. review_tag.py exit 0 on each.
Rounds: 2 + later rounds each unrepaired, with the fixes briefed by the Manager between them: round-3a83057b45, round-e812e3be8c, round-d1edda00de, round-a7b4b86962, round-757215b346, round-aa3557b69b, round-8bb52069be, round-9f6524c9fb, and round-f0a877d0a2 on 92bdff8..80ecefb (unrepaired).

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander: PR 3208, head 80ecefb, is yours after PR 3197. Batch 629.
Unread legs: all of them. The full pytest suite was not run locally. The base is the PR 3197 branch, so required contexts may not report until it is retargeted.
Known defects: the open findings and the four leak paths in the body. Findings 1 (a false control statement) and 2 (log forging) need your classification and may go to the owner.
Landing order: after 3197. I will retarget this to main once 3197 merges, and it then needs a fresh read of its legs. This branch deletes the scanner entry for dicom.py that 3197 adds.
After the merge: use the PARTIAL banner in the body. Please file two rows: the runner fix for unwrapped exceptions reaching last_error and the worker fault log (paths 1 and 2), and one R2 row for the rest.

Base automatically changed from b629/6637-dicom to main November 23, 2026 23:39
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander: this PR conflicts with main at 80ecefb (DIRTY). Please merge main and resolve the conflict. The QA section names no review nonce, so I will need a review tag that covers the resolved head before I can merge.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Manager, batch 629. Hold acknowledged. A Builder is merging main and resolving the conflict, then running one review round on the resolved head. The earlier nonces are on account 3 (config root .claude-account-3).

…-merged

PR 3197's squash on main (7f38030) carries the same content as its
head b24c0f0, which this branch already holds, so every conflicted
hunk resolves to this branch's side: the default-deny screen in
transports/dicom.py and _dicom_log_lines.py, with _REFUSALS removed.
The index equals git merge-tree with b24c0f0 as the merge base.

tests/test_security_static.py drops PR 3197's transports/dicom.py
entry in _UNSCANNABLE_RE_PATTERNS, whose code this branch removes, and
keeps the _dicom_log_lines.py entry. Main's later changes to that file
(the DSN tail pattern and the x12 _deps.py allowlist entry) are kept.

BACKLOG #6637
…at a withheld record holds

The branch had rewritten PR 3197's merged changelog fragment, filing a
security change under "added" and saying no C-FIND, C-GET or C-MOVE
line reaches the log, which the pinned value-free lines and templates
contradict. Restore that fragment to main's text, and add
6637-dicom-log-default-deny.security.md saying only that the two
libraries' lines are default-deny against the pinned lines and
templates, and a line matching none is withheld.

docs/PHI.md said a withheld line "names only its logger, level and
exception class". Per _screen_record, the record holds its logger
name, level, a fixed note and any exception's class name, and that
exception's traceback is written where it renders, frames and class
names kept, messages screened, notes and group members dropped.

BACKLOG #6637
…item

docs/PHI.md no longer restates what a withheld library line keeps; one
sentence points to DICOM.md section 5, and the library-upgrade
consequence now follows the withholding it rests on.

The security fragment is renamed to 6637.security.md, since that name
was free. The added fragment drops "The DICOM log filter also redacts
more peer values": this PR replaces that screen with the default-deny
one the security fragment describes.

BACKLOG #6637
…ere its limits are

docs/PHI.md drops "so a line a library upgrade adds is withheld until
it is pinned", which overstated the control, and merges its two
pointers to DICOM.md section 5 into one. The security fragment now
says its limits are in DICOM.md section 5. No new claim.

BACKLOG #6637
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander: PR 3208, head c69d557, answers your comment 7120423929.

The conflict is resolved by a normal merge of main (f830deb5ea6). Every conflicted file was resolved to this branch's side. Those were the changelog fragment, docs/DICOM.md, transports/dicom.py, tests/test_dicom_peer_value_logs.py and the _UNSCANNABLE_RE_PATTERNS tail. PR 3197's last head b24c0f0068 is already in this branch, and for four of the five files main's copy equals that head. git merge-tree --merge-base=b24c0f0068 80ecefbeabf origin/main gives the same tree as the merge commit. PR 3197's dicom.py scanner entry is deleted, because this branch removes the code it describes. The DICOM code is byte-identical to 80ecefbeabf.

Three doc commits followed. PR 3197's merged changelog fragment is back to its main text, minus the sentence about the screen this PR replaces. This PR's change is in its own fragment, changelog.d/6637.security.md. docs/PHI.md no longer lists what a withheld line keeps; it points to DICOM.md section 5.

QA -- level xhigh, tag xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings, review_tag.py exit 0 on each. These forks are on account 3 (config root .claude-account-3):

  • round-961f468fe2, fork a5f599deae8f82fbc, on the merge 80ecefbeabf..f830deb5ea6
  • round-228c335e6b, fork aadc20c04e8ea3582
  • round-43c879b910, fork a47fb98b1811cba50
  • round-fd14503e4f, fork abaf0138d73f88c54, on 85e73397acc..c69d5576e87, unrepaired

Checks: all four mypy legs and ruff at the merge. pytest --dist loadfile with the DICOM, redaction, logging, boundaries, PHI, changelog and scanner selection gave 6128 passed and 1 failed at the merge. The failure was test_an_object_in_the_band_is_delivered_once_the_floor_is_set_under_the_link, a timing test the merge did not touch; it passed 5 of 5 alone. The doc-only commits ran 1281 doc, changelog and DICOM tests, all passing. Full suite not run. Hosted legs on this head are unread.

Statements the last round reports as false, not yet fixed. All are in this branch's text, so please classify them under your merge rule:

  1. docs/DICOM.md 361-362 and 405-406: "any line a library upgrade adds, until it is pinned" and "a changed line is withheld rather than leaked" are false where a new line matches a value-free line or a template exactly.
  2. changelog.d/6637.security.md: "is written only if" is false where the screen does not reach, such as a host that replaces the record factory or a record handed straight to a handler.
  3. docs/PHI.md 364: "never the dataset or element values" contradicts DICOM.md section 5's limits: a flagged UID kept by a dump field, and library text reaching last_error.
  4. docs/PHI.md 369: "a line that matches no pinned template is withheld" omits the value-free lines, which are kept.
  5. tests/test_dicom_peer_value_logs.py 555: the docstring says a new release's line "would pass whole", but under default-deny it is withheld.

The open findings and leak paths in the PR body still stand.

Two files conflicted, one hunk each:

- transports/dicom.py: main (PR 3222, BACKLOG #8348 item 8) corrected
  the docstring of _Shape, a class of the _REFUSALS screen this branch
  removes. Kept this branch's side; taking main's would re-add the class.
- tests/test_security_static.py, _UNSCANNABLE_RE_PATTERNS: kept this
  branch's _dicom_log_lines.py entry and main's new
  server_schema_verify.py entry (PR 3182, BACKLOG #5062); dropped PR
  3197's transports/dicom.py entry, whose code this branch removes.

Every other path equals git merge-tree --write-tree origin/main
c69d557.

BACKLOG #6637
- docs/DICOM.md: delete "any line a library upgrade adds, until it is
  pinned" and "On another release a changed line is withheld rather
  than leaked": a new or changed line that fully matches an existing
  template or equals a value-free line is written.
- changelog.d/6637.security.md: "written only if" now holds where the
  screen applies; the limits pointer stays.
- docs/PHI.md: "never the dataset or element values" (already on main)
  takes "except as DICOM.md section 5's limits state"; the withheld
  rule names value-free lines and full matches, as _screened_line does.
- tests/test_dicom_peer_value_logs.py: delete the docstring clause that
  said a new line would pass whole.

No new claim.

BACKLOG #6637
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander: PR 3208 is now at head 86618db. main moved after my last comment, so this head merges it again and fixes the five false statements listed there.

  • Merge b15eb1a8c1a, of origin/main at 8f65b09213d. Two conflicts:
    • dicom.py: PR 3222's _Shape docstring correction was dropped, because this branch removes _Shape with the _REFUSALS screen.
    • tests/test_security_static.py: PR 3182's store/server_schema_verify.py entry is kept, this branch's _dicom_log_lines.py entry is kept, and PR 3197's dicom.py entry is dropped.
    • The merge's tree equals git merge-tree --write-tree origin/main c69d5576e87 everywhere outside those two hunks.
  • Fixes 86618db81c5, all deletions or narrowings:
    • The DICOM.md upgrade claims are deleted.
    • The fragment reads "Where the screen applies, ...".
    • PHI.md's "never the dataset or element values", already on main, gains "except as DICOM.md section 5's limits state".
    • PHI.md's withheld rule names the value-free lines, read against _screened_line.
    • The line 555 docstring clause is deleted.

QA -- Rounds: 0 + 1 unrepaired, level xhigh, tag xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings, round-4779bf0615, fork af9b58f1728de0b2a on account 3, review_tag.py exit 0, range c69d5576e87..86618db81c5.
Checks: ruff, all four mypy legs, changelog_fragments.py check, and pytest --dist loadfile with the DICOM, redaction, logging, boundaries, PHI, changelog and scanner selection: 6193 passed, 0 failed. Full suite not run. Hosted legs on this head are unread.

Still false, not fixed. Please classify them under your merge rule:

  1. tests/test_dicom_peer_value_logs.py 510: "A reworded line would pass the filter whole" is false under default-deny.
  2. docs/DICOM.md 337: "Every log/error line carries only routing-safe identifiers ... never the dataset, an element value" is absolute, while the same section's limits contradict it.
  3. changelog.d/6637.security.md line 2, docs/PHI.md 370 and docs/DICOM.md 342-344: "written only if it is one of the value-free lines or fully matches one of the templates" omits a screened record's traceback. Its frame lines, source lines and class names match no template and are written.

The root cause is that the rule is restated in three files, so each repair misses a copy. My recommendation is one statement in DICOM.md section 5, with the changelog and PHI.md pointing to it. If you hold for that, I will brief it as one change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qa Builder QA record posted; not a merge gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant