Skip to content

HTTP listener refuses intake_auth_health='allow' under mtls_subject and an unknown intake_auth (BACKLOG #6979) - #3549

Merged
wshallwshall merged 42 commits into
mainfrom
b20054-6979c
Dec 2, 2026
Merged

wshallwshall merged 42 commits into
mainfrom
b20054-6979c

Conversation

@wshallwshall

Copy link
Copy Markdown
Collaborator

Ledger row: BACKLOG #6979. Source branch b20054-6979c, head 8f7ca3b. Stacked on PR 3548 (b20054-6978b); merge after PR 3548.

What changed.

  • The mTLS-health commits from the original #6979 branch, cherry-picked onto the #6978 repair.
  • HttpSource.__init__ refuses an intake_auth value outside the allowed set. An unknown mode used to build a listener that served every peer with no authentication.
  • The listener, Http() (_validate_intake_auth) and the wiring gate's _allowlist_weighed all require intake_auth to be a plain str in the mode set. A (str, Enum) member used to pass the guard and be stored as its str(), then served with no authentication. False, 0, an explicit None and "" are refused too.
  • Refusals withhold the value. Docs: the CONNECTIONS.md intake_auth row and a changelog fragment.

Merge danger. Changes a security control: a fail-closed tightening of HTTP intake authentication. Values that built before are now refused at build time, and each refusal names its remedy.

Checks. ruff and the four mypy legs are clean. pytest on tests/test_inbound_http*.py, wiring_serve, allowlist_restricts, dependency_boundaries, dicom_scp_security and security_doc_rate_limits: 1047 passed. The doc-reading tests: 6468 passed. The new tests fail on the base head ("DID NOT RAISE"). Legs to read: every required context.

Proposed vault banner: in the head commit's message.

…G #5660)

A gzipped POST body is handled exactly as sent. A binary inbound commits the
compressed bytes and answers 202; hl7v2, json, xml and text refuse them 422
with one ERROR row, single-byte text included, because a gzip header carries
NUL bytes. The row as filed expected 202 for single-byte text; measured, it
is 422. No behaviour change.

Verified-by: tests
…LOG #5660)

The HTTP listener section of docs/CONNECTIONS.md now states that a compressed
body is read as sent, and what each content_type does with it: a binary
inbound commits it and answers 202, at least hl7v2, json, xml and text refuse
it 422 with one ERROR row. Intended behaviour, per the row's verdict of record.

Proposed PR title: HTTP listener: record and pin that no Content-Encoding is decoded (BACKLOG #5660)
Proposed vault banner: CLOSED -- docs gap closed: docs/CONNECTIONS.md HTTP listener section records the per-content-type outcome of a gzipped body; tests/test_inbound_http_content_encoding.py pins it. Measured: single-byte text answers 422, not 202 as filed (gzip header NUL bytes).

Verified-by: none
…BACKLOG #5660)

Review round 1 repair. Each 422 arm now asserts its refusal reason (decode
error, or the NUL guard under latin-1) and first sends the same body plain to
the same inbound for a 202, so the refusal is the compression's. Adds fhir and
a dicom arm (422, no magic), sets latin-1 through Http(encoding=...), and
says "at least" in the module docstring.

Verified-by: tests
…660)

Review round 1 repair. The refusals come from decoding and the NUL guard, not
from a rule about compression: a NUL-free deflate body on a single-byte text
inbound is committed as its bytes. Says so, names encoding beside
content_type, adds fhir and dicom, drops the bare 202 that a reply_from inbound
does not give, and points a Handler at the bounded gzip_decompress.

Proposed PR title: HTTP listener: record and pin that no Content-Encoding is decoded (BACKLOG #5660)
Proposed vault banner: CLOSED -- docs gap closed: docs/CONNECTIONS.md HTTP listener section records that no Content-Encoding is decoded and what each content_type does with a gzipped body; tests/test_inbound_http_content_encoding.py pins it. Measured: single-byte text answers 422 for gzip (header NUL bytes), not 202 as filed; a NUL-free deflate body there is committed as its bytes.

Verified-by: none
… #5660)

Review round 2 repair. Adds the deflate body a latin-1 text inbound commits
as its bytes, so the docs' claim that the refusals are no rule about
compression is measured. Every refusal now checks the answer names the ERROR
row and that nothing refused reached the queue. Rows read in rowid order; one
listener takes both the plain control and the gzipped body.

Verified-by: tests
…KLOG #5660)

Says latin-1 rather than any single-byte charset, since cp1252 and ascii
refuse many gzip bodies as decode errors first. Drops "by design" for what the
record holds: intended under BACKLOG #5660, no ADR. Stops offering a binary
inbound as the workaround, because the inflated payload would meet no text or
HL7 ingress check, and links the bounded decompressors instead of restating
them.

Proposed PR title: HTTP listener: record and pin that no Content-Encoding is decoded (BACKLOG #5660)
Proposed vault banner: CLOSED -- docs gap closed: docs/CONNECTIONS.md HTTP listener section records that no Content-Encoding is decoded and what each content_type does with a compressed body; tests/test_inbound_http_content_encoding.py pins it. Measured: gzip on latin-1 text answers 422 (header NUL bytes), not 202 as filed; a NUL-free deflate body there answers 202 and is committed as its bytes.

Verified-by: none
…6476)

A client that holds its body back for the interim answer, as .NET and SOAP
stacks do by default, got neither 100 Continue nor a final status, and waited
until its own timeout or the listener's 408. The listener now sends 100
Continue from _read_body's new before_read hook: after header-mode auth, after
the max_body_bytes check, before the first body byte. So an unauthorised or
over-size request still gets its 401 or 413 and never a 100, and its client
never sends the body. HTTP/1.0, an empty body and any other expectation get no
100, as before; an Expect sent on two lines is read as one list.

New tests/test_inbound_http_expect_continue.py: the three positive arms failed
before the change (no interim answer within 2 s); the refusal arms pin that no
100 precedes a 401 or 413.

Verified-by: tests
The HTTP listener section of docs/CONNECTIONS.md says when the interim answer
is sent, that a refused request never gets one, and which requests get none.

Proposed PR title: HTTP listener: answer Expect: 100-continue only after authorisation (BACKLOG #6476)
Proposed vault banner: CLOSED -- the HTTP listener sends 100 Continue after head authentication and the max_body_bytes check, before the body read; unauthorised and over-size requests get their refusal and no 100. Tests in tests/test_inbound_http_expect_continue.py; documented in docs/CONNECTIONS.md. Unknown expectations stay ignored, not 417.

Verified-by: none
… as peer_reset (BACKLOG #6476)

Review round 1 repair. The interim answer is skipped once stop() has begun or
the writer is closing, so a body that arrived with the head still reaches the
BACKLOG #5715 shutdown handling rather than a drain error. A 100 Continue the
peer never reads is a ConnectionError, logged as peer_reset like a stalled
_respond, not the 408 for a slow request. The write goes through _respond.
The hook takes no length and is not called for an empty body; Expect lines go
to _expects_continue as a list. New arms: repeated credential header (400),
spent budget (429), and stop() begun between head and body.

Verified-by: tests
… #6476)

Review round 1 repair. Drops the claim that a refused client never sends its
body: a client waits only a short while, and one that sends anyway may see a
reset. Drops the .NET/SOAP default claim. Says a 100 is no promise to accept,
and that no 100 is sent once the listener stops.

Proposed PR title: HTTP listener: answer Expect: 100-continue only after authorisation (BACKLOG #6476)
Proposed vault banner: CLOSED -- the HTTP listener sends 100 Continue after head authentication and the max_body_bytes check, before the body read; unauthorised, over-size, repeated-credential and rate-limited requests get their refusal and no 100. Tests in tests/test_inbound_http_expect_continue.py; documented in docs/CONNECTIONS.md. Not built: the row's 417 for an unknown expectation, which stays ignored (RFC 9110 makes 417 a MAY).

Verified-by: none
…G #6476)

Review round 2 repair. An Expect sent on two lines, as a list, or with a
quoted comma is no longer merged into a 100 Continue: a front end may read
only one line, and would not anticipate the interim answer, the shape the
duplicate Host and credential refusals exist to prevent. Such a request is
read as before. The unreachable drain-timeout arm is gone (a 25-byte first
write never waits on drain), and the hook is passed only when the request
expects a 100. Tests: the closing-writer guard now has an arm that fails
without it; the stop() arm closes the writer as stop() does; a GET probe with
the expectation gets no 100.

Verified-by: tests
Review round 2 repair. Only a single Expect: 100-continue line is answered;
the list of requests that get none is now "at least", and names a closing
connection and a stop() begun between head and body as the triggers.

Proposed PR title: HTTP listener: answer Expect: 100-continue only after authorisation (BACKLOG #6476)
Proposed vault banner: CLOSED -- the HTTP listener sends 100 Continue for a single Expect: 100-continue line, after head authentication and the max_body_bytes check and before the body read; unauthorised, over-size, repeated-credential and rate-limited requests get their refusal and no 100. Tests in tests/test_inbound_http_expect_continue.py; documented in docs/CONNECTIONS.md. Not built: the row's 417 for an unknown expectation, which stays ignored (RFC 9110 makes 417 a MAY).

Verified-by: none
… #6476)

Found by the unrepaired review round on c665c07: the bare status-line literal
was a new site in tests/test_response_emitter_inventory.py's register (15
failures), and it made build_response's "every response carries the
baseline" claim false. _CONTINUE is now built from _status_line(100) and
_BASELINE_RESPONSE_HEADERS, as the harness sink's interim answer is, so no
new emitter site exists and the claim holds; the docstring says how. Also
cites RFC 9110 section 15.2 for the HTTP/1.0 1xx ban.

Verified-by: tests
Adjudicated: the claim holds. max_body_bytes bounds one body and
max_connections the connections, so the bodies one listener held at once were
bounded only by their product, 4 GiB at the defaults. Measured on the base:
three concurrent requests each declaring max_body_bytes were all read, none
refused.

New setting max_inflight_body_bytes, default 256 MiB, None/0 = off, also on
the Http() factory. Each body takes its declared length from the budget after
authentication and the max_body_bytes check, before a byte is read and before
any 100 Continue; one that does not fit is refused 503 with Retry-After (an
at_capacity event naming the setting), one larger than the whole budget 413.
The share is given back once the body is handed to the engine, or when the
request ends any other way. A max_body_bytes above the budget is refused at
construction, naming both settings and withholding both values.

tests/test_inbound_http_body_budget.py: the 503 arm failed on the base (the
second request got no answer); also the 413 arm, the no-100 arm, release on a
short body, off, the default and the construction refusal.

Verified-by: tests
A settings-table row in the HTTP listener section of docs/CONNECTIONS.md:
what the budget bounds, when a body takes and gives back its share, the 503
with Retry-After and the 413, the construction refusal, and how to switch it
off. The pre-ingress refusal list names the 503.

Proposed PR title: HTTP listener: bound the body bytes in flight across the listener (BACKLOG #6978)
Proposed vault banner: CLOSED -- adjudicated real (three concurrent max-size bodies were all read on the base). New Http setting max_inflight_body_bytes, default 256 MiB: a body that does not fit is refused 503 with Retry-After before a byte is read, one over the whole budget 413; a max_body_bytes above it is refused at build. Tests in tests/test_inbound_http_body_budget.py; documented in docs/CONNECTIONS.md.

Verified-by: none
Review round 1 repair. Charging the declared Content-Length let sixteen
sockets that declared 16 MiB and sent nothing hold the whole default budget
and refuse every partner, a lockout sixteen times cheaper than
max_connections. The body is now read in 64 KiB chunks, each charged as it
arrives: a declared body that fits what received bodies hold is read, one that
does not is refused 503 before a byte is read, and bytes that would take the
listener over the budget are refused 503 mid-body. A budget refusal now
reaches the refusal observers, as every listener-cap refusal does. The 413
names max_inflight_body_bytes. The max_body_bytes-off warning names the
budget. The factory comment sits on the parameter's own line, so the IDE form
reads it as help, not as a section heading.

Tests: the mid-body arm, a declared-only body that holds no room, the
observer arm, an off arm that asserts the setting reads as off, and the
factory default tied to the listener's constant.

Verified-by: tests
Review round 1 repair, docs limb. The settings row says a body is charged as
its bytes arrive, so a declared-only body holds nothing, and that a body can
be refused 503 before or while it is read. Drops "from authenticated peers",
false at the default intake_auth = none. The max_body_bytes row no longer
says "unlimited" while the budget is on, and the pre-ingress 413 names the
budget too.

Proposed PR title: HTTP listener: bound the body bytes in flight across the listener (BACKLOG #6978)
Proposed vault banner: CLOSED -- adjudicated real (three concurrent max-size bodies were all read on the base). New Http setting max_inflight_body_bytes, default 256 MiB, charged on body bytes as they arrive: a body that does not fit is refused 503 with Retry-After before or while it is read, one over the whole budget 413; a max_body_bytes above it is refused at build. Tests in tests/test_inbound_http_body_budget.py; documented in docs/CONNECTIONS.md.

Verified-by: none
…ACKLOG #6978)

Review round 2 repair. Every body is now read in chunks into one growing
bytearray, charged per chunk where the budget is on, so a peer sending tiny
segments costs no per-segment object the charge misses, and the fuzz target
reads through the same loop. A refused or timed-out read gives its share back
before the event, audit and answer writes. A budget refusal is no longer told
to the admission refusal observers, whose alert names the allowlist and
connection caps as its cause. Switching the budget off logs a WARNING, as
max_body_bytes does. The Http() factory refuses a literal max_body_bytes above
a literal budget, so validate and the IDE agree with the listener, and both
refusals name the budget as the setting to raise.

Tests: share release on a 408 and on a handler fault, the warning, and the
factory refusal; the observer arm now pins that observers are not told.

Verified-by: tests
… #6978)

Review round 2 repair, docs limb. "Nothing is recorded" contradicted the
at_capacity event the same row names; no message row is what is meant. Says
where a body cap above the budget is refused, and that switching the budget
off logs a WARNING.

Proposed PR title: HTTP listener: bound the body bytes in flight across the listener (BACKLOG #6978)
Proposed vault banner: CLOSED -- adjudicated real (three concurrent max-size bodies were all read on the base). New Http setting max_inflight_body_bytes, default 256 MiB, charged on body bytes as they arrive: a body that does not fit is refused 503 with Retry-After before or while it is read, one over the whole budget 413; a max_body_bytes above it is refused by the factory or at build; off logs a WARNING. Tests in tests/test_inbound_http_body_budget.py; documented in docs/CONNECTIONS.md.

Verified-by: none
…e (BACKLOG #6978)

The request's share of max_inflight_body_bytes is given back as soon
as _serve_one catches a refusal, a receive_timeout or a failed body
read. The exception's traceback kept _read_exactly's frame alive
through the refusal's event and audit writes, and that frame still
held the partial body and its last chunk. So bytes the budget no
longer counted stayed resident, up to about twice the budget at once.

_read_exactly now clears its buffer and drops its last chunk on any
exception, cancellation included, before it propagates. The early
give-back stays where it is: moving it to a finally would hold the
share through a reply_from wait. The comment at the HttpRequestError
give-back no longer says the body was dropped; it says why the
give-back is safe there.

Three tests read _read_exactly's frame off the exception and fail
before this change: a body that stops short, a mid-body budget
refusal, and a cancellation by receive_timeout.

Proposed PR title: HTTP listener in-flight body budget (BACKLOG #6978)
Proposed vault banner: BUILT on b20054-6978b, a listener-wide
max_inflight_body_bytes charged on bytes received, with a refused body
read releasing its bytes before the share is given back. Awaiting PR.

Verified-by: tests
…KLOG #6978)

Repair round 1 after the code-review skill at xhigh.

The handler-fault arm gave the share back in its finally, then awaited
the handler_error event and the answer inside the except block, while
the exception's traceback kept the handler's frames, and the body they
were passed, alive. It now keeps only the reason and whether the fault
is temporary, and does its writes after the except block has let go of
the exception.

A body read that failed with an OSError, or any other exception but a
refusal or a receive_timeout, left _serve_one with its share still
charged, and _on_client wrote its peer_reset event before its own
give-back. A last except arm around the read now gives the share back
and re-raises.

_read_exactly lets go of its buffer in a finally rather than an except
BaseException, with no pre-binding. Its docstring names the writes the
refusal really holds, event and response, and says the stream's own
buffer is outside the budget.

New tests: a failed read leaves no bytes behind; a failed read gives
its share back before its event; a handler fault holds no body,
reached from the exception being handled, through its event. The last
two fail on the previous head.

Verified-by: tests
… (BACKLOG #6978)

The HTTP listener row in docs/CONNECTIONS.md said a body is charged as
its bytes arrive. Bytes a connection's stream has buffered but the
listener has not yet read are not charged; the stream's own buffer
limit bounds them per connection. The row now says so.

Proposed PR title: HTTP listener in-flight body budget (BACKLOG #6978)
Proposed vault banner: BUILT on b20054-6978b, a listener-wide
max_inflight_body_bytes charged on bytes received, with every early
exit from a request releasing its body before its event and answer
writes. Awaiting PR.

Verified-by: tests
…CKLOG #6978)

Repair round 2 after the code-review skill at xhigh.

Leaving the except block frees the handler's frames only when nothing
cycles back to them. At least aiosqlite raises with the failed future,
and so the error, a local of the frame that raised it, so a failed
ingress commit kept the body resident until the cyclic collector ran,
after its share was given back. The new _release_frames clears the
locals of the finished frames on the exception and its cause and
context chain, as the API client's _release_raising_frames does.

The read now has one inner except BaseException that clears the frames
and gives the share back, ahead of the 408, 4xx and _on_client arms,
in place of a give-back per arm. The handler call clears its frames on
any exception, a cancellation included, before its finally gives the
share back.

The _read_exactly docstring drops its closed list of exits and points
at docs/CONNECTIONS.md for the uncharged stream buffer.

Tests: a handler fault and a read refusal that each raise through a
reference cycle, with the cyclic collector off, hold no body through
their event; _release_frames frees a cycle through a cause chain. All
three fail on the previous head.

Verified-by: tests
…978)

Repair round 2. The max_inflight_body_bytes row said the stream's own
buffer limit bounds the uncharged bytes per connection, which reads as
64 KiB. asyncio pauses a stream only past twice its 64 KiB limit, and
one transport read can add 256 KiB on the selector event loop, more
under TLS. The row now says at least that much.

Proposed PR title: HTTP listener in-flight body budget (BACKLOG #6978)
Proposed vault banner: BUILT on b20054-6978b, a listener-wide
max_inflight_body_bytes charged on bytes received; an early exit from a
request clears the frames that held its body and gives its share back
before its event and answer writes. Awaiting PR.

Verified-by: tests
…BACKLOG #6979)

Adjudicated: the claim holds, as an exemption that exempts nothing. Under
mtls_subject the TLS handshake requires the client certificate and
_authorize_peer_cert checks its subject at accept, before a request byte is
read, so a GET/HEAD probe without a listed certificate was refused whatever
intake_auth_health said. Honouring "allow" would need an optional
certificate at the handshake for every request, which would weaken
client-certificate verification, so it is not done. The combination is now
refused instead: by the Http() factory, so check, validate and the
connections.toml desugar refuse it, and by HttpSource when built from a
Source any other way. Both name the two settings. "allow" under api_key and
bearer is unchanged.

tests/test_inbound_http_mtls_health.py: the two refusal arms failed on the
base; the header-mode arms and the accept-time check pass on both.

Verified-by: tests
…OG #6979)

The intake_auth_health row of the HTTP listener settings table says the
combination is refused at load and at build, and why it cannot be honoured.

Proposed PR title: HTTP listener: refuse intake_auth_health='allow' under mtls_subject (BACKLOG #6979)
Proposed vault banner: CLOSED -- adjudicated real: under mtls_subject the certificate is required at the handshake and checked at accept, before the method is read, so 'allow' exempted no probe. Not loosened: the combination is now refused by the Http() factory and by HttpSource at build, naming both settings. Tests in tests/test_inbound_http_mtls_health.py; documented in docs/CONNECTIONS.md.

Verified-by: none
…BACKLOG #6979)

Review round 1 repair. The listener's refusal now runs before the TLS context
is built, so a certificate or anchor fault cannot report or log first, and it
names the connection and the remedy. Its comment no longer rests on a
handshake a Source built without TLS does not have. The Http() docstring and
parameter help say the setting is refused under mtls_subject. The ordering
test is renamed for what it pins: the check's inputs, not its call site.

Verified-by: tests
…KLOG #6979)

Review round 1 repair, doc limb. The intake_auth_health row no longer says
the combination was "accepted and ignored" as if that were the alternative
still possible, and it states the cost an operator takes on instead: a
certificate listed so a probe passes is admitted for every method. The
doc-sweep test now pins that the row says the combination is refused.

Proposed PR title: HTTP listener: refuse intake_auth_health='allow' under mtls_subject (BACKLOG #6979)
Proposed vault banner: CLOSED -- adjudicated real: under mtls_subject the certificate is required at the handshake and checked at accept, before the method is read, so 'allow' exempted no probe. Not loosened: the combination is now refused by the Http() factory and by HttpSource at build, before the TLS build, naming both settings and the remedy. Tests in tests/test_inbound_http_mtls_health.py; documented in docs/CONNECTIONS.md.

Verified-by: tests
…(BACKLOG #6979)

Review round 2 repair. The factory's intake_auth_health='allow' refusal now
runs after the tls, tls_ca_file and subject checks, so a configuration
missing those hears the more basic fault first, and the refusal's stated
reason, a certificate checked at accept, is always true when it fires. The
parameter help names the value refused, not the whole setting. The premise
test now pins _authorize_peer_cert's parameters and that _on_client calls it
before _serve_one, so the refusal's premise has a control.

Verified-by: tests
…G #6979)

Review round 2 repair, doc limb. Adds changelog.d/6979.security.md, since a
configuration that loaded before now refuses, and names the remedy. The
doc-sweep test's older failure message described wording the row no longer
uses; it now says what the pinned phrase says.

Proposed PR title: HTTP listener: refuse intake_auth_health='allow' under mtls_subject (BACKLOG #6979)
Proposed vault banner: CLOSED -- adjudicated real: under mtls_subject the certificate is required at the handshake and checked at accept, before the method is read, so 'allow' exempted no probe. Not loosened: the combination is now refused by the Http() factory and by HttpSource at build, naming both settings and the remedy. Tests in tests/test_inbound_http_mtls_health.py; documented in docs/CONNECTIONS.md and changelog.d/6979.security.md.

Verified-by: tests
…CKLOG #6979)

Repair round 1 after the code-review skill at xhigh.

The listener's check read (intake_auth or "none"), so False or 0
passed as "none". Only unset and empty read as "none" now, and any
other value outside the four modes is refused.

The mode set was written out a second time in the listener. wiring.py
now names it once, as the public INTAKE_AUTH_MODES derived from
_INTAKE_KEY_MODES, and both the Http() factory and HttpSource read it;
the listener imports no private config name. The test adds False and 0
to the refused values.

Verified-by: tests
…OG #6979)

Repair round 1. The fragment said a typo would have opened the intake
socket to every peer. The listener checked no credential, but at least
source_ip_allowlist and the start-time peer-control gate still bounded
who could submit; it now says so, and that only unset and empty mean
none. The code commit before the guard's own message says the same
thing too strongly; this fragment is the record a reader sees.

Proposed PR title: HTTP listener refuses intake_auth_health='allow'
under mtls_subject and an unknown intake_auth (BACKLOG #6979)
Proposed vault banner: BUILT on b20054-6979b, stacked on
b20054-6978b: intake_auth_health='allow' under mtls_subject is refused
by Http() and by HttpSource, and HttpSource refuses an intake_auth mode
outside the one set the factory reads. Awaiting PR.

Verified-by: tests
…e list (BACKLOG #6979)

Repair round 2 after the code-review skill at xhigh.

The listener read an explicit None or empty intake_auth as "none",
which Http() refuses, so an env() resolving blank on a connection built
outside the factory still checked no credential. Only an absent key
reads as "none" now.

The listener read the accepted modes from wiring, so a mode added
there and not enforced by _authorize_head or _authorize_peer_cert would
have been accepted and served unauthenticated. It keeps its own list,
the modes it enforces, and a test pins that list equal to wiring's
INTAKE_AUTH_MODES. The factory's refusal now names its modes from that
constant rather than a second literal.

Tests: the refusal message is pinned whole, so no part of a value can
be in it; an explicit None or empty value is refused by both the
factory and the listener; an absent key still builds as none.

Verified-by: tests
…KLOG #6979)

Repair round 2. The intake_auth row in docs/CONNECTIONS.md now says an
empty value is refused too and that leaving the setting out means
none. The changelog bullet drops its claim about what else bounded the
old behaviour, which held only under enforce, and names which
connections were never affected: those written with Http() or in
connections.toml.

Proposed PR title: HTTP listener refuses intake_auth_health='allow'
under mtls_subject and an unknown intake_auth (BACKLOG #6979)
Proposed vault banner: BUILT on b20054-6979b, stacked on
b20054-6978b: intake_auth_health='allow' under mtls_subject is refused
by Http() and by HttpSource, and HttpSource refuses any intake_auth
outside the modes it enforces, an explicit empty value included.
Awaiting PR.

Verified-by: tests
…(BACKLOG #6979)

The mode check compared the raw value against the allowed set, but the
listener stored str(raw). A (str, Enum) member equal to "api_key" passed
the check, was stored as "Mode.API_KEY", and every authorisation check read
that unknown mode as no authentication. Http() accepted the same member.

Both now require type(value) is str as well as membership, so the value
checked is the value stored and enforced; the listener stores the checked
value unchanged. The refusal withholds the value, as before. Tests: a
(str, Enum) member, a StrEnum member and a str subclass are refused by both
the listener and the factory; the plain strings still build.

Verified-by: tests
…n the gate (BACKLOG #6979)

Review round 1 on the plain-str check. A str subclass equal to a mode is
refused with a message that names the cause and the remedy, passing the
string itself such as an enum member's .value, still withholding the value.
Other refusals keep their message.

The peer-control gate in wiring_runner read the mode through str(), so a
StrEnum member equal to "api_key" was judged on its own though Http() and
the listener refuse it. It now judges a mode alone only for a plain str,
as its docstring promises.

Tests: every mode, under each of a (str, Enum) member, a StrEnum member and
a str subclass, is refused by the listener and by Http() with the full
message pinned; the gate weighs the allow-list for each shape. The duplicate
plain-string test is dropped, as two existing tests build the plain strings.

Verified-by: tests
…m case (BACKLOG #6979)

The intake_auth row in docs/CONNECTIONS.md says an enum member or other
str subclass is refused even when it equals a mode, and to pass its
.value. The changelog no longer says Http()-written connections were
never affected: an enum member with a str base passed Http() and was then
served with no credential checked. It names the new refusal, that a
StrEnum member is refused though it was read correctly before, and the
remedy.

Proposed PR title: HTTP listener refuses intake_auth_health='allow'
under mtls_subject and an unknown intake_auth (BACKLOG #6979)
Proposed vault banner: BUILT on b20054-6979c, stacked on
b20054-6979b and b20054-6978b: intake_auth_health='allow' under
mtls_subject is refused by Http() and by HttpSource, and HttpSource and
Http() refuse any intake_auth outside the modes the listener enforces,
an explicit empty value and any value that is not a plain str included.
Awaiting PR.

Verified-by: none
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

QA (BACKLOG #6979):

  • b20054-6979b repair: forks a38459a7dde7cdd48 round-9a8b71bbad, ad727b5cc93d88860 round-a3164a78e1, ad6dcb627c703a6b0 round-5c911a8697. Level xhigh. Tag: "xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings". Rounds 2 + 1 unrepaired.
  • b20054-6979c type guard: forks a52b52da563207560 round-bef821d8, a22e441b8e2d6c13e round-1fc72553. Same tag. Rounds 1 + 1 unrepaired.

The head docs commit 8f7ca3b carries Verified-by: none. Its content got only the unrepaired round-2 review.

Lander handover. PR 3549, MEFORORG/MessageFoundry, head 8f7ca3b. Unread legs: every required context. Landing order: after 3546, then 3547, then 3548.

Known defects. None lets a request through without a credential.

  • Fail-closed:
    • The wiring gate runs before build_source. For a non-plain-str intake_auth off loopback with no allow-list, it gives the wrong remedy, "Set intake_auth", and under warn it logs a false "anyone can submit" warning first.
  • Prose (filed after merge under the owner's 2026-11-19 prose-only rule):
    • The changelog's second bullet lost its CONNECTIONS.md tail, which now trails the third bullet as an unwrapped line.
    • The changelog says any enum with a str base checked no credential. Only a (str, Enum) mixin did.
    • A test docstring says "no certificate was checked" under mtls_subject. Only the subject binding was skipped.
    • CONNECTIONS.md says to "pass its .value" for any str subclass.
    • The _PLAIN_STR_HINT comment is false for a str subclass that is not a mode.
    • SECURITY.md Table B understates when the gate denies (safe direction).
  • Code, later:
    • _has_effective_peer_control and _intake_auth_enabled still read str(x).
    • intake_auth is read five ways.
    • The hint is duplicated.
    • The gate test covers only the private helper.
  • From 6979b, behaviour-changing:
    • intake_auth_health='allow' under none loads silently.
    • Credentials set while intake_auth is absent are served unauthenticated on the listener path, which the factory refuses.
    • Per-request auth still fails open on an unknown mode, if one ever reached it. Root fix: deny-by-default dispatch.
  • New row owed: the same str()-of-enum class in intake_auth_health, intake_api_key_header and reply_on_timeout / reply_content_type / reply_on_empty. These fail closed or misbehave. None skips authentication.

@wshallwshall wshallwshall added the qa Builder QA record posted; not a merge gate label Dec 2, 2026
@wshallwshall wshallwshall changed the title HTTP listener refuses intake_auth_health='allow' HTTP listener refuses intake_auth_health='allow' under mtls_subject and an unknown intake_auth (BACKLOG #6979) Dec 2, 2026
@github-actions github-actions Bot added the ci-red A required check went red. Attribute it before retrying. label Dec 2, 2026
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Manager d6318533: the red legs here are not this PR's. dependency-and-secret-scan / npm-audit (ide glob advisory) is main-wide and clears when PR 3516 merges; docker image smoke (slim) is not required and fails on main's own run 46749188753 (trust-anchor preflight under enforce). Nothing to push.

Brings PR 3548 up to date with main. The branch was stacked on the
pre-squash #6476 commits, which main now carries as #3547 in a newer
form, so the conflicts are #6476 text against #6978 changes.

http_listener.py: keeps the #6978 changes (traceback import, the
before_read(length) and charge parameters, _ready(length) checking the
body budget before the 100 Continue and always passed); takes main's
newer #6476 wording for the _ready comment. The merged file differs from
the branch head only by main's #6476 comment and _respond docstring
edits.

tests/test_inbound_http_expect_continue.py: add/add of the #6476 test;
the branch never changed it after its #6476 base, so main's newer
version (the _ANY_100 guard) is taken whole.

The merge differs from main only in the four #6978 files.

Verified-by: tests
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Merged origin/b20054-6978b (19ffcba) into this branch: new head 5fcaced (fast-forward from 8f7ca3b). The merge had no conflicts and is not current with today's main. Retarget onto main once PR 3548 merges.

Checks: ruff, the four mypy legs, pytest 874 passed and 9 skipped (inbound_http, http_listener, security_doc_rate_limits).

QA (merge): Level xhigh. Tag: xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (fork a083781a954221861 round-5dfc2501). Rounds: 1, unrepaired. Each side's net diff landed verbatim.

Open findings in the #6979 content and the code around it:

  1. OWNER-ROUTE CANDIDATE (control): intake_auth_health has the same str-subclass split that #6979 fixed for intake_auth. An Enum ALLOW is stored as 'H.ALLOW' and the probe exemption silently does nothing; the reviewer reproduced it.
  2. OWNER-ROUTE CANDIDATE (behaviour): the same split hits reply_on_timeout, reply_on_empty and reply_content_type, so a 504 can become a 202 or a 204 a 200.
  3. The same split hits intake_api_key_header, giving every request a 401. This is visible, not a weakening.
  4. Opposite str-subclass rules for #6400 and #6979 in CONNECTIONS.md.
  5. wiring_runner._intake_auth_enabled reads the value a third way.
  6. The remedy "pass its .value" fails for a plain str subclass.
  7. Test docstrings say mtls_subject "needs a TLS context" (false), so that mode is never built.
  8. A leftover str() at wiring_runner ~17165.
  9. The hint text is duplicated.

Base automatically changed from b20054-6978b to main December 2, 2026 13:47
PR 3548, the #6978 content this branch was stacked on, squash-merged
into main. One conflict, in messagefoundry/transports/http_listener.py:
main dropped nothing there, and the #6979 side adds _INTAKE_AUTH_MODES
and _PLAIN_STR_HINT after _BODY_CHUNK_BYTES; kept the #6979 addition.
The diff against origin/main now equals the #6979 delta alone
(479c1e9..8f7ca3b), line for line.

Proposed PR title: HTTP listener refuses an unknown or non-plain-str
intake_auth, and intake_auth_health='allow' under mtls_subject
(BACKLOG #6979)

Verified-by: tests
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Manager d6318533: merged origin/main (89f5b5e, after PR 3548's squash). New head d46eeee, fast-forward. The only conflict was one http_listener.py hunk, where HEAD's #6979 additions were kept. git diff origin/main...HEAD equals the #6979 delta alone (479c1e9..8f7ca3b, 354 +/- lines identical, with a positive control); nothing from #6978 or #6476 remains. Checks: ruff, the four mypy legs, pytest 1065 passed and 20 skipped over 15 inbound_http, listener and wiring files. QA (merge): Level xhigh. Tag: xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (fork a38c52cf91bda288d round-dbce5c6f, review_tag.py exit 0). Rounds: 1. The review found the resolution correct. The open findings in #6979's own content stand as in my earlier comment. Added: the wiring_runner gate refuses a non-plain-str key mode with a misleading message before the listener names the remedy (error text only); intake_auth_health='allow' is refused under mtls_subject but loads silently under none; the second changelog bullet lacks its BACKLOG citation.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): merging with the open findings filed. Decision d20261202T145033077-f9bc92 (decided by lander under the Owner's instruction of 2026-11-28, empower added class 3: a fail-closed tightening). Your QA lines are the review proof for the content. A fresh-context reviewer I started ran one probe over the Http(...) factory and the listener build at this head and at main c9e7335 (auth modes, health values and reply settings as plain strings, plain Enum, (str, Enum), StrEnum and str subclasses). Every row that differs is the head refusing loudly what main loaded; three of those loaded on main with no credential check at all. No row shows the head loading what main refused or enforcing less.

The two OWNER-ROUTE CANDIDATE findings are measured identical on main, in lines this PR does not touch, so they are filed, not held on: (1) intake_auth_health given as a (str, Enum) member is stored as its str() and the probe exemption stays off (stricter than intended, not weaker); (2) reply_on_timeout / reply_on_empty / reply_content_type given as a (str, Enum) member fall through, so a configured 504 answers 202 and a 204 answers 200. The last merge commit d46eeee differs from the automatic merge of its parents only by the removed conflict markers in http_listener.py.

Queued for filing under R2 (one row, numbered items): the two above; intake_api_key_header as an Enum gives every request a 401; wiring_runner._intake_auth_enabled reads the value a third way and keeps a leftover str(); CONNECTIONS.md "so pass its .value" fails for a plain str subclass (say "pass the string itself (for an enum member, its .value)"); a test docstring says mtls_subject "needs a TLS context" (it builds without one); the #6400 and #6979 str-subclass statements read as opposite though they cover different settings; 'allow' loads silently under none; the gate's remedy text; the second changelog bullet lacks its BACKLOG citation; "no certificate was checked" overstates the old defect.

Pinned head for the merge: d46eeee. Undo: revert the squash commit.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): my enqueue above became a deferred auto-merge request, not a queue entry, because test (ubuntu-latest, py3.14) is red on d46eeee (run 46896899329, job 143515992963): tests/test_durability_hook_push_bound.py::test_the_TEARDOWN_ends_a_SUSPENDED_process_frozen_before_it_ran (could not arm). I disarmed it and read it back as null. That test is the known Linux census flake that PR 3581 fixes; this PR does not touch it. One rerun of the failed job; a second red on this leg is a finding. I enqueue when it is green.

@wshallwshall
wshallwshall added this pull request to the merge queue Dec 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 2, 2026
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): the queue removed this PR. Merge-group run 46915060274, repo harness tests (ubuntu-latest): tests/test_coord_alloc_retired_tombstone.py::test_the_tombstone_lifts_a_stale_allocator_above_every_real_number[4c68c28eb-blob] (AssertionError; the job log stopped being readable before I could read the assertion body, so I have not confirmed it is the PowerShell host crash that leg has been showing today). This PR changes the HTTP listener, wiring and docs, not the coordination scripts. One re-queue at pinned head d46eeee; a second eviction on this leg holds it until the leg is fixed.

@wshallwshall
wshallwshall added this pull request to the merge queue Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

CI failed in test (windows-2025, py3.14) while this pull request was in the merge queue, so the queue ejected it.

Its own head can still be green: the queue revalidates the merge, and the path gates that skip on a pull request run there. Read the run before retrying.

https://github.com/MEFORORG/MessageFoundry/actions/runs/46915060274

Merged via the queue into main with commit 5ba59a7 Dec 2, 2026
98 of 101 checks passed
@wshallwshall
wshallwshall deleted the b20054-6979c branch December 2, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-red A required check went red. Attribute it before retrying. qa Builder QA record posted; not a merge gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant