Repository navigation
Block every refusal §6.4 names in the adapters - #616
bar-capsule wants to merge 4 commits into
Conversation
drk-ram
left a comment
There was a problem hiding this comment.
Reviewed _exchange.py, _handshake.py, _outcome.py, _error.py, and the updated adapter test suites (132abe8d):
- Unified §6.4 refusal boundary in
acs.client(http_decision_failure,MalformedResponseError,round_trip): Treating only HTTP408and500..599(with no JSON-RPC body) and signed-32603asUndecideddecision failures, while classifying every other non-2xx HTTP status (429,404, redirects included—even if headers arrived before the deadline viaaborter.status), any signed error other than-32603, any unsigned error, and anyAcsResultthat failsresponse-envelope.json(including a malformedallow) asRefusedcloses the remaining fail-open paths underACS_DEFAULT_DENY=0. - Truncated body & schema validation (
_read,_validator): RaisingConnectionErroronhttp.client.IncompleteReador positive remainingresp.lengthand validatingServerHelloagainsthandshake.json#/$defs/ServerHellokeep the handshake and step gates consistent.
artmaro
left a comment
There was a problem hiding this comment.
@bar-capsule Looks good, thanks. I checked it against §6.4 from #603 and ran the adapter tests locally.
|
@bar-capsule a real-host check of this PR at One question from the runs: which class should a mismatched id get? D-029 says |
|
Thanks for the runs. D-029 is the intent: a mismatched id or result.request_id is signature_invalid, since a verified response bound to another request is a replayed or spliced answer. The signature_invalid definitions in otel-mapping.json and trace/events.md predate #603 (#275) and say otherwise, so they need fixing together with failure_class(). I noted it on #308, where D-029 was decided. |
|
I moved this PR's base to Moving the base dismissed Evgeniy's approval, though the rebase would have dismissed it anyway. |
rocklambros
left a comment
There was a problem hiding this comment.
Restoring the approval that moving this PR to release/0.2 dismissed. The commit is the one Evgeniy approved, 132abe8. I didn't re-review the code or run it, because it still conflicts with release/0.2. The rebase will dismiss this approval too, so it needs a fresh review after that.
Only an HTTP 408 or 5xx with no JSON-RPC body and a signed -32603 follow the posture. Any other non-2xx status, every other signed error, and an answer that cannot be parsed or fails response-envelope.json, an allow included, block the step and refuse the handshake. The ML-DSA keyring path follows the same rule. Signed-off-by: Bar Kaduri <bar@capsule.security>
A signed step result offered as a ServerHello, on the HMAC and the key document path, and an id with neither result nor error now refuse the session. The gateway's 429 cause is http_429_refusal; it still denies. Signed-off-by: Bar Kaduri <bar@capsule.security>
132abe8 to
5c97225
Compare
|
Rebased onto Ran locally: conformance for Claude Code, Cursor and NAT (with the nat and pqc extras), guardian, interop and the gateway suite, all passing. @artmaro the base move dismissed your approval, could you take another look? @rocklambros same for you, the code under your approval changed. @Noctis-dev1 this is the rebase you were waiting for. |
|
@bar-capsule re-ran the item-6 real-host check against the rebased head (
So the refusals survived the rebase onto #600 and #618. One unchanged item from the 20 Nov run, for the record: |
|
@Noctis-dev1 thanks for re-running it on the rebased head, that's the check this rebase needed. @artmaro @rocklambros the real-host results match the 20 Nov run, so #616 is ready for another look. |
|
This needs a fresh review at the current head, since the earlier approvals were dismissed when the PR moved to release/0.2. Noctis's real-host runs match the 20 Nov campaign, so please re-approve or request changes at the current head. |
|
Approvals were dismissed on the move to release/0.2, and the head I think is now e5d92e0. I think it could use a fresh review at that head. Don't forget to include the Noctis real-host results in the review request. |
|
@DanPazlev @bar-capsule — looking at the CI failure on
The Codex adapter is actually enforcing the 0.2 refusal behavior ( |
What changed
The adapters now end a step the three ways #603 sets in §6.4:
408or5xxwith no JSON-RPC body, or a signed-32603.429,404and redirects included (was400and413with no JSON-RPC body, while a signedallowunder any status was honored);-32603, a code added later or one that isn't an integer included (was six listed codes);response-envelope.jsonanywhere in the envelope, anallowand a signed-32603included (these followed the posture, and only the result was checked).The handshake applies the same split. These answers refuse the session whatever
ACS_STARTUP_POSTUREsays, and so does a signed ServerHello that failshandshake.jsonor doesn't answer the ClientHello (it counted as no answer, and only some fields were checked).Three changes keep the split exact:
Docs: the README's degraded-Guardian section, SECURITY.md T5, the three mapping pages, and the env-table and troubleshooting rows. The NAT README's audit samples now show
guardian_refusal_fail_closed, which the adapter already emitted for those codes.Which issue does this implement
Refs #32
Refs #603
Merge timing: like the spec change it implements, this belongs to 0.2, so it shouldn't merge before 0.1.5 is cut. I'll retarget it to the 0.2 branch once that exists.
Base branch
integration, because this touches the specification, schemas, a referenceimplementation, an adapter, tests, or CI
main, because every changed path is on the documentation lane allowlist inCONTRIBUTING.md
Type of change
Breaking for deployments? Yes, for a deployment that opted into
proceed. A Guardian behind a rate limiter that answers429, a wrong URL path that answers404, or a Guardian that answers a malformedallownow blocks the step instead of letting it through. The auditcausenames the status (http_429_refusal), and the troubleshooting rows say so.I tested this
uv run pytest -vpasses on my machineuv run mkdocs build --strictpasses on my machineEach rule has a test in
tests/client/test_exchange.py,tests/client/test_session.pyandtests/core/test_errors.py. NAT'stest_untrusted_answers.pychecks that the protected function never ran. The 133 new assertions all fail onintegration. Two existing NAT controls had been answering with anallowthat failsresponse-envelope.json, so they now send a conformant one.lint-imports: 2 contracts kept. The wheel check passes.pytest: 1237 passed, 1 skipped.Live run of the built wheel in Claude Code and NAT, through a recording proxy and a proxy that injects the answer to the tool call, with the agent opted into
proceed. The stalled-body cases skip the recording proxy, which buffers whole responses, and404,-32050, the stalled503and the Guardian that declaresdenyran in Claude Code only:503, a503whose body stalls past the deadline, and a signed-32603.429, a429carrying a signedallow,404, a signed-32601, a signed-32050, a malformedallow, anallowthat is also a ServerHello, a signed-32603with nomessage, JSON nested past the parser's depth, and a429whose body stalls past the deadline. The canary file stayed absent, and NAT's protected function ran 0 times.503from a Guardian that declaresdeny.The block text names the class and cause, for example
refused (http_429_refusal). The Guardian's error message appears only in the audit record. Cursor wasn't run live; it goes through the same client code.Checklist
git commit -s(required by the DCO)Security
Under
proceed, an attacker who could make the Guardian answer429,404, an unregistered error code or a malformedallowcould let the step through, and a signedallowunder a4xxwent through under either posture. Those answers now block it.