[Conformance] Claude Code host: a file named with `@` in the prompt reaches the model without the Guardian, and the reference Guardian does not evaluate `userMessage`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- ai-infra-agents, security
Direzione di ricerca
Start with the Claude Code host hook registration and hookmap, then read the reference Guardian dispatch in reference-implementations/agt/packages/guardian/src/handshake.ts and server.ts. Trace how steps/userMessage is mapped and evaluated; the issue proposes allowing or denying these messages and blocking Claude Code prompts on denial. Done means the host sends UserPromptSubmit to the Guardian and a deny prevents the prompt and referenced file from reaching the model.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What you ran
Claude Code 2.1.325 (claude-opus-5-5), non-interactive (-p), permission mode default, --allowedTools Read, against the reference Guardian.
- ACS: the branch of #597 at 201ddb3, on top of
integrationat d3323ba. AGT Guardian, Bun 1.3.11, a Docker container, the stock manifest and the default failure posture (proceed). - Hooks: the
settings.jsonfrom #597 (PreToolUseon^(Bash|WebFetch|Read)$,PostToolUseon^(Bash|Read)$), plus a probe onUserPromptSubmitthat saves its own stdin. The probe ran in three variants: silent (exit 0, no output),{"decision":"block"}on stdout, and exit 2. - Test file:
fake-secret.txtinreference-implementations/agt/, containingAWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE, the example key from the AWS documentation. - Prompt:
@fake-secret.txt Reply with only: fatto., and in one case@/tmp/fuori-progetto/fake-secret.txt Reply with only: fatto., an absolute path outside the project. - 3 runs per case, each with a fresh Guardian and a fresh session. I checked what reached the model in the session transcript, in the
api-request-blobentries where Claude Code records the request it sent.
What you expected
docs/spec/instrument/hooks.md, userMessage:
Fires when external user input arrives, before it is presented to the agent's reasoning context.
and L132:
Decision: ALLOW / DENY / MODIFY. Guardian MAY redact content before delivery to the agent.
A file named with @ is that kind of input. Anthropic's documentation (Reference files and directories) says:
This includes the content of the file in the conversation when it fits the Read tool's token limit, 25,000 tokens by default. A text file larger than 256KB isn't included.
Your
PreToolUsehooks don't run when Claude Code includes a file you reference with@, because it makes no tool call.
So I expected the file not to go through the Read hooks fixed in #597. What I wanted to know is which hook fires, what it receives, whether it can stop the file, and what the reference Guardian would do with it.
What happened
| Case | Hooks that fired | File attached by Claude Code | Key in the request to the model |
|---|---|---|---|
| Silent probe | UserPromptSubmit (0) |
yes | yes, 3 of 3 |
| Silent probe, absolute path outside the project | UserPromptSubmit (0) |
yes | yes, 3 of 3 |
Probe answers {"decision":"block"} |
UserPromptSubmit (0) |
no | no request sent |
| Probe exits 2 | UserPromptSubmit (2) |
no | no request sent |
permissions.deny: ["Read(./fake-secret.txt)"], silent probe |
UserPromptSubmit (0) |
no | no, the prompt went out without it |
CLAUDE_CODE_DISABLE_FILE_MENTIONS=1 in the environment, silent probe |
UserPromptSubmit (0), then PreToolUse:Read (0), PostToolUse:Read (0) |
no | no: the model called Read, the Guardian answered allow and then modify, and the model got [REDACTED] |
In the first two cases the Guardian received nothing: no envelope, no audit entry. The file outside the project was attached and sent the same way as the one inside it.
The probe received cwd, hook_event_name, permission_mode, prompt, prompt_id, session_id and transcript_path. prompt was the raw text, @fake-secret.txt Reply with only: fatto., without the file's content. That matches the hooks reference: "UserPromptSubmit hooks receive the prompt field containing the submitted text."
With the block, the result was "UserPromptSubmit operation blocked by hook: probe block", followed by the original prompt, and the transcript had no file attachment and no request to the model. The hooks reference says "block" "stops the prompt before it reaches Claude". A hook that exits 2 blocks too, with its stderr shown as the reason.
The file misses three layers in turn, and that is why it never reaches the Guardian.
- Claude Code attaches the file itself, with no tool call, so
PreToolUseandPostToolUsedon't fire. The documentation quoted above says so, and the runs show it. - The AGT Claude Code host registers only
PreToolUseandPostToolUse.UserPromptSubmitfires, but nothing in the shippedsettings.jsonor the hookmap listens to it. - Even if the host sent
steps/userMessage, the reference Guardian would not decide on it. It evaluates onlysteps/toolCallRequestandsteps/toolCallResult(handshake.ts#L74), and any other method gets "method not dispatched by this Guardian" (server.ts#L944). The AGT README listssteps/userMessageas "mapped, not evaluated" (README.md#L333). Andhandshake.jsonsays a client MUST treat a method the Guardian does not evaluate as "ALLOW-by-default" (handshake.json#L80).
With this input, then, the reference deployment gave the model the file's content, both for a file inside the project and for one outside it.
What a fix could do depends on what the hook allows. Apart from the block, which I measured, this part comes from the documentation and from reasoning about it.
UserPromptSubmitcan stop the prompt and the file with it, as measured. It can't change what Claude Code attaches. The hooks reference (Decision control) lists the events that can rewrite content and says: "UserPromptSubmit: can't replace the prompt; it only injectsadditionalContextalongside it".- A Guardian that evaluates
userMessagehere can therefore allow or deny the whole prompt. It can't redact the file the way it redacts a Read result today. TheMODIFYthat hooks.md allows foruserMessagehas no way to reach the attachment on this host. - The hook sees the path, not the content. A host could decide on the path alone, the way the request gate already decides on Read's
file_path. It could also read the file at that path itself and send the content, so the Guardian decides on what the file holds. Either way the outcome is a block, not a redaction.
The other route is on the Claude Code side, and it is documented. A Read deny rule keeps a path out ("Claude Code doesn't include a file that the rule matches"). CLAUDE_CODE_DISABLE_FILE_MENTIONS=1 turns the @ reference into a path that the model then reads with Read, which goes through the gates fixed in #597. That is the last row of the table. The documentation says that variable "requires Claude Code v2.1.299 or later, and Claude Code ignores it in project and local settings", so the reference implementation can't turn it on through the project settings.json it ships. I set it in the environment and didn't test it in a settings file.
What I'd propose, for discussion:
- The reference Guardian evaluates
steps/userMessage, at least allow or deny. #229, still open, answers it with allow-by-default and records it in the session chain, which is not the same as evaluating it against policy. - The Claude Code host maps
UserPromptSubmittosteps/userMessageand applies a deny as a block. Bar's adapter inadapters/already mapsUserPromptSubmittosteps/turnStartand thensteps/userMessage(mapping.md). I haven't measured that adapter on an@reference. - Until then, the Claude Code host README states that a file named with
@never reaches the Guardian, and points deployments to the two documented controls above.
This is not #330 or #331. #330 is the Read tool, where the host fires PreToolUse and PostToolUse and the fix is in the shim (#597). In #331, shell-mode output, no hook fires at all, so it waits on Claude Code. Here a hook fires and can block, so the gap can be closed on the ACS side.
Related: #330, #331, #597, #212 (file reads on Cursor), #184 (row D7, userMessage and agentResponse not dispatched), #229, #31, #16.
Not tested: interactive mode, a directory named with @, an MCP resource named with @server:resource, the CLAUDE.md files that an @ reference also adds to the context, a file above the size limit, runs without --allowedTools Read, the variable set in user or managed settings, and other hosts.
Current Priority Scope
Feeds the runnable Guardian reference implementation
- Lingua principale
- TypeScript
- Stelle
- 183
- Fork
- 56
- Merge medio
- 3g 1h
- PR unite (30g)
- 67
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di GenAI-Security-Project/agent-control-standard
-
status:needs-triage type:bug workstream:refimpl
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
GenAI-Security-Project/agent-control-standard#764 ·
I maintainer di solito rispondono entro 1 giorno
-
status:needs-triage type:docs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 96/100
GenAI-Security-Project/agent-control-standard#717 ·
I maintainer di solito rispondono entro 1 giorno
-
status:needs-triage type:docs
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
GenAI-Security-Project/agent-control-standard#650 ·
I maintainer di solito rispondono entro 1 giorno
-
priority:P1 status:needs-triage type:conformance
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
GenAI-Security-Project/agent-control-standard#614 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Conformance] Tool-call trace spans are dropped by a GenAI backend: no gen_ai.operation.name, span name is not execute_toolForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertastatus:needs-triage type:conformance
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
GenAI-Security-Project/agent-control-standard#520 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di GenAI-Security-Project/agent-control-standard
Issue simili
-
Media browser returns "Not found" for repositories using the SHA-256 object formatForse già presa @adamchodera l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Follow-ups from #312Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
janhesters/remixcn#318 ·
I maintainer di solito rispondono entro 1 giorno
-
Interceptor LaunchTestProfile.sh: no Windows (Git Bash/MSYS) branch, test profile never launchesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
danielmiessler/LifeOS#3150 ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Make the "%" unit spacing the same in the web and in A10Forse già presa @kragent66-glitch l’ha presa oggi. Apertabug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
maiychrus25/OpenTea-DX-OS#226 · 1 commento ·