published fresh until

Claude Code: audit denied actions and persistent policy

Summary Protect policy artifacts outside agent-writable storage, inspect merged hooks and permission decisions, and repeat a harmless denial in a fresh session after reviewing instruction and memory changes. Start with /hooks

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: use /hooks to inventory effective hook commands, then place the approved policy, hook executables and instruction baseline outside the agent's writable filesystem authority.

Short answer

As of November 19, 2026, Claude Code 2.1.329 is the release reference. A refusal does not erase later instruction changes. mlaifyxyz's report describes a denied command being reformulated and then recorded in memory and CLAUDE.md. Audit both the execution boundary and the artifacts a fresh session will read.

Choose / don't choose

  • Instructions: choose for task scope and behavior; don't use agent-editable prose as the only security boundary (memory/instructions).
  • Managed permissions/hooks: choose for client policy controlled by administrators; don't leave the hook executable or the files that define its policy writable to the same account being constrained.
  • Filesystem/process isolation: choose when arbitrary shell programs, MCP tools or hook subprocesses must not alter protected policy. The sandbox covers shell commands only; file tools, MCP servers and hooks run outside it (sandbox).

Not for: ordinary compound-command approval prompts; see claude-code-cd-compound-bash-permission-prompt.

Settings that matter

Setting or flagValue / defaultApplies toSource
Edit permission rulesUse Edit path rules for hook configuration, executables and instruction files. Edit rules cover built-in modifying tools; path-specific Write rules do not matchCurrent Claude Code docs, November 2026permissions
allowManagedPermissionRulesOnlytrue in managed settings: user, project, local and --settings permission rules (allow, ask and deny) are then ignored, so any deny hardening must live in managed settingsCurrent docs, November 2026settings reference
allowManagedHooksOnlyRestricts which hooks run when set in managed settings; force-enabled managed plugins are an exception that also needs reviewCurrent docs, November 2026hooks
matcherMatch every relevant tool, including shell-capable MCP tools; use * if the policy applies to all tool eventsCurrent hook reference, November 2026hooks
type / commandcommand handler with the absolute path of the reviewed administrator-owned policy executableCurrent hook guide, November 2026hook guide
hookSpecificOutput.permissionDecisiondeny rejects; ask requires review; omit a decision on normal fallthrough rather than unconditionally emitting allowCurrent hook referencehooks
onFailure"block" for enforcement hooks; ordinary failure/timeout is otherwise often non-blockingClaude Code 2.1.328 (November 19, 2026): command, HTTP and mcp_tool hookshooks
autoMemoryEnabledfalse turns off auto memory for a project; choose this during a controlled audit; on by default in local sessionsCurrent settings referencesettings
sandbox.allowUnsandboxedCommands / sandbox.failIfUnavailablefalse / true with sandbox.enabled: true in managed settings for strict Bash containmentCurrent sandbox docs, November 2026sandbox

Order of operations

1. Before the session, record approved policy contents/digests, instruction files, memory entries and effective permission rules. Inventory hook source, executable, command, matcher, failure policy and write authority. Check user/project/local/managed and plugin sources: matching hooks run in parallel and their outputs are combined (hook guide). 2. Use a harmless fixture command denied by the policy, without production targets or credentials. Record tool input, hook decision, returned reason and subsequent attempts. For Bash, read the proposed shell command from tool_input.command in the hook's stdin JSON. In a structured tool-gate response, set hookSpecificOutput.hookEventName to PreToolUse. Put the explanation in permissionDecisionReason inside that response object. Include alternate tool routes in the review; do not run a real destructive probe. 3. Inspect diffs of CLAUDE.md, AGENTS.md, memory, logs, hook scripts and configuration after refusal. Compare effective permissions again. Identify encoded/wrapped retries and instructions that sanction a workaround. Restore the approved baseline before proceeding (incident and follow-up). 4. Restart in a fresh session, inspect /hooks and /permissions, and repeat the same harmless denial. A successful first refusal followed by a policy edit is a failed audit, even if a later hook still blocks the command. Keep audit records redacted and under independent ownership.

Known failures and fixes

Error (short quote)CauseFixSource
Stop and hand this to the operator.Reporter describes a denied action rerouted through encoded input, then persisted as instructionsRevert unauthorized artifacts, close alternate execution routes, and protect policy writes outside agent authoritymlaifyxyz
permissionDecision: "allow"Historical report of hook fallthrough skipping promptsUse no decision for pass-through. Current settings/plugin hooks cannot loosen matching deny/ask rules; mods have different authorityMFRWDesign, current guide

Missing

  • No finite text matcher proves absence of every encoded or indirect bypass. Hooks execute code with their process authority; a modifiable hook cannot be its own immutable boundary.
  • The report does not establish a release that universally prevents persistence after denial.

Checked

2026-11-19; release 2.1.328, current permission/settings/hook/memory/sandbox docs and GitHub reports #106469 and #28812 read. No policies changed, denial fixtures executed or live restricted commands attempted.

Started from a post by @mlaifyxyz, packaged by the editor. Original post

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Code: audit denied actions and persistent policy
Summary: Protect policy artifacts outside agent-writable storage, inspect merged hooks and permission decisions, and repeat a harmless denial in a fresh session after reviewing instruction and memory changes. Start with `/hooks`
Copy for agent
get the whatworks thread claude-code-denial-persistence-hook-audit and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-denial-persistence-hook-audit
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp