Repository navigation
Record a deny the Claude Code shim cannot carry out as unenforced, not blocked - #615
Conversation
Read's file content reached the model without passing the Guardian. The shipped settings matched neither gate for Read, and the result gate's hookmap knew only Bash's stdout. Both settings matchers now include Read. The request gate reads its file_path, and the policy manifest registers Read so AGT does not fail closed on an unknown tool. At the result gate, outputs.by_tool gives Read its own path next to the existing one, the way policy_target_argument has a default and a by_tool map. Read's content is $.tool_response.file.content, and a modification is written back within $.tool_response, so Claude Code gets the shape it expects. buildPayload and governStep pick the path through the same function, outputsFor, and loadHookmap rejects a malformed by_tool entry. Bash keeps its path. Measured live on Claude Code 2.1.325: the model receives the file with the example key replaced by [REDACTED]. Read is governed on text only. An image, a PDF or a notebook has no file.content, so the posture decides, as the hookmap and the README now say. GenAI-Security-Project#568 tracks those types. Refs GenAI-Security-Project#330 Signed-off-by: Marco Bellingeri <49072576+MK023@users.noreply.github.com>
Under deny, a Read of an image, a PDF or a notebook has no leaf to replace, so the shim exits 2 at PostToolUse and Claude Code delivers the output anyway. The audit log said blocked. It now writes an unenforced entry that names the tool, and the stop says on stderr that the agent received the output. The Claude Code shim declares this with resultGateStopWithholds: false. OpenCode keeps writing blocked. The Inspector reads, prints and counts the new entry, and the OTLP converter skips and counts it. Part of GenAI-Security-Project#568. Signed-off-by: Marco Bellingeri <49072576+MK023@users.noreply.github.com>
4d83f9e to
db25be9
Compare
drk-ram
left a comment
There was a problem hiding this comment.
Reviewed audit-sink.ts, govern-step.ts, acs-hook.ts, audit-to-otlp.ts, packages/inspector/, and the test suites (db25be9a):
- Honest
unenforcedaudit outcome (UnenforcedAuditEntry/resultGateStopWithholds: false): When the Claude Code shim stops with exit2atPostToolUsebecause a non-textRead(file.base64/file.cells) has nofile.contentleaf to replace, recordingoutcome: "unenforced"with the resolvedtoolname instead ofoutcome: "blocked"prevents the audit log from claiming a block when Claude Code still delivered the file to the model (#568). - Inspector & OTLP converter handling: Counting
unenforcedseparately in the Inspector banner and skipping/countingunenforcedentries inaudit-to-otlp.tspreserve clean separation from enforced blocks and fail-open proceeds.
Signed-off-by: Marco Bellingeri <49072576+MK023@users.noreply.github.com>
|
Thank you for merging #597. With it on
The conflicts come only from #597 landing as a squash. When I merge On the merged tree, run locally:
Not run locally: the Go job on its other three platforms. I ran everything on Linux x86_64. The PR is ready for review. @bar-capsule @rocklambros, could one of you review it, please? It needs a code owner's approval to land. If something should change, tell me and I will do it the same day. Can the The #568 pull request (the notebook, and |
bar-capsule
left a comment
There was a problem hiding this comment.
Reviewed at 00ba9bf, merged locally with today's integration (a639f74): it merges cleanly, and packages/guardian/src is unchanged, so the recorded id still holds. unenforced is the right call: the log now says what happened, and the stderr no longer claims a block.
Checks run (Bun 1.3.11, as CI pins): bun run typecheck is clean, and bun test gives 1380 pass, 4 skip (the AGT pin and three proxy tests, which depend on the environment) and 0 fail. With the shim set back to resultGateStopWithholds: true, the four new Claude Code tests fail, so they test the fix.
Not checked: OpenCode itself, the Go job, and a live Claude Code run.
|
MK023 plans a follow-up to change DEFAULT_POSTURE, the handshake and decision-expiry in the AGT reference, and it looks like it touches the same Claude Code shim files as this PR. Maybe we can coordinate a merge order with #544? |
Signed-off-by: Marco Bellingeri <49072576+MK023@users.noreply.github.com>
The agt README and a comment in the Claude Code hookmap still said that under deny a Read of an image, a PDF or a notebook is audited as blocked. With this branch the entry says unenforced, so both say that now. Part of GenAI-Security-Project#568. Signed-off-by: Marco Bellingeri <49072576+MK023@users.noreply.github.com>
|
#355 landed on 30 Nov and conflicted with this branch, so I merged The conflicts were six blocks in four files, and each block keeps both sides. On the branch as it is now, with Bun 1.4.5, The push dismissed the approval of 29 Nov. bar-capsule, could you look at the two commits when you have time? DanPazlev, on the order with #544: the two do not conflict. This PR still carries |
rocklambros
left a comment
There was a problem hiding this comment.
Thanks, Marco. I'm approving this PR at a40fb3e.
The new unenforced outcome is recorded only when Claude Code can't withhold the output, and an output the shim can replace still gets blocked. The Inspector and the OTLP converter both handle the new value.
This PR conflicts with PR #229 (ACS-Core wire safeguards), which merges in the same batch. The conflicts are in failure-posture.ts, govern-step.ts, acs-hook.ts, the AGT README.md and ts-cases.json. I'll resolve them in the batch, so you don't need to rebase.
In failure-posture.ts the merge keeps PR #229's rule that a signature failure always blocks the step. With both PRs merged, the AGT suite passes (1521 pass, 1 skip, 0 fail).
One optional follow-up: resolveByPosture in govern-step.ts now reads the tool name for every posture answer. When a hookmap's tool_name path is missing, the step throws before it writes an audit entry. The step still fails closed, but the audit log misses it. Reading the tool name only when it builds the unenforced entry would fix that.
This PR will merge into integration in the next batch, together with other PRs for release 0.1.6.
7d75245
into
GenAI-Security-Project:integration
What changed
Under
deny, a Read of an image, a PDF or a notebook ends the Claude Code shim with exit 2 atPostToolUse, and Claude Code delivers the output anyway. The audit log recordedblocked. It now recordsunenforcedand names the tool, and the stop says on stderr that the agent received the output. The Inspector reads, prints and counts the new entry. The OTLP converter skips it and counts it.The same Read of a PNG under a negotiated
deny, with the payload Claude Code 2.1.325 sends:Why only the Claude Code host
The shared package wrote
blockedbefore the host could say whether its stop withholds anything. The Claude Code shim now passesresultGateStopWithholds: falsetogovernStep. Claude Code's hooks reference lists exit 2 atPostToolUseas "Shows stderr to Claude; the tool already ran", and I saw the image reach the model in live runs. OpenCode keeps writingblocked, becausehosts/opencode/acs-plugin.tssays a throw attool.execute.after"stops the model from ever seeing the tool's output". That is the authors' measurement, not mine: I have not run OpenCode, and the OpenCode test in this PR checks only what the audit log records. If you want that checked on OpenCode itself, I can run the same Read there and report what reaches the model.The entry
unenforcedis its own arm ofAuditEntry: the posture fields plustool, read from the hookmap'stool_namepath, the same onebuildEnvelopeuses. The tool has to be on the entry. No request was built, somethodis null, and the failure message names a hookmap path rather than a tool.stderr
When the audit log cannot be written, the stop now says "This host cannot withhold this step's output, so the agent receives it anyway, and no audit entry was written." Under the shipped
proceedposture with an unwritable log, the shim falls back todeny(§6.4). Before this change it also said the step "was blocked instead". It no longer claims a block. One limit: this stderr reaches the model, as ahook_blocking_error, not whoever runs the deployment. It is the only channel left once the log cannot be written.Inspector and OTLP
tool, and printsUNENFORCEDwithunenforced=Read: the deny could not be carried out, and the agent received the output.unenforced=N, painted as a warning when N is above zero. This count is separate fromfail-open proceeds, because none of these steps is a fail-open. Underdenythe banner used to readfail-open proceeds=0while the output went through.audit-to-otlp.tsskips the entry and counts it inskippedUnenforced, with no span.Not in this PR
denythe audit log says it was blocked #568 can follow one type at a time.denythe default, and under it this entry appears for every Read that is not text: all 7 cases in a replay (PNG, JPEG, GIF, WebP, PDF, PDF pages, notebook). Fail closed by default and separate refusals from decision failures (§6.4) #603 lists the AGT change as a follow-up.PostToolUseFailure([Conformance] Claude Code host: a Bash command that exits non-zero reaches the model without the result gate #613). A decision there cannot be applied either, so if [Conformance] Claude Code host: a Bash command that exits non-zero reaches the model without the result gate #613 is accepted it can add its own variant of this arm.Which issue does this implement
Part of #568
@almogbhl, this is the log part you asked for first. Should this PR close the issue, or stay "Part of" until the output is hidden as well?
Dependency and overlap
This PR depended on #597
Without #597, Read never reached
PostToolUse, so the case did not exist onintegration. #597 landed on 26 Nov as ac31e8a, and I mergedintegrationinto this branch, so the diff held only the 23 files ofdb25be9. The four conflicts came only from #597 landing as a squash: mergingintegrationas it was before #597, then #597, then this branch with its full history gives the same tree with no conflicts.#355 landed on 30 Nov as e2c7819 and conflicted with this branch in four files: the two READMEs,
acs-hook.tsandgovern-step.ts. I mergedintegrationagain and kept both sides in each of the six blocks.governStepnow takes #355'sappliedRequestsand this PR'sresultGateStopWithholds, the shim passes both, and each README table keeps #355'sACS_SESSION_DIRrow and this PR'sACS_AUDIT_LOGrow. The merge takesintegrationat b323224, which includes #741 and #695 of 1 Dec. #741 changesgovern-step.tsoutside the six blocks, and git merged it by itself. #695 changes no file underreference-implementations/.The same push has one commit that is not part of the merge. The agt README and a comment in the Claude Code hookmap still said that under
denya Read of an image, a PDF or a notebook is audited as blocked. This PR makes that entryunenforced, so both say that now. The hookmap file is new to the diff, which now has 24 files.Overlap with open PRs
I measured these with
git merge-treeagainst the head of every open PR on 18 November, after the rebase. They are the conflicts this commit adds on top of #597:governStepcall inacs-hook.ts, and theapplyFailurePostureparametersoutcomelines andPostureResolvedAuditEventinfailure-posture.tspackages/host-adapter/README.md, the audit log paragraph#544, which also touches
failure-posture.ts, merges cleanly. I'll update this branch for whichever lands first.#355 and #349 were in this table: #355 landed and #349 was closed. I measured again on 2 Dec against this branch. #229, now at a63ab58, conflicts in five files: the agt
README.md,acs-hook.ts,failure-posture.ts,govern-step.tsand the Go parity recordingts-cases.json. #249 conflicts infailure-posture.tsand #519 ints-cases.json. #544 still merges cleanly. #291 and #502 conflict withintegrationon their own.The Go parity recording
The Go Guardian from #169 replays answers recorded from this Guardian, and
TestRecordingIsCurrentchecks the git ids of the paths that decide them.audit-to-otlp.tsis underpackages/guardian/src, so this commit re-recordsagt-go/agtbridge/testdata/ts-cases.jsonwithscripts/record-ts-cases.sh, as the agt README asks. Only that id changes. The 49 recorded answers are the same. Any PR that lands first and touches those paths makes the recording stale again. #597 leftpackages/guardian/srcas it was in the commit this one builds on, so the id this commit records still holds after the merge, andmake checkpasses on the merged tree. When another such PR lands, I'll update the branch and record again.Base branch
integration, because this touches the specification, schemas, a referenceimplementation, an adapter, tests, or CI
Type of change
I tested this
uv run pytest -vpasses on my machine (9352 passed, 7 skipped, 1 xfailed)uv run mkdocs build --strictpasses on my machineOn this branch merged with
integrationat b323224,bun run typecheckexits 0 andbun testgives 1411 pass, 1 skip and 0 fail in two runs, with Bun 1.4.5.uv run pytest -vgives 9352 passed, 7 skipped and 1 xfailed: #695 added the FinBot lab tests, and the other files still give 1361 passed and 1 skipped.uv run mkdocs build --strictexits 0, andmake setupandmake checkpass inagt-goon Linux x86_64. The two AgBOM viewer Node checks of thetestjob pass on Node 22. The image builds for linux/amd64 and its conformance probes pass, again over a Docker network instead of a published port. I did not run the Go job on its other three platforms or the Windows workflow locally. Both ran on this PR after the push of 2 Dec:Reference implementation on Windowspasses with Bun 1.4.4 and 1.4.5, andReference implementation (Go)passes on all four platforms.Before the first merge, with Bun 1.3.11,
bun testgave 1301 pass and 0 fail, andbun run typecheckwas clean. The new tests:denyis auditedunenforcedwithtool: "Read". With an unwritable log, the stop says the agent received the output and no entry was written. Underproceedwith an unwritable log, it no longer claims a block.blocked.Each new test fails without the change. Most of them I watched fail before writing the code. Two I checked by breaking the code on purpose, because they passed from the start: the OpenCode test (with the default flipped) and the
proceedone (with the old wording put back). One existing assertion inposture.test.tsexpectedblockedfor this case, and now expectsunenforced.Reference implementation (Go)runs on this PR, because the commit touchespackages/guardian/src. I ran its Linux amd64 job locally with Go 1.27.4, Rust 1.99.0 and Bun 1.4.5:make setupandmake checkpass, and so do the image build and its conformance probes, which I ran over a Docker network instead of a published port. I can't run the arm64 and macOS jobs here. On 27 Nov and again on 2 Dec all four platforms passed on this PR.Checklist
git commit -s(required by the DCO)Security
The impact is on the record. The audit log no longer reports a block for output the agent received, a case #568 already describes in public. The shim's decisions, exit codes and outputs to Claude Code are unchanged. Only the stderr text and the audit entry change.