Skip to content

Record a deny the Claude Code shim cannot carry out as unenforced, not blocked - #615

Merged
rocklambros merged 5 commits into
GenAI-Security-Project:integrationfrom
MK023:refimpl/audit-unenforced
Dec 3, 2026
Merged

rocklambros merged 5 commits into
GenAI-Security-Project:integrationfrom
MK023:refimpl/audit-unenforced

Conversation

@MK023

@MK023 MK023 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Under deny, a Read of an image, a PDF or a notebook ends the Claude Code shim with exit 2 at PostToolUse, and Claude Code delivers the output anyway. The audit log recorded blocked. It now records unenforced and 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:

-{"outcome": "blocked",    "posture": "deny", "method": null, "failure": {"kind": "host_configuration", ...}}
+{"outcome": "unenforced", "posture": "deny", "method": null, "failure": {"kind": "host_configuration", ...}, "tool": "Read"}

Why only the Claude Code host

The shared package wrote blocked before the host could say whether its stop withholds anything. The Claude Code shim now passes resultGateStopWithholds: false to governStep. Claude Code's hooks reference lists exit 2 at PostToolUse as "Shows stderr to Claude; the tool already ran", and I saw the image reach the model in live runs. OpenCode keeps writing blocked, because hosts/opencode/acs-plugin.ts says a throw at tool.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

unenforced is its own arm of AuditEntry: the posture fields plus tool, read from the hookmap's tool_name path, the same one buildEnvelope uses. The tool has to be on the entry. No request was built, so method is 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 proceed posture with an unwritable log, the shim falls back to deny (§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 a hook_blocking_error, not whoever runs the deployment. It is the only channel left once the log cannot be written.

Inspector and OTLP

  • The Inspector accepts the new arm, rejects one with no tool, and prints UNENFORCED with unenforced=Read: the deny could not be carried out, and the agent received the output.
  • Its banner gains unenforced=N, painted as a warning when N is above zero. This count is separate from fail-open proceeds, because none of these steps is a fail-open. Under deny the banner used to read fail-open proceeds=0 while the output went through.
  • audit-to-otlp.ts skips the entry and counts it in skippedUnenforced, with no span.

Not in this PR

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 on integration. #597 landed on 26 Nov as ac31e8a, and I merged integration into this branch, so the diff held only the 23 files of db25be9. The four conflicts came only from #597 landing as a squash: merging integration as 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.ts and govern-step.ts. I merged integration again and kept both sides in each of the six blocks. governStep now takes #355's appliedRequests and this PR's resultGateStopWithholds, the shim passes both, and each README table keeps #355's ACS_SESSION_DIR row and this PR's ACS_AUDIT_LOG row. The merge takes integration at b323224, which includes #741 and #695 of 1 Dec. #741 changes govern-step.ts outside the six blocks, and git merged it by itself. #695 changes no file under reference-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 deny a Read of an image, a PDF or a notebook is audited as blocked. This PR makes that entry unenforced, 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-tree against the head of every open PR on 18 November, after the rebase. They are the conflicts this commit adds on top of #597:

PR Where
#229, #502 the governStep call in acs-hook.ts, and the applyFailurePosture parameters
#249 the outcome lines and PostureResolvedAuditEvent in failure-posture.ts
#291 packages/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.ts and the Go parity recording ts-cases.json. #249 conflicts in failure-posture.ts and #519 in ts-cases.json. #544 still merges cleanly. #291 and #502 conflict with integration on their own.

The Go parity recording

The Go Guardian from #169 replays answers recorded from this Guardian, and TestRecordingIsCurrent checks the git ids of the paths that decide them. audit-to-otlp.ts is under packages/guardian/src, so this commit re-records agt-go/agtbridge/testdata/ts-cases.json with scripts/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 left packages/guardian/src as it was in the commit this one builds on, so the id this commit records still holds after the merge, and make check passes 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 reference
    implementation, an adapter, tests, or CI

Type of change

  • Reference implementation or adapter

I tested this

  • I synced my branch with the base branch before opening this (rebased onto bf985ca, with Govern Read in the Claude Code host #597 rebased the same way)
  • uv run pytest -v passes on my machine (9352 passed, 7 skipped, 1 xfailed)
  • uv run mkdocs build --strict passes on my machine

On this branch merged with integration at b323224, bun run typecheck exits 0 and bun test gives 1411 pass, 1 skip and 0 fail in two runs, with Bun 1.4.5. uv run pytest -v gives 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 --strict exits 0, and make setup and make check pass in agt-go on Linux x86_64. The two AgBOM viewer Node checks of the test job 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 Windows passes with Bun 1.4.4 and 1.4.5, and Reference implementation (Go) passes on all four platforms.

Before the first merge, with Bun 1.3.11, bun test gave 1301 pass and 0 fail, and bun run typecheck was clean. The new tests:

  • Through the real Claude Code shim, an image Read under deny is audited unenforced with tool: "Read". With an unwritable log, the stop says the agent received the output and no entry was written. Under proceed with an unwritable log, it no longer claims a block.
  • On OpenCode, the same failure stays blocked.
  • The Inspector reads and prints the new entry, and its banner counts it.
  • The OTLP converter skips the entry and counts it.
  • The round-trip test checks that the writer's arm and the Inspector's arm have the same fields.

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 proceed one (with the old wording put back). One existing assertion in posture.test.ts expected blocked for this case, and now expects unenforced.

Reference implementation (Go) runs on this PR, because the commit touches packages/guardian/src. I ran its Linux amd64 job locally with Go 1.27.4, Rust 1.99.0 and Bun 1.4.5: make setup and make check pass, 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

  • Commits are signed off with git commit -s (required by the DCO)
  • Prose follows STYLE.md
  • No secrets, tokens, or internal URLs in the diff

Security

  • This change has no security impact

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.

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>

@drk-ram drk-ram left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed audit-sink.ts, govern-step.ts, acs-hook.ts, audit-to-otlp.ts, packages/inspector/, and the test suites (db25be9a):

  • Honest unenforced audit outcome (UnenforcedAuditEntry / resultGateStopWithholds: false): When the Claude Code shim stops with exit 2 at PostToolUse because a non-text Read (file.base64 / file.cells) has no file.content leaf to replace, recording outcome: "unenforced" with the resolved tool name instead of outcome: "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 unenforced separately in the Inspector banner and skipping/counting unenforced entries in audit-to-otlp.ts preserve clean separation from enforced blocks and fail-open proceeds.

Signed-off-by: Marco Bellingeri <49072576+MK023@users.noreply.github.com>
@MK023

MK023 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for merging #597. With it on integration, I merged integration at ac31e8a into this branch. Four files conflicted, and this is how I resolved each one:

  • reference-implementations/agt/README.md, one sentence: I kept the integration text about onFailure, which came with fix(agt): make Claude Code PreToolUse hook fail closed #462.
  • reference-implementations/agt/hosts/claude-code/README.md, three paragraphs: the same, the integration text about onFailure stays.
  • reference-implementations/agt/hosts/claude-code/test/post-tool-use.test.ts: both blocks only add this PR's tests, so I kept them.
  • reference-implementations/agt-go/agtbridge/testdata/ts-cases.json: the recorded tree id of packages/guardian/src stays this PR's (cbd5fd14). integration records the state Govern Read in the Claude Code host #597 produced (d8cfeb4f), and this PR changes that directory on top of it.

The conflicts come only from #597 landing as a squash. When I merge integration as it was before #597, then #597, then this branch with its full history, I get the same git tree with no conflicts, so the resolution changed nothing else. After the merge, the branch differs from integration in the 23 files of db25be9.

On the merged tree, run locally:

  • bun run typecheck exits 0, and bun test gives 1318 pass, 4 skip and 0 fail in two runs, with Bun 1.3.11.
  • uv run pytest -v gives 1267 passed and 1 skipped, and uv run mkdocs build --strict exits 0.
  • The two AgBOM viewer Node checks of the test job pass on Node 22.
  • In reference-implementations/agt-go, make setup and make check pass. So do CGO_ENABLED=0 go build ./... and go test ./.... TestRecordingIsCurrent, which checks the recorded ids, passes with this PR's id, cbd5fd14, and fails with d8cfeb4f, the one integration records.
  • make image builds the image for linux/amd64, and its conformance probes pass. I ran the probes over a Docker network instead of a published port, as I did when I opened this PR, so not through make image-check itself.
  • The build job's steps from uv sync --locked --no-dev through tools/build_roadmap_data.py exit 0.
  • In a live run with Claude Code 2.1.330, an image Read under deny is audited unenforced with tool: "Read", three times out of three.

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 status:blocked label come off now that #597 has landed?

The #568 pull request (the notebook, and tool and call_id on the audit entries) is ready locally. I will open it against integration once this one lands.

bar-capsule
bar-capsule previously approved these changes Nov 29, 2026

@bar-capsule bar-capsule left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@DanPazlev

Copy link
Copy Markdown
Collaborator

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?

MK023 added 2 commits December 2, 2026 10:56
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>
@MK023

MK023 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

#355 landed on 30 Nov and conflicted with this branch, so I merged integration at b323224 into it.

The conflicts were six blocks in four files, and each block keeps both sides. governStep takes #355's appliedRequests and this PR's resultGateStopWithholds, the shim passes both, and each README table keeps #355's ACS_SESSION_DIR row and this PR's ACS_AUDIT_LOG row. Two more files are changed by both PRs, packages/guardian/README.md and govern-step.test.ts, and git merged them by itself. #355 touches no other file of this PR, so failure-posture.ts, audit-sink.ts and the Inspector are as they were. Two more PRs landed on 1 Dec. #741 changes govern-step.ts outside those blocks, and git merged it by itself. #695 changes no file under reference-implementations/. A second commit corrects two sentences, one in the agt README and one in a comment of the Claude Code hookmap. They still said that under deny a Read of an image, a PDF or a notebook is audited as blocked, and this PR makes that entry unenforced.

On the branch as it is now, with Bun 1.4.5, bun run typecheck exits 0 and bun test gives 1411 pass, 1 skip and 0 fail in two runs. uv run pytest -v gives 9352 passed, 7 skipped and 1 xfailed (#695 added the FinBot lab tests), and make setup and make check pass in agt-go. Each half of the shim's call has a test that sees it: without appliedRequests the retry test of #355 fails, and without resultGateStopWithholds: false three tests of this PR fail. After the push, on this PR, the Windows workflow passes with Bun 1.4.4 and 1.4.5 and the Go job passes on its four platforms. The description has the new numbers.

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. git merge-tree against #544 at c791150 is clean for this branch and for integration. With both merged, bun run typecheck exits 0 and bun test gives 1423 pass, 1 skip and 0 fail. For the §6.4 work on the AGT reference, bar-capsule wrote on #603 that landing this PR first works, and that building on #544 once it lands avoids a conflict (#603 (comment)).

This PR still carries status:blocked. The label was added on 21 Nov, when this PR was a draft that depended on #597, and #597 landed on 26 Nov. If nothing else blocks it, could a maintainer remove the label?

@rocklambros rocklambros left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rocklambros rocklambros mentioned this pull request Dec 3, 2026
11 of 18 tasks
@rocklambros
rocklambros merged commit 7d75245 into GenAI-Security-Project:integration Dec 3, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this from Needs triage to Done in ACS Project Tracker Dec 3, 2026
@rocklambros rocklambros mentioned this pull request Dec 3, 2026
10 of 15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:blocked Waiting on another decision or PR type:refimpl Reference implementation or adapter work

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants