Skip to content

Back to the catalog

When the Guardrails Slip: The Case for Hook-Based Governance Across Agent Platforms | Blog | Endor Labs
endorlabs.comarticle

When the Guardrails Slip: The Case for Hook-Based Governance Across Agent Platforms | Blog | Endor Labs

Endor Labs analyzes three recent coding-agent security disclosures — a chained CWE-78 command-injection CVE trio in Claude Code CLI (CVE-2026-35020/35021/35022) leading to credential exfiltration, the cross-vendor "Comment and Control" GitHub prompt-injection attack hitting Claude Code, Gemini CLI, and GitHub Copilot Agent, and a Claude Code deny-rule bypass where policy silently stops enforcing past 50 subcommands — and argues each would have been disrupted by a platform-agnostic hook layer intercepting file writes/reads, tool calls, and egress. It maps each attack stage to hook intercept points, notes hooks' limits (entry-point injection before hook loader init, in-process bypasses needing real sandboxing), and pitches Endor Labs' own hook-based governance product as the cross-vendor policy layer.

TL;DR Endor Labs breaks down three fresh Claude Code/Gemini CLI/Copilot agent exploits (chained command-injection CVEs, cross-vendor GitHub prompt-injection, and a 50-subcommand deny-rule bypass) and argues a platform-agnostic hook layer would have caught most of them.
Document

What it is

An Endor Labs analysis mapping three recent coding-agent disclosures to specific hook-based controls. The concrete, actionable content the summary omits is where a hook would cut each attack chain, and the one place it cannot. Named specifics: the Phoenix Security CWE-78 chain in Claude Code CLI (CVE-2026-35020/21/22, confirmed exploitable on v2.1.91), and the "Comment and Control" cross-vendor prompt injection (disclosed April 16 by Aonan Guan and collaborators at Johns Hopkins; Anthropic rated its variant CVSS 9.4 Critical).

How it works

The CVE chain: 35020 gives arbitrary execution via an attacker-controlled TERMINAL env var during CLI init (zero interaction); 35021 is a POSIX double-quote bypass in the editor-path utility ($()/backtick substitution evaluates inside double quotes); 35022 is the sink — auth-helper config values invoked with shell=true and no validation, firing on every auth cycle. The chain: 35020 establishes execution → attacker writes a malicious .claude/settings.json registering a hostile auth helper → next auth detonates 35022 → exfiltration, up to Claude Code's own conversation memory.

The Comment and Control attack works identically against Claude Code Security Review, Gemini CLI Action, and Copilot Agent: injection content in a PR/issue title, body, or comment enters the agent's context inside a GitHub Actions runner holding secrets (ANTHROPIC_API_KEY, GEMINI_API_KEY, GITHUB_TOKEN); the agent is instructed to read a secret and write it back through GitHub itself (commit, issue edit, PR comment) — no external C2. The page's key point: this injection is not a bug, it's context the agent is designed to process, so model-, prompt-, and runtime-level defenses all sit upstream of the final action and were bypassed.

What to do

The page names specific hook interception points:

  • File-write hook on .claude/settings.json and adjacent agent-config paths — the agent almost never writes these mid-session, so it's a natural canary for the implant stage.
  • File-read hook on credential paths: ~/.aws/credentials, .env, MEMORY.md, keychain shims — catches collection before exfiltration.
  • Pre-tool-call hook to deny/gate git push, gh CLI, and API calls whose payloads match credential patterns — same rule across all three vendors.

Caveats

Hooks explicitly do not cover the entry point: CVE-2026-35020 fires during process startup, before agent-layer hooks initialize. Closing that gap requires environment-variable hygiene at the wrapper level, outside the agent runtime. The page also states hooks are not a substitute for a real sandbox or kernel-level monitoring — they're userspace, valued because they're the only surface consistent across vendors. The fetched text cuts off mid-sentence in Attack 2's mitigation and does not reach the third disclosure (the 50-subcommand deny-rule bypass).

Organisations named here

  • Adversa AI
  • Aonan Guan
  • CC-643
  • CWE-78
  • MAX_SUBCOMMANDS_FOR_SECURITY_CHECK
  • Phoenix Security

CVEs named here

  • CVE-2026-35020
  • CVE-2026-35021
  • CVE-2026-35022

Technologies named here

  • Claude Code CLI
  • Endor Labs hook-based AI coding agent governance product
  • Claude Code hooks
  • Gemini CLI
  • tree-sitter parser
  • GitHub Copilot Agent
  • Claude Code Security Review action
  • Gemini CLI Action
  • Claude Code
  • GitHub Copilot
  • GitHub Actions
  • Endor Labs
  • Comment and Control

Techniques named here

  • OS Command Injection
  • File exfiltration via conversation memory
  • Cross-vendor prompt injection via GitHub comment/PR/issue
  • Deny-rule bypass via subcommand count overflow