LLM Agents Should Employ Security Principles

Kaiyuan Zhang, Zian Su, Pin-Yu Chen, Elisa Bertino, Xiangyu Zhang, Ninghui Li · DOI

Abstract

As Large Language Model (LLM) agents evolve into autonomous assistants with access to sensitive personal data and financial accounts, they increasingly become targets for prompt injection and data theft. This paper introduces AgentSandbox, a framework that applies foundational information security principles—such as least privilege and defense-in-depth—to LLM agent architectures. AgentSandbox implements a multi-layered defense strategy that significantly reduces attack success rates to below 5% while preserving the agent's functional utility.

Introduction: The Vulnerability of LLM Agents

The core security challenge in modern LLM agents stems from the lack of separation between "code" (system instructions) and "data" (user or third-party input). In traditional software, these are distinct; however, LLMs process all text uniformly. This allows attackers to use "prompt injection"—embedding malicious commands within data (e.g., an email or a flight search result)—to hijack the agent's behavior. For instance, a malicious input might instruct an agent to ignore its safety guidelines and exfiltrate a user's credit card information. Current ad-hoc defenses, such as keyword filtering, are easily bypassed, and over-privileged access to user history exacerbates the risk of total privacy compromise.

The AgentSandbox Framework

To address these vulnerabilities, AgentSandbox adapts the Saltzer and Schroeder security principles (1975) to the LLM era. The framework decomposes the agent's lifecycle into five specialized components designed to isolate sensitive data and restrict external interactions.

The AgentSandbox architecture featuring Persistent and Ephemeral Agents.
  1. Persistent Agent (PA): Acts as the long-term repository for user profiles and Personally Identifiable Information (PII). It is isolated from direct external communication.
  2. Ephemeral Agent (EA): A short-lived, task-specific LLM instance. By deleting the EA after each task, the system prevents "memory poisoning" from persisting across sessions.
  3. Data Minimizer (DM): A gatekeeper that uses a reward-modeling policy engine to provide the EA with only the specific data required for its current task (e.g., providing a passport number for travel but withholding medical records).
  4. I/O Firewall: Enforces strict schemas on external tool calls to block unauthorized actions triggered by compromised third-party services.
  5. Response Filter (RF): Sanitizes the EA's output before it can be integrated back into the Persistent Agent's memory.

Key Insights: Sandboxing and Dynamic Privilege

The most significant innovation in AgentSandbox is the use of disposable agents. By sandboxing external interactions within a stateless Ephemeral Agent, any potential compromise is contained. Even if an attacker successfully injects a prompt, they cannot access the user's long-term memory or influence future operations. Furthermore, the Data Minimizer ensures that "least privilege" is applied contextually, dynamically balancing the need for data to complete a task against the risk of exposure.

Comparison of a standard agent versus AgentSandbox under a prompt injection attack.

Evaluation and Results

The framework was evaluated using the AgentDojo benchmark, covering 97 tasks across Banking, Slack, Travel, and Workspace domains. Testing primarily utilized GPT-4o.

  • Security: Without defense, the baseline Attack Success Rate (ASR) was approximately 58%. AgentSandbox reduced the average ASR to 4.34%. In the Workspace domain, the ASR dropped from 26.67% to just 0.83%.
  • Utility: Unlike many security measures that degrade performance, AgentSandbox maintained 82% utility, nearly matching the 83.8% utility of an undefended agent. In contrast, traditional detectors often dropped utility below 20%.

Conclusion and Future Work

AgentSandbox demonstrates that classical security principles can effectively secure modern AI agents. While the current implementation significantly improves safety, future work will focus on refining the Reward Modeling Policy Engine to handle more complex multi-agent workflows and reducing user friction in ambiguous scenarios where human-in-the-loop intervention is required.

Summary updated

BibTeX
@misc{zhang2025llm,
  author = {Kaiyuan Zhang and Zian Su and Pin-Yu Chen and Elisa Bertino and Xiangyu Zhang and Ninghui Li},
  title = {{LLM Agents Should Employ Security Principles}},
  year = {2025},
  eprint = {2505.24019},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.24019},
}
Figure