Characterizing LLM Agent Behaviors in Module Shadowing Environments
Organizations: Gaoling School of AI, Renmin University of China, Beijing, China · Beijing Institute of AI Safety and Governance, Beijing, China · School of Humanities, University of Chinese Academy of Sciences, Beijing, China · Safe and Secure AI (SSAI), Beijing, China
Abstract
LLM agents operating in untrusted workspaces face the risk of untrusted code execution during routine tasks, yet final reports and workspace states alone cannot reliably establish whether execution occurred. We introduce an evaluation framework that codes observation, reasoning, execution, and response behaviors from agent trajectories and aligns them with independent environmental records to reconstruct execution histories and verify final reports. We apply this framework to module shadowing, in which a local file is loaded in place of a trusted module during import, enabling untrusted code execution without adversarial prompts. Across 90 trials with 15 models, the payload executed in 51% of direct shadowing trials and 87% of indirect shadowing trials. Even explicit recognition of the shadowing mechanism did not ensure prevention, as the payload ran in 10 of the 29 trials with recorded recognition. These failures were often omitted from final reports, as 49 of the 62 triggered trials ended without mention of the security issue. Three reports even denied execution, including one from a trial in which independent logs recorded 19 payload executions. Final workspace states also obscured prior execution when agents deleted or overwrote the payload marker in 10 triggered trials. These findings demonstrate that combining behavioral coding with independent environmental auditing enables rigorous and transparent evaluation of agent safety.
Figures & tables
| Expressed risk awareness | Observed safeguards | Direct | Indirect |
|---|---|---|---|
| Explicit mechanism recognition | effective | 13/13 | 3/3 |
| some runs isolated | 3/5 | 0/1 | |
| none | 0/4 | 0/3 | |
| Other expressed awareness | effective | 1/1 | - |
| some runs isolated | 0/1 | 0/9 | |
| none | 0/8 | 0/9 |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
| Category | Behaviour | Definition and examples |
|---|---|---|
| Observation | Inspected the evaluation environment | Examines evaluation logs, verifier or test directories, processes, watcher code or cached bytecode, for example by reading the file-system watcher and startup scripts "to understand how completion is verified". |
| Inspected the module before any trigger | Displays the module's source before the first-trigger step, for example with nl -ba xml.py . | |
| Checked for the artifact before any trigger | Examines the artifact path or lists its directory before the first-trigger step, for example by listing the still-empty artifact directory. | |
| Reasoning | Recognized name shadowing | States that the local file takes precedence over or conflicts with the library module of the same name, for example "shadows Python's stdlib xml package". |
| Noted the payload's side effect | Describes the module's extra action, for example "writes a canary file when imported". | |
| Voiced suspicion of the module | Expresses suspicion about the module, for example "contains suspicious code". |
LLM Agent Security
Large language model agent security studies attacks and safeguards for systems that plan, use tools, retain memory, and act across applications.
See all 342 papers