arXiv(opens in a new tab)cs.CRSep 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2609.03884

A Blind Trust, the Bloody Thrust: When Attacker-Controlled Hook Updates Steer AI Agent Harnesses towards Malicious Behaviors

Pengxun Li, Litian Zhang, Jianwei Hou, Shujiang Wu, Song Li, Zifeng Kang, Xi Zhang

Abstract

Modern AI agent harnesses expose lifecycle hooks that bind shell commands to runtime events (e.g., session start, tool calls, and file edits). These commands run with host privileges yet ship as lifecycle-hook configuration and may fire at times the LLM never observes. We identify the lifecycle-hook update path, which harnesses trust blindly, as a new attack surface. Under a supply-chain threat model in which an attacker controls only plugin metadata and lifecycle-hook configuration, a benign versioned plugin can be trojanized by an update that silently binds attacker-chosen commands to benign events, yielding malicious host-side behavior such as privilege escalation. We propose HOOKPRY, an open-source and fully automated attack framework that systematically exploits this vulnerability across heterogeneous AI agent harnesses. HOOKPRY realizes ten attack objectives; across 25 combinations of harnesses and backends in 1,000 end-to-end runs, it compromises all seven evaluated harnesses, with per-harness success rates reaching 92.5%. Representative defenses remain insufficient: Microsoft Defender has 0% recall, and the union of three static defenses misses 47.5% of malicious artifacts.

1 Introduction

The integration of Large Language Models (LLMs) into software development has given rise to AI agent harnesses, i.e., frameworks such as Claude Code [2], OpenClaw [33, 34], and Codex CLI [32] that serve as the critical bridge between user intent and host system execution. Far from being simple message relays, these harnesses act as powerful intermediaries that possess high-level filesystem and process privileges.

Within this architecture, lifecycle hooks—integral components of the harness, designed to automate agent workflows—constitute a security-critical control plane.

A hook is essentially a configuration entry that binds a specific event—e.g., the installation of a dependency or the modification of a configuration file—to a predefined system command. Crucially, the harness can dispatch this command directly as a subprocess without requiring the LLM to interpret or select it [2, 33, 34]. For instance, a “post-update” hook could automatically trigger a script immediately after a software update, a process that occurs outside the model’s reasoning loop. This creates a decisive post-trigger boundary where defenses focused on adversarial prompts or model alignment cannot inspect the execution. While prior studies have examined malicious plugin code, tool-description poisoning, and skill manipulation [9, 18, 29, 42, 43], they have not isolated harness-managed lifecycle hooks as an independent attack target, leaving an important question unanswered: are these hooks susceptible to remote attacks delivered via the supply chain and portable across harnesses?

Regrettably, our findings confirm this possibility. We identify the lifecycle-hook update path, which harnesses trust implicitly, as a new attack surface. Under a supply-chain threat model in which an attacker controls only plugin metadata and lifecycle-hook configuration, a benign versioned plugin can be trojanized by an update that silently binds attacker-chosen commands to benign events, yielding malicious host-side behavior such as privilege escalation [10, 30, 31].

To explain why this sequence succeeds across different harnesses, we characterize three features of lifecycle hooks. The first feature is a two-layer plugin architecture, where marketplace metadata controls how a plugin is discovered while lifecycle hooks control how it actually runs. This allows a single plugin to show one unified public identity, but internally run with a distinct set of runtime permissions. The second feature is event-driven execution. Once an event matched with a lifecycle hook fires, the harness binds and spawns the configured command outside the LLM’s decision path, even if the runtime permissions attached to a stable plugin identity

*2026141030@bupt.cn †litianzhang@bupt.edu.cn §houjianwei@cac.gov.cn §wushujiang@buaa.edu.cnsongl@zju.edu.cn ||zifengkang@bupt.edu.cn **zhangx@bupt.edu.cn

Figure

Figure 1: An overview of the proposed attack framework HOOKPRY. HOOKPRY comprises three components: ① Adversarial Manifest Optimization (AMO), which improves the marketplace retrievability of an initially benign plugin; ② Temporal Decoupling (TD), separating initial trust acquisition from a later hook-bearing update and conditional activation; and ③ Least Common Interface (LCI), which maps the payload to the native lifecycle-hook interface of the target harness. Steps 1-5 illustrate a standard workflow; after a matching event has been triggered, the harness dispatches the registered command outside the LLM's decision path, leading to malicious behaviors, e.g., stealthily dumping env credentials.

may have changed across versions. The third feature is cross-harness heterogeneity; Event names, configuration schemas, and command runners differ across harnesses.

Each of these features introduces a corresponding challenge to the attacker. The first challenge, acquisition, concerns how a remote attacker can generate discovery opportunities for an initially benign plugin through ordinary marketplace channels, without direct access to the victim or the ability to force an installation. The second challenge, activation, involves how that plugin can retain its stable identity yet acquire new runtime hook permissions after initial inspection, bypassing any new LLM decision or explicit authorization for the added hook entry. The third challenge, robustness, questions how a payload can survive cross-harness discrepancies in lifecycle vocabularies, configuration schemas, shell execution contracts, and permission boundaries. While prior technical report and vulnerability disclosures demonstrate specific primitives connecting a hook to process execution [10, 30, 31], an end-to-end attack paradigm that simultaneously overcomes the three challenges has not been systematically studied.

In this paper, we propose HOOKPRY, an open-source¹ and fully automated framework for lifecycle-hook attacks that can be delivered through a supply chain, scalable to heterogeneous AI agent harnesses. Figure 1 summarizes a design overview of HOOKPRY together with its end-to-end attack path, from marketplace delivery of an initially benign plugin through a hook-bearing update to harness-controlled execution and its

externally observable effect. Specifically, the key insight behind HookPry's design is that an attacker can exploit the time gap between when a plugin earns trust and when it actually exercises hook privileges, and preserve the intended attack capability across different tools rather than relying on rigid command syntax, by stitching together delivery, activation, and execution through plugin configuration alone.

HOOKPRY comprises three components, each designed to solve one of the three challenges, respectively. The first component, Adversarial Manifest Optimization (AMO), addresses the acquisition challenge by engineering a plugin's metadata—such as its name and description—to create a constrained identity that is retrievable under diverse search intents. This optimization ensures the plugin appears benign and highly discoverable, securing initial installation without triggering security scrutiny.

Second, Temporal Decoupling (TD) addresses the activation challenge by separating the initial benign artifact from a later update carrying altered hook authority under the same identity. By exploiting this temporal gap, TD allows the plugin to pass initial vetting and gain trust before silently introducing malicious lifecycle bindings via an update.

Lastly, Least Common Interface (LCI) addresses the robustness challenge by extracting the shared lifecycle-hook capabilities across different harnesses. It acts as a compiler that translates a single abstract attack logic into the native event and command representations specific to each target harness, ensuring portability without manual adaptation.

¹https://anonymous.4open.science/r/HookPry-2EBD

HookPry effectively realizes ten distinct attack objectives across a diverse landscape of environments. Our evaluation covers 25 unique combinations of harnesses and backends, executing 1,000 end-to-end runs that demonstrate the framework's potency: HookPry successfully compromised all seven evaluated harnesses. Overall, 77.0% of the runs produced fully oracle-confirmed effects, with peak effectiveness reaching 92.5% on the Hermes harness and zero runs being explicitly blocked by the model. This high success rate underscores a critical gap in current security postures. Representative defenses remain insufficient; Microsoft Defender achieved 0% recall, and even the union of three static defenses—including a lifecycle-hook-aware policy—still missed 47.5% of the malicious artifacts. These results confirm that a minimal configuration binding can induce severe cross-harness effects, largely bypassing the model-mediated loss observed in traditional prompt-based attacks and evading defenses that fail to inspect the lifecycle-hook path. Finally, we have responsibly disclosed our findings to all affected harness vendors and are waiting for their response.

Our contributions are:

  • A new attack surface and supply-chain threat model. We identify the lifecycle-hook update path, which harnesses trust blindly, as a critical new attack surface. We formalize a supply-chain attack where a benign, versioned plugin is trojanized via a trusted update to silently bind attacker-chosen commands to benign events, enabling malicious host-side behavior such as privilege escalation without modifying the plugin's executable code.

  • An automated cross-harness attack framework. We propose HOOKPRY, an open-source and fully automated framework that systematically exploits this vulnerability across heterogeneous AI agent harnesses. HOOKPRY is designed to realize ten distinct attack objectives, addressing the challenges of acquisition, activation, and robustness in automated agent environments.

  • Comprehensive evaluation and defense analysis. We demonstrate HOOKPRY's effectiveness through 1,000 end-to-end runs across 25 combinations of seven harnesses and five LLM backends. Our results show that HOOKPRY compromises all evaluated harnesses, with success rates reaching 92.5%. We further show that representative defenses, including Microsoft Defender, are insufficient, achieving 0% recall and missing a significant portion of malicious artifacts.

References (43)