Repository navigation
fix(agt): treat an HTTP 4xx from the Guardian endpoint as a refusal - #544
Conversation
post() parsed the response body without reading the status, so a 401 or 403 from the Guardian endpoint, or from whatever authenticates in front of it, became a SyntaxError or an unrecognised JSON-RPC error. Both were left to on_decision_failure, and under proceed the step ran even though the adapter's credential had been rejected. post() now throws GuardianHttpRefusalError for any 4xx except 408 and 429, and classifyDeliveryFailure files it as refused, so the step is blocked whatever the posture. 408, 429 and 5xx still follow the posture, and a 5xx body is still read. Part of GenAI-Security-Project#32. Signed-off-by: Santosh Kumar Puppala <puppalas97@gmail.com>
|
Thanks for this. It is queued rather than ignored. A lead has not reviewed this pull request yet. A lead will read it when they have time, and we can't promise a date. Nothing here is rejected. If a check below fails, please fix it. A pull request that waits a long time may be closed, and you can reopen it later. |
drk-ram
left a comment
There was a problem hiding this comment.
Reviewed guardian-client.ts, failure-posture.ts, and the accompanying tests (d8824bc6):
- Pre-body HTTP 4xx refusal check (
isRefusalStatus/GuardianHttpRefusalError): Checkingres.status >= 400 && res.status < 500 && res.status !== 408 && res.status !== 429before reading or JSON-parsing the response body (and cancelingres.body) prevents an HTML/plain-text401/403from an authenticating proxy from throwing aSyntaxError(unknown->proceed). - Fail-closed classification (
classifyDeliveryFailure): MappingGuardianHttpRefusalErrortokind: "refused"blocks the step regardless ofon_decision_failureand attributes the refusal to"the guardian's endpoint"in the audit reasoning.
|
#603 §6.4 classes HTTP 429 as a refusal, but this PR leaves it as a decision failure ("408, 429 and 5xx still follow on_decision_failure"). Please move 429 to the refusal branch, or I'll note the mismatch on #603. Separately, GuardianHttpRefusalError puts res.statusText into the error message. That's server-controlled text that can reach logs. Drop it or sanitize it. The HTTP status is enough for the audit record. A test that asserts a 401 from an intermediary is blocked under proceed would lock in the fix the PR body describes. |
rocklambros
left a comment
There was a problem hiding this comment.
Thanks, Santosh. I'm approving this PR at c791150.
Every HTTP 4xx except 408 and 429 now blocks the step whatever the posture, as Bar set out on issue #32 on 11-04.
One rule changed after that. On 11-05 the leads agreed that an HTTP 429 is a refusal too (decision D-046), and Dan Pazlev pointed this out here on 11-30. With this PR as it is, a 429 still follows the posture, so under proceed the step runs.
I'll make that one change myself when I merge: isRefusalStatus in guardian-client.ts will block 429, and the test in client.test.ts will expect deny for it. 408 stays on the posture. You don't need to do anything for it.
This PR also conflicts with PR #229 (ACS-Core wire safeguards) in failure-posture.ts and its test imports. I'll resolve that in the batch too. With both PRs merged, bun test packages/host-adapter hosts/claude-code passes (635 pass, 0 fail).
This PR will merge into integration in the next batch, together with other PRs for release 0.1.6.
54d0ef8
into
GenAI-Security-Project:integration
The leads ruled on 11-05 that an HTTP 429 is a refusal, like the other 4xx (D-046). PR GenAI-Security-Project#544 left 429 with the posture, so under proceed the step ran. isRefusalStatus now blocks every 4xx except 408, and the client test expects deny for 429. Signed-off-by: Rock Lambros <rock@rockcyber.com>
What changed
post() now checks the status before reading the body, so any 4xx except 408 and 429 blocks the step whatever the posture, as Bar set out in #32. 408, 429 and 5xx still follow on_decision_failure, and a 5xx body is still read.
One side effect: a wrong ACS path that 404s now blocks steps instead of following the posture.
Which issue does this implement
Part of #32
meaning, so it needs no issue
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
I tested this
uv run pytest -vpasses on my machineuv run mkdocs build --strictpasses on my machinebun test packages/host-adapterpasses (395). Without the status check, the new 4xx tests fail.Checklist
git commit -s(required by the DCO)Security
It closes the fail-open on a rejected adapter credential described in #32.