arXiv:2610.40716cs.CROct 2026

Manuscript Offprint

arXiv:2610.40716

Characterizing LLM Agent Behaviors in Module Shadowing Environments

Shuai Yang, Enmeng Lu, Jinyu Fan, Gongce Cao, Yu Chen, Jiawei Xie, Feifei Zhao, Zhangsheng Wang, Yongyu Jiang, Yi Zeng

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

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.

1 Introduction

Autonomous LLM agents operate in untrusted workspaces with permissions to read local files, write code, and run shell commands (Yang et al., 2024; Yao et al., 2023). Evaluating their safety requires analyzing how they interact with their environment and the security risks those interactions introduce. However, final reports and final workspace states alone cannot reliably establish what occurred during a task (Kirgis et al., 2026). An agent may omit a security incident from its final report, and subsequent file modifications may delete or overwrite the evidence. Consequently, similar final states can reflect either successful prevention or an incident whose traces were subsequently removed.

Module shadowing provides a useful context for examining this ambiguity. During a routine import, the runtime may load a local file in place of the intended trusted module. The local file can execute a payload and then delegate to the genuine module, allowing the agent to continue its benign task. Unlike prompt injection attacks (Debenedetti et al., 2024; Greshake et al., 2023; Perez & Ribeiro, 2022; Zhan et al., 2024), this threat vector requires no adversarial text. It therefore allows us

*Corresponding author. Contact: shuai.yang@beijing-aisi.ac.cn; yi.zeng@ruc.edu.cn.

to examine how agents respond to a threat embedded in their execution environment, including whether they recognize the mechanism, prevent payload execution, and report incidents that normal task outcomes may conceal.

We introduce a framework for evaluating agent safety beyond final outcomes by combining behavioral coding with independent environmental auditing. We code observation, reasoning, execution, and response behaviors from agent trajectories and align them with independently recorded file system changes. Applying this framework to 90 trials across 15 models under direct and indirect module shadowing reveals discrepancies among expressed risk awareness, execution outcomes, and incident reporting. Among triggered trials, final reports frequently omitted the security issue and sometimes incorrectly denied execution. By linking behaviors to independent environmental records, our framework makes these safety assessments traceable and verifiable.