· nervico-team · artificial-intelligence  Â· 10 min read

Security and Compliance in AI Agent Development

Code injection risks, data leakage, GDPR and EU AI Act compliance, sandbox execution, and audit trails for teams developing with AI agents.

Code injection risks, data leakage, GDPR and EU AI Act compliance, sandbox execution, and audit trails for teams developing with AI agents.

AI agents for software development execute code, access the filesystem, interact with APIs, and modify repositories. This means a compromised or misconfigured agent can cause the same damage as a developer with production access and bad intentions.

The adoption of AI agents in development teams has grown exponentially in 2025-2026, but most organizations haven’t updated their security frameworks to account for this new attack surface. They’re still applying the same security policies they used when developers wrote all code manually.

This article analyzes the five main risk vectors when developing with AI agents, current regulatory obligations (GDPR, EU AI Act), and technical countermeasures for each. This isn’t a generic compliance document: it’s a technical guide for development teams using AI agents in their daily workflow.

Code Injection: The Number One Risk

How Injection Works in AI Agents

Prompt injection is the equivalent of SQL injection for AI agents. According to the OWASP Top 10 for LLM Applications 2025, prompt injection is the number one critical vulnerability, present in more than 73% of AI deployments assessed during security audits.

There are two main types:

Direct injection: A malicious user directly manipulates the input the agent receives. In a development context, this can happen when:

  • An agent processes issues or PRs containing malicious instructions in their description
  • An agent reads configuration files that have been modified to include hidden instructions
  • An agent executes tasks based on unvalidated external user inputs

Indirect injection: Malicious content is embedded in data sources the agent consumes as context. This variant is more dangerous because the agent doesn’t distinguish between legitimate data and injected instructions. Examples in development:

  • Malicious repositories containing prompt injections in code comments or README files
  • Pull requests with hidden instructions in the diff
  • Git histories with commits containing injection payloads
  • Configuration files (including MCP configurations) modified to redirect agent behavior

A study published in ScienceDirect on threats in LLM agent workflows documents how attacks have evolved from simple jailbreak attempts to sophisticated multi-step campaigns, where attackers design prompt sequences that gradually modify the agent’s understanding of its objectives and constraints.

Technical Countermeasures

Input validation:

  • Sanitize all inputs reaching the agent from external sources
  • Implement filters that detect known injection patterns
  • Strictly separate user content from system context
  • Never allow user inputs to modify the system prompt

Principle of least privilege:

  • The agent should only have access to files and systems needed for the current task
  • Revoke permissions when the task ends
  • Use access tokens with limited scope and expiration time
  • Never give the agent access to production credentials

Mandatory sandboxing:

  • Run the agent in an isolated environment (container, VM, sandbox)
  • Block outbound network traffic (egress) to prevent data exfiltration
  • Block writes outside the workspace
  • Block writes to configuration files that could modify hooks or MCP configurations

Data Leakage: When the Agent Knows Too Much

Data Leakage Vectors

AI agents process large volumes of code and data as part of their normal operation. This creates multiple data leakage vectors:

Leakage to AI providers:

  • The code you send to the agent may be processed by the AI provider’s servers
  • Depending on terms of service, that code may be used for model training
  • Sensitive information (API keys, credentials, customer data) may be inadvertently included in context

Cross-session leakage:

  • Some agents maintain state between sessions (memory, persistent context)
  • An agent working on the payments module today may retain information about payment logic tomorrow when working on another module
  • In teams where multiple people use the same agent, information from one project can leak to another

Leakage through outputs:

  • Agent-generated code may include patterns that reveal information about your internal architecture
  • Generated error messages may expose implementation details
  • Agent logs may contain sensitive data stored in third-party systems

Technical Countermeasures

Data classification:

  • Define what type of information can and cannot be sent to the agent
  • Implement automatic filters that detect and strip credentials, PII, and sensitive data before sending
  • Use secret detection tools (like git-secrets or trufflehog) in the pipeline

Retention control:

  • Configure the agent to not retain data between sessions when possible
  • Use privacy modes when available (Cursor and Claude Code offer this option)
  • Regularly review and delete agent conversation histories

Provider agreements:

  • Verify your AI provider doesn’t use your data for training (most offer this guarantee on enterprise plans)
  • Require GDPR-compliant Data Processing Agreements (DPA)
  • Evaluate self-hosted options for highly sensitive data

GDPR and AI Agents: Concrete Obligations

What GDPR Says About AI Data Processing

GDPR doesn’t mention AI agents specifically, but its principles apply directly:

Article 6: Legal basis for processing. You need a legal basis to send personal data to an AI agent. If your agent processes code containing customer data (even in tests or fixtures), you need justification.

Article 25: Data protection by design and by default. Your agent system must implement data protection from its design, not as an afterthought. This includes data minimization (sending the agent only what’s necessary) and pseudonymization when possible.

Article 35: Data Protection Impact Assessment (DPIA). If you use AI agents to process personal data at scale or systematically, you likely need a DPIA.

Practical GDPR Implementation

  1. Audit what data your agent processes: Review what files, databases, and APIs the agent accesses. Identify if any contain personal data.

  2. Minimize context: Don’t send the agent more data than necessary. If it needs to work on a user module, don’t give it access to the payments module.

  3. Pseudonymize test data: If your test fixtures contain real customer data, replace them with synthetic data before the agent processes them.

  4. Document the data flow: Record what data is sent to the agent, to which provider, under what legal basis, and for how long it’s retained.

  5. Guarantee data subject rights: If a customer exercises their right to erasure, make sure their data is also removed from agent context or history.

EU AI Act: What Applies to Your Team

Risk Classification

The EU AI Act classifies AI systems into four risk levels. Most development agents fall into the limited or minimal risk category, but there are important exceptions:

High risk (Annex III): If your AI agent makes or assists with decisions about employment (for example, evaluating developer performance based on code metrics), it could be classified as a high-risk system. Annex III obligations for high-risk systems take effect August 2, 2026.

Limited risk: Most code development agents fall here. The primary obligations are transparency (users must know they’re interacting with AI) and technical documentation.

Key Deadlines

  • February 2025: AI prohibitions already in effect (don’t apply to typical software development)
  • August 2025: Transparency obligations for general-purpose AI
  • August 2026: Full obligations for Annex III high-risk systems
  • Possible extension to December 2027: The European Commission proposed the “Digital Omnibus” package that could postpone Annex III obligations, but prudent organizations treat August 2026 as the binding deadline

Penalties

Fines reach 35 million euros or 7% of global turnover for serious violations. This isn’t a theoretical risk: the EU has demonstrated enforcement willingness with GDPR and will apply the same approach with the AI Act.

Concrete Actions for Your Team

  1. Classify your agents: Determine if any of your AI uses fall in the high-risk category
  2. Document: Record which models you use, for what purpose, what data they process, and what controls you have
  3. Implement transparency: Users (internal and external) must know when they interact with AI-generated output
  4. Maintain audit records: Immutable logs of agent decisions and actions

Sandbox Execution: Containment Architecture

Why Sandboxing Is Mandatory

According to NVIDIA’s technical analysis on sandboxing agentic workflows, mandatory controls to mitigate serious indirect injection attacks include:

  • Network egress controls: Prevent data exfiltration
  • Blocking writes outside the workspace: Prevent persistence mechanisms and remote code execution
  • Blocking writes to configuration files: Prevent exploitation of hooks and MCP configurations

The practical conclusion is clear: an AI agent with code execution capability must run in a sandbox. Non-negotiable.

Level 1: Isolated container

  • Docker container with only necessary tools
  • No access to host network
  • Read-only filesystem except for the working directory
  • CPU, memory, and execution time limits

Level 2: Network policies

  • Whitelist of allowed endpoints (package registries, necessary APIs)
  • Block all unauthorized outbound traffic
  • Log all attempted network connections

Level 3: Activity monitoring

  • Log all executed commands
  • Real-time alerts for suspicious activity
  • Immutable audit trail of all agent actions

Implementation With Existing Tools

Most modern development agents offer security modes:

  • Claude Code: Offers privacy mode and control over which commands the agent can execute
  • Cursor: Allows configuring privacy mode at the organization level
  • Devin: Runs in isolated cloud environments by default

For agents that don’t offer native sandboxing, use Docker with restrictive configuration, or solutions like gVisor or Firecracker for stronger isolation.

Audit Trails: Complete Traceability

Why Traceability Is Critical

When an AI agent generates code that introduces a security bug, you need to answer several questions:

  • What instruction generated that code?
  • What context did the agent have when it generated it?
  • Who approved the agent’s output?
  • Was the code reviewed before reaching production?

Without a complete audit trail, these questions have no answers. And in a regulatory context (GDPR, AI Act), not having answers is a compliance problem.

What to Record

Agent inputs:

  • Complete prompt sent to the agent (including system prompt and context)
  • Identity of the user who initiated the session
  • Timestamp of each interaction

Agent outputs:

  • Complete generated code
  • Commands executed and their results
  • Decisions made (and reasoning, if available)

Human review:

  • Who reviewed the agent’s output
  • What changes were made to the output before integration
  • Explicit approval or rejection

Operational context:

  • Model and version used
  • Sandbox configuration
  • Active permissions during the session

Practical Implementation

An emerging best practice is to capture the agent’s internal thought process (chain-of-thought) and tool call logs. Organizations must implement immutable audit trails for agent memory: every time an agent stores information in long-term context, it’s cryptographically logged so that if malicious information is later found, you can trace exactly when and how it was introduced.

Tools:

  • Git log as native audit trail (every agent commit is traceable)
  • Structured logging with tools like structlog or Elastic Stack
  • Log storage in immutable systems (append-only)
  • Audit dashboards with automatic alerts

Security Checklist for Teams

Before Adopting AI Agents

  • Classify data the agent will process (public, internal, confidential, PII)
  • Define sandbox and isolation policy
  • Verify DPA with AI provider
  • Document legal basis for data processing (GDPR)
  • Classify AI usage under EU AI Act

During Daily Use

  • Run agents in sandbox with controlled network egress
  • Review all generated code before integration (mandatory code review)
  • Don’t send credentials, PII, or production data to the agent
  • Maintain logs of all agent interactions
  • Use secret detection in the pipeline (pre-commit hooks)

Periodic Review (Quarterly)

  • Audit agent logs looking for anomalous activity
  • Review and update agent access policies
  • Verify sandbox controls remain active
  • Update compliance documentation with regulatory changes
  • Evaluate new security tools specific to AI agents

Conclusion

Security in AI agent development isn’t an optional add-on. It’s a fundamental requirement that must be designed from day one. Attack vectors are real, regulations are binding, and the consequences of ignoring both are costly.

The good news is that countermeasures are known and applicable. Sandboxing, principle of least privilege, audit trails, input validation, and data classification are established security practices that just need adaptation to the new AI agent context.

The most common mistake isn’t failing at technical implementation. It’s not starting. Teams that integrate security and compliance from the beginning of their AI agent adoption avoid problems that are orders of magnitude more expensive to solve later.


Want to ensure your AI agent adoption meets security and compliance standards?

At NERVICO we help technical teams implement AI agents securely:

  • Security audit: We evaluate your current agent configuration and identify vulnerabilities
  • Sandbox architecture: We design isolated execution environments for your agents
  • GDPR and AI Act compliance: We help you document and meet regulatory obligations
  • Security training: We train your team in security practices specific to AI-assisted development

No alarmism. No generic security solutions. Just pragmatic security engineering adapted to your context.

Request free technical audit — We’ll evaluate the security of your AI agent setup and give you a concrete action plan.


Sources

  1. NVIDIA: Practical Security Guidance for Sandboxing Agentic Workflows
  2. Lakera: Indirect Prompt Injection - The Hidden Threat
  3. SecurePrivacy: EU AI Act 2026 Compliance Guide
  4. ScienceDirect: From Prompt Injections to Protocol Exploits in LLM-Powered Agent Workflows
  5. Wiz: AI Compliance in 2026 - Definition, Standards, and Frameworks
Back to Blog

Related Posts

View All Posts »