Abstract
Large Language Models (LLMs) are increasingly central to agentic systems due to their strong reasoning and planning capabilities. By interacting with external environments through predefined tools, these agents can carry out complex user tasks. Nonetheless, this interaction also introduces the risk of prompt injection attacks, where malicious inputs from external sources can mislead the agent's behavior, potentially resulting in economic loss, privacy leakage, or system compromise. System-level defenses have recently shown promise by enforcing static or predefined policies, but they still face two key challenges: the ability to dynamically update security rules and the need for memory stream isolation. To address these challenges, we propose DRIFT, a Dynamic Rule-based Isolation Framework for Trustworthy agentic systems, which enforces both control- and data-level constraints. A Secure Planner first constructs a minimal function trajectory and a JSON-schema-style parameter checklist for each function node based on the user query. A Dynamic Validator then monitors deviations from the original plan, assessing whether changes comply with privilege limitations and the user's intent. Finally, an Injection Isolator detects and masks any instructions that may conflict with the user query from the memory stream to mitigate long-term risks. We empirically validate the effectiveness of DRIFT on the AgentDojo benchmark, demonstrating its strong security performance while maintaining high utility across diverse models -- showcasing both its robustness and adaptability.
Introduction
As LLM agents move from simple chatbots to autonomous systems with tool-use capabilities—such as searching the web, reading emails, or executing code—they become vulnerable to indirect prompt injection. In these attacks, malicious instructions are hidden within external data (e.g., a product review or an automated email) to hijack the agent's workflow.
Existing defenses often struggle with a trade-off between security and utility. Model-level defenses are difficult to harden against all jailbreaks, while static system-level rules are often too rigid for complex, multi-step tasks. DRIFT (Dynamic Rule-based Isolation Framework for Trustworthy agents) addresses these gaps through a layered, system-level architecture that provides dynamic flexibility without compromising safety.
Methodology
DRIFT introduces a three-layered defense strategy that operates throughout the agent's execution cycle:
- Secure Planner: Before interacting with untrusted environments, this component analyzes the user's query to generate a "minimal function trajectory" and a JSON-schema-style parameter checklist. This establishes the "ground truth" for the user's intent.
- Dynamic Validator: To handle the messiness of real-world tasks, the Validator monitors tool calls in real-time. It categorizes actions by privilege levels (Read, Write, or Execute). While "Read" actions are generally permitted, "Write" or "Execute" actions trigger an "Intent Alignment" check to ensure the deviation still aligns with the user's original goal.
- Injection Isolator: This component maintains "memory hygiene" by scanning data returned from tools. It detects and masks instructions that conflict with the user's original query before they are added to the agent's conversation history, preventing long-term "infection" of the agent's reasoning.
Experimental Results
The researchers evaluated DRIFT using benchmarks such as AgentDojo and Agent Security Bench (ASB), which include hundreds of diverse tasks and injection attacks.
Security-Utility Trade-off
DRIFT demonstrated a significant improvement in both security and utility preservation. On the AgentDojo benchmark using GPT-4o-mini, DRIFT reduced the Attack Success Rate (ASR) from 30.7% (undefended) to just 1.3%. Unlike static defenses like CaMeL, which can break agent functionality, DRIFT maintained high utility, outperforming CaMeL by 20.1% in scenarios without attacks.
Efficiency
DRIFT is notably more efficient than previous system-level defenses. It incurs a token overhead of approximately 1.89x compared to an undefended agent, a substantial improvement over static defenses like CaMeL, which can incur up to a 7x overhead.
Conclusion
DRIFT proves that dynamic validation and memory isolation are essential for securing advanced LLM agents. By borrowing concepts like privilege levels from traditional operating systems, DRIFT creates a logical hierarchy for risk management. While future work will address computational overhead and broader real-world testing, DRIFT represents a major step toward building robust and trustworthy autonomous agents.
Summary updated