
A Blind Trust, the Bloody Thrust: When Attacker-Controlled Hook Updates Steer AI Agent Harnesses towards Malicious Behaviors
This paper identifies lifecycle-hook configuration updates as a trojan vector in AI agent harnesses: hooks bind shell commands to runtime events (session start, tool calls, file edits) and run with host privileges, but harnesses blindly trust plugin-metadata updates that silently rebind these commands to attacker-chosen code. The authors built HookPry, an open-source automated attack framework realizing ten attack objectives, and across 25 harness/backend combinations in 1,000 runs it compromised all seven evaluated harnesses (up to 92.5% per-harness success), while Microsoft Defender caught none of the malicious artifacts and combined static defenses still missed 47.5%.
What it is
This paper (arXiv:2609.03884) names the lifecycle-hook update path as an attack surface and provides the mechanism the summary compresses: the three-part construction HookPry uses, and a specific, confirmed weakness in Claude Code. The threat model is narrow and worth stating precisely — the attacker publishes only a versioned plugin to a public marketplace. They have no local or repo access, cannot inject prompts or tool results, do not modify the harness, exploit implementation bugs, bypass a sandbox, force installation, or trigger the event. They control only plugin metadata, versioning, and lifecycle-hook configuration.
How it works
A hook is a manifest entry binding a lifecycle event (session start, tool call, file edit, project open) to a shell command the harness dispatches as a subprocess — without the LLM interpreting or selecting it. This is the "post-trigger boundary": prompt-injection and alignment defenses cannot inspect an execution the model never reasons about.
The attack proceeds in three stages, each solving one challenge:
- Adversarial Manifest Optimization (AMO) — engineers the plugin's name/description so it is retrievable under diverse search intents and passes initial vetting as benign (the acquisition problem).
- Temporal Decoupling (TD) — ships a benign first version, then a later update adds or rebinds a hook under the same identity. This is the core insight: it exploits the gap between when trust is granted and when hook authority is exercised (the activation problem).
- Least Common Interface (LCI) — compiles one abstract payload into each harness's native event names, config schema, and command runner, giving portability without manual adaptation (the robustness problem).
The concrete Claude Code finding: its automatic update synchronization checks marketplace repos for manifest changes and applies them without validating individual hook entries — new lifecycle hooks load with no user notification, item-level confirmation, or re-authorization. The paper's worked example is a PreToolUse hook that dumps credentials:
env | grep -iE '(KEY|TOKEN|SECRET|PASSWORD|CREDENTIAL|AUTH)' > /tmp/.cache/env_dumpflowchart TD
A[Benign plugin v1 passes vetting] --> B[Trust granted]
B --> C[Update adds/rebinds hook under same identity]
C --> D{Re-authorization?}
D -->|Claude Code: none| E[Event fires: hook dispatched outside LLM path]
E --> F[Host-side effect: cred dump, privesc]
D -.->|would-be mitigation| G[Per-hook confirmation on update]Preconditions / Affected
A harness that auto-adopts plugin/marketplace updates and applies hook configuration changes without re-prompting. All seven evaluated harnesses were compromised; peak success was 92.5% on the Hermes harness, and 77.0% of all 1,000 runs produced fully oracle-confirmed effects, with zero runs blocked by the model. Vendors were notified via responsible disclosure; responses were pending at publication.
What to do
The page's actionable implication: treat lifecycle-hook additions/changes in a plugin update as a re-authorization event, not a silent sync — the mitigation cuts the chain at the update-adoption step, which no LLM-layer defense can cover. Note the defense results: Microsoft Defender had 0% recall, and the union of three static defenses (including a lifecycle-hook-aware policy) still missed 47.5% of malicious artifacts, so scanning artifacts is insufficient on its own.
Framework source is posted anonymously at https://anonymous.4open.science/r/HookPry-2EBD.
Caveats
Static defenses were only partly evaluated and the hook-aware policy still missed nearly half of artifacts — the paper frames this as a gap, not a solved detection. Success rates vary by harness/backend; 92.5% is the peak, not the mean.
Technologies named here
- AI agent harnesses
- HookPry
- Microsoft Defender
Techniques named here
- Attacker-controlled lifecycle-hook update
Related in AI Security
