AgentGuard

Securing AI, One Action at a Time

Track: Cybersecurity / Blockchain

Inspiration

Autonomous AI agents are becoming increasingly capable. They can read emails, browse websites, summarize documents, access files, and execute actions on behalf of users. However, these capabilities introduce a serious security vulnerability: indirect prompt injection.

Unlike direct attacks on chatbots, indirect prompt injection hides malicious instructions inside content an AI agent is asked to process. An ordinary email, webpage, or document might contain instructions telling an agent to reveal private information, send data to an attacker, or perform unauthorized actions.

Traditional defenses often rely on suspicious-text detection, regex signatures, or additional AI guardrails. However, malicious instructions can be disguised through semantic paraphrasing, encoding, Unicode manipulation, invisible text, and multi-turn manipulation.

We asked a different question:

What if we stopped guessing what information says and started tracking where it came from?

Inspired by dynamic taint analysis and information-flow control in operating systems, we built AgentGuard, a runtime data-provenance firewall that separates trusted user intent from untrusted external information.

What Is AgentGuard?

AgentGuard sits between an autonomous AI agent and the tools it can access. Before a sensitive action is executed, AgentGuard evaluates the provenance of the information influencing that action and applies a configurable security policy.

It is designed to operate independently of the underlying AI model, supporting both deterministic scripted agents and LLM-powered reasoning agents.

AgentGuard uses three primary security decisions:

  • ALLOW: The action satisfies the security policy.
  • ASK: The action requires explicit user approval.
  • BLOCK: The action violates the security policy.

1. Dynamic Taint Tracking

AgentGuard assigns provenance labels based on the origin of information:

  • TRUSTED: Instructions and information explicitly provided by the user.
  • UNTRUSTED: External information received from webpages, emails, files, and other external sources.

These labels are assigned at the input/output channel boundary rather than inferred from the wording of the content.

When untrusted information enters an agent's context, AgentGuard tracks its influence as the agent interacts with tools.

This allows the firewall to distinguish between what the user actually authorized and instructions that originated from external content.

2. Stage 2: Argument-Level Provenance

A basic taint-tracking firewall can be overly restrictive. Once an agent reads an external webpage, it might block every sensitive action, even when the action was explicitly authorized by the user.

Consider this example:

A user asks an agent to read a recipe webpage and email the ingredients to Alice.

The webpage is untrusted, but the recipient Alice was explicitly specified by the user. Blocking the entire action would create an unnecessary false positive.

AgentGuard's Stage 2 Argument Provenance Engine addresses this problem:

  1. It identifies sensitive arguments in tool calls, such as an email recipient or file path.
  2. It checks whether those arguments can be traced to trusted user input.
  3. If the sensitive arguments have trusted provenance, the action can be allowed.
  4. If an injected instruction supplies an unauthorized recipient or other sensitive argument, the firewall blocks the action.

This approach helps maintain security without unnecessarily restricting legitimate workflows.

3. NVIDIA Nemotron 3.5 Super-VL Integration

We integrated NVIDIA Nemotron 3.5 Super-VL through the OpenRouter API to evaluate AgentGuard against an LLM-powered reasoning agent.

A deterministic scripted agent is useful for repeatable testing, but real-world AI applications increasingly rely on reasoning models. We wanted to investigate whether an advanced LLM could still be manipulated by malicious instructions hidden in external content.

Our application provides a side-by-side comparison between:

  • Scripted Agent: A deterministic agent used for repeatable scenario execution.
  • Nemotron LLM Agent: A reasoning model that processes external content and generates tool calls.

The comparison allows us to inspect execution traces, tool calls, arguments, provenance labels, and firewall decisions.

This demonstrates an important security principle:

An AI model's ability to reason does not automatically make it capable of distinguishing trusted instructions from malicious external content.

The model makes decisions. AgentGuard independently enforces the security boundary before sensitive actions are allowed to proceed.

4. Live Gmail IMAP Auto-Shield

AgentGuard includes an email integration using SSL-protected IMAP.

Its Live Email Inbox feature is designed to monitor incoming messages and evaluate their contents for potentially malicious instructions.

The integration supports monitoring Inbox, Spam/Junk, and All Mail folders.

Incoming emails can be evaluated using two different agent engines:

  • A deterministic scripted agent.
  • The NVIDIA Nemotron reasoning model.

This allows us to compare how different agents interpret potentially malicious email content and how AgentGuard evaluates their resulting actions.

The email integration demonstrates how provenance-based protection can be applied to practical email-driven agent workflows.

5. Hardened Provenance Engine (v2)

Our original v1 provenance implementation relied on basic substring matching.

During adversarial testing, we discovered that attackers could exploit this approach using carefully crafted argument mutations.

We developed a hardened v2 engine with several improvements:

  • NFKC Unicode normalization: Reduces Unicode-based evasion.
  • Zero-width character rejection: Prevents invisible characters from manipulating provenance checks.
  • Whole-token extraction: Uses typed token matching instead of arbitrary substring matching.
  • Control-character rejection: Rejects potentially dangerous characters, including newlines and null bytes.
  • POSIX path canonicalization: Normalizes file paths and prevents path-alias and traversal tricks.

The original v1 implementation remains available for comparison and regression testing.

6. Break It: Interactive Red-Team Lab

We wanted to test our own security system instead of simply demonstrating successful attacks being blocked.

We built the Break It adversarial testing laboratory, which evaluates seven mutation families across 109 adversarial test cases.

The testing covers:

  • Substring and truncation attacks.
  • Malicious domain extensions.
  • Unicode and normalization tricks.
  • File-path traversal and aliases.
  • Malformed and oversized inputs.
  • Tool-name mutations.
  • Provenance laundering.

Our initial v1 implementation had 21 bypasses across these tests.

After improving the provenance engine, hardened v2 recorded zero bypasses across all 109 adversarial test cases.

The lab also allows users to explore attack payloads, inspect test scenarios, and understand how the firewall responds.

7. Agent Monitoring, Threat Detection, and Event Logs

Beyond the security engine, we developed an interactive Streamlit dashboard that makes the firewall's behavior observable.

Overview Dashboard

The Overview page provides an executive view of AgentGuard's security activity, including:

  • Security checks performed.
  • Attacks successfully blocked.
  • Benign tasks completed.
  • Additional execution latency.
  • Scenario execution traces and security verdicts.

Agent Monitoring

The Agent Monitoring section provides visibility into agent execution and activity, helping users inspect how agents interact with their available tools and the security layer.

Threat Detection

The Threat Detection view presents the taint-flow architecture and attack inspection interface.

It includes:

  • Attack-vector statistics.
  • Attack taxonomy across eight categories.
  • Scenario payload and objective inspection.
  • External injection fixtures.
  • Enforcement status and agent-engine selection.

Users can inspect how external instructions enter the agent's context and where the firewall intercepts sensitive actions.

Event Logs

The Event Logs section provides an audit-oriented view of recorded security activity, allowing users to inspect execution events and firewall decisions.

Policy & Settings

AgentGuard includes configurable security policies and enforcement settings.

The policy engine uses YAML rules to define how different tools and sensitive operations should be handled.

Users can explore the security configuration and enforcement behavior rather than relying on a fixed set of hardcoded decisions.

8. Empirical Benchmark Results

We evaluated AgentGuard using 24 attack scenarios (23 non-adaptive attacks and one adaptive attack), 12 benign-utility scenarios, and 109 adversarial provenance mutation tests.

The 24 scenarios consist of 23 non-adaptive attacks and one adaptive attack.

Without Firewall (Baseline)

  • Attack success rate: 100% (23/23 non-adaptive attacks).
  • Benign task utility: 100% (12/12).
  • False blocks: 0.
  • Guard overhead: 0.000 ms.

Stage 1: Strict Taint Tracking

  • Non-adaptive attack success rate: 0% (0/23).
  • Benign task utility: 66.7% (8/12).
  • False blocks: 4.
  • Guard overhead: 0.073 ms.

Stage 2: AgentGuard

  • Non-adaptive attack success rate: 0% (0/23).
  • Benign task utility: 100% (12/12).
  • False blocks: 0.
  • Guard overhead: 0.050 ms.

Red-Team Fuzzer: Hardened v2

  • Adversarial test cases: 109.
  • Mutation families: 7.
  • v1 bypasses: 21.
  • v2 bypasses: 0.

Important Known Limitation

The adaptive A21 attack succeeds across all three enforcement modes. In this scenario, the relevant file was already present on disk before the session began, exposing a limitation in the current session-based provenance model.

We consider this an important finding rather than hiding it. Addressing pre-session state and inherited provenance is an area for future improvement.

Key Result

Under the tested non-adaptive scenarios, Stage 2 blocked all 23 attacks while successfully completing all 12 benign tasks, with zero false blocks.

The hardened v2 provenance engine also recorded zero bypasses across 109 adversarial mutation tests.

These results demonstrate the potential of argument-level provenance as a practical security mechanism for AI-agent tool execution.

9. Formal Policy Verification

AgentGuard also includes a bounded policy verifier and static policy linter.

The verifier checks security-policy consistency, including:

  • Whether registered tools have valid security tiers.
  • Whether output labels are valid.
  • Whether sensitive arguments are properly declared.
  • Whether critical tools enforce the required provenance restrictions.

The bounded verifier evaluates possible execution sequences against independent policy specifications.

At a verification horizon of k = 2, the project reports:

  • 2,048 execution sequences.
  • 4,096 step transitions.
  • Zero policy violations.

This provides an additional layer of assurance beyond ordinary scenario-based testing.

10. How We Built It

AgentGuard was developed as a modular Python security framework.

Core Security Components

  • Taint Tracking: Maintains trusted and untrusted data labels and tracks provenance through agent context.
  • Policy Engine: Applies configurable YAML security rules to determine whether tool calls should be allowed, require approval, or be blocked.
  • Provenance Engine: Implements Stage 2 argument-level provenance checks, including baseline v1 and hardened v2 implementations.
  • Security Guard: Intercepts tool calls, evaluates security policies, records decisions, and measures execution overhead.
  • Audit Logging: Records security events for inspection and analysis.
  • Formal Verifier: Checks policy consistency and verifies bounded execution sequences.

Agent Components

  • Base Agent: Defines a pluggable agent interface.
  • Scripted Agent: Executes deterministic benchmark scenarios.
  • LLM Agent: Integrates NVIDIA Nemotron 3.5 Super-VL through OpenRouter.
  • Sandbox Tools: Provide a controlled environment for testing agent actions.

Technology Stack

  • Python
  • Streamlit
  • NVIDIA Nemotron 3.5 Super-VL
  • OpenRouter API
  • YAML
  • IMAP over SSL
  • Pytest

The application combines a security dashboard, agent monitoring, email-based testing, adversarial evaluation, configurable policies, and security-event inspection in one platform.

11. What We Learned

Reasoning Does Not Guarantee Security

Our dual-engine evaluation reinforced an important lesson: even advanced reasoning models can be influenced by malicious instructions embedded in external content.

An LLM's ability to reason does not automatically establish whether an instruction came from the user or an attacker.

Security enforcement must therefore exist independently of the model's reasoning process.

Security Must Preserve Usability

Strict taint tracking can prevent unauthorized actions, but it can also block legitimate workflows.

Stage 2 demonstrated how checking the provenance of sensitive arguments can reduce false positives while maintaining protection against the tested non-adaptive attacks.

Testing Our Own Assumptions Made the System Stronger

Our initial v1 implementation was vulnerable to 21 adversarial mutations.

Building the Break It lab exposed those weaknesses and guided the development of the hardened v2 engine.

This reinforced the importance of continuously testing security mechanisms against evolving attack techniques.

12. Accomplishments We're Proud Of

  • 23/23 non-adaptive attacks blocked: Under Stage 2 in our benchmark.
  • 100% benign task utility: All 12 tested benign tasks completed under Stage 2.
  • Zero false blocks: In the Stage 2 benchmark.
  • 0/109 hardened v2 bypasses: Across adversarial mutation tests.
  • 0.050 ms Stage 2 overhead: Reported by the benchmark.
  • NVIDIA Nemotron integration: LLM-powered agent evaluation and side-by-side comparison.
  • Live Gmail IMAP integration: Email-based security testing.
  • Interactive red-team laboratory: Adversarial testing and provenance inspection.
  • Formal policy verification: Bounded execution checking with zero reported violations.
  • Interactive security dashboard: Agent monitoring, threat detection, event logs, and configurable policies.

Most importantly, we built a working prototype demonstrating how data provenance can help secure autonomous AI agents without unnecessarily restricting legitimate actions.

13. Try It Live & Explore the Code

Live Interactive Application:
https://taint-tracking-firewalls-for-agents-hdmcmfexxjgqxsgwtmxvnu.streamlit.app/

GitHub Repository:
https://github.com/AVKD1279/Taint-Tracking-Firewalls-for-Agents

14. What's Next for AgentGuard?

We see several opportunities to extend AgentGuard beyond its current prototype:

  • MCP Integration: Extend protection to Model Context Protocol-compatible agents and tools.
  • Implicit Information Flow: Track indirect influences between information sources, not just direct data movement.
  • Multi-Agent Protection: Propagate provenance labels across collaborating AI agents.
  • Browser Extension: Identify potentially malicious external content before it reaches an AI agent.
  • Framework Compatibility: Integrate with additional AI-agent frameworks and real-world workflows.
  • Pre-Session Provenance: Improve protection against attacks involving files and state that existed before an agent session began.

Our long-term vision is to make AgentGuard a lightweight, model-independent security layer that helps developers build AI agents that are powerful, useful, and safe.

Built With

  • ai-agents
  • artificial-intelligence
  • cybersecurity
  • data-provenance
  • github
  • information-flow-control
  • llms
  • nvidia
  • openrouter
  • prompt-injection
  • pytest
  • python
  • streamlit
  • yaml
Share this project:

Updates

Submission history