TrueWatch
Get Started
Security & Trust

AI Agent Security Starts With Seeing What Your Agents Do

Jimmy Soh
·Dec 1, 202611 min read

Coding agents are fast because they're trusted. They read your workspace, run terminal commands and call tools on your behalf. That same trust makes AI agent security a visibility problem first: you can't protect credentials and code from agents you can't see.

What is AI agent security? AI agent security is the practice of controlling what autonomous AI agents can read, run and send. For coding agents, that means protecting secrets in the workspace, vetting the endpoints agents send traffic through, limiting unattended actions, and keeping a record of what each agent did, on which machine, for whom.

Coding agent sending workspace context through a third-party API router that can read and rewrite requests before they reach the model

What are the biggest AI agent security risks for coding agents?

Coding agents combine broad read access, the ability to run commands and network access to model providers. Six risks come up again and again.

1. Secrets in context

Agents read project files, configuration and terminal output to understand the task. Any API key, SSH key or cloud credential stored in those places can end up in a prompt, and from there in a provider's logs or an intermediary's hands.

2. Prompt injection

Agents treat what they read as context, and an attacker can hide instructions in it: a README, a code comment, an issue, a web page or a tool's output. The OWASP AI Agent Security Cheat Sheet lists both direct and indirect prompt injection as key risks and recommends treating all external data as untrusted.

3. Untrusted intermediaries

Third-party API routers sit between the agent and the model. They can read every request and response in plain text, and a malicious one can rewrite what comes back.

4. Unattended execution

Agents running in autonomous mode act on model responses without a human confirming each step. A single injected instruction can run before anyone sees it.

5. Excessive permissions

An agent that can install packages, push code and run any shell command can do all of that on an attacker's behalf. OWASP calls this tool abuse and privilege escalation, and recommends granting only the tools a task needs.

6. Unmanaged agents

Agents installed on company laptops, often on personal accounts, that the security team doesn't know exist. None of the controls above can apply to an agent nobody has inventoried.

Unbounded agent loops add a cost risk as well, which OWASP calls denial of wallet. For tracking that side, see How to track Claude Code cost per developer.

How do secrets end up in AI agent prompts?

Agents gather context automatically. They scan project files, read configuration such as .env, and capture terminal output. If an API key, SSH key or cloud credential sits in any of those places, it can end up in a prompt without anyone deciding to share it.

Where that prompt goes next matters. Some developers route agent traffic through third-party API routers or relays, often to save cost or reach a model that isn't available in their region. A router has to read each request to forward it, and nothing stops it from keeping what it reads.

What did researchers find about LLM API routers?

In April 2026, researchers from UC Santa Barbara and collaborators published Your Agent Is Mine: Measuring Malicious Intermediary Attacks on the LLM Supply Chain. They tested 28 paid and 400 free LLM API routers using planted decoy credentials.

FindingNumber
Routers actively injecting malicious code into responses9 (1 paid, 8 free)
Routers that touched the researchers' decoy AWS credentials17
Routers that drained cryptocurrency from a researcher-owned wallet1
Routers using adaptive evasion, behaving normally until conditions changed2
Codex sessions already running in autonomous ("YOLO") mode in a separate decoy study401, in a study that captured 99 credentials across 440 sessions

An agent that runs unattended, through a router that rewrites responses, can execute injected instructions before anyone sees them.

Findings from the Your Agent Is Mine study: 9 routers injected malicious code, 17 touched decoy AWS credentials, 1 drained a crypto wallet

What does an attack on a coding agent look like, step by step?

Put the research findings together and a realistic path looks like this. Each step shows the control that could have stopped it.

StepWhat happensControl that breaks the chain
1. Cheaper accessA developer points their coding agent at a free third-party router to reach a model at lower costAn inventory of agents and the endpoints they use, plus an approved-endpoint policy
2. Context collectionThe agent reads the project, including a .env file with a cloud key, and sends it as contextSecrets kept out of files and output that agents can read
3. Credential captureThe router logs the request and keeps the keyShort-lived, scoped credentials that limit what a stolen key can do
4. Response rewriteThe router injects an extra command into the model's responseResponse-side anomaly screening
5. Unattended executionThe agent runs in autonomous mode and executes the commandA fail-closed policy gate and human confirmation for high-risk tool calls
6. InvestigationThe security team needs to know which machines, users and sessions were affectedSession traces per user and an append-only record of tool calls

No single control covers every step. Most of them, though, depend on knowing which agents run on which machines and what each session did.

Why is shadow AI now an endpoint problem?

Shadow AI used to mean someone pasting data into a chatbot. With coding agents, it means unmanaged tools running with developer-level access on company laptops, often on personal accounts, sometimes through endpoints nobody approved. Security teams can't assess a risk they can't inventory, and that inventory now lives on each device.

What defenses do researchers recommend?

The paper evaluates three client-side controls:

  1. A fail-closed policy gate: deny any tool call that isn't on an allowlist.

  2. Response-side anomaly screening: check whether returned content looks altered.

  3. Append-only transparency logging: record every call so incidents can be replayed and scoped.

All three depend on visibility. A policy gate needs to know what normal looks like. Anomaly screening needs a baseline. And without a full record, you can't tell how far a breach reached.

How do these risks map to the OWASP AI Agent Security Cheat Sheet?

The OWASP AI Agent Security Cheat Sheet is a useful reference for turning these risks into controls.

Coding agent riskOWASP risk categoryOWASP best practice
Secrets in contextSensitive data exposure, data exfiltrationData protection: minimize sensitive data in context
Prompt injectionPrompt injection (direct and indirect)Input validation: treat external data as untrusted
Untrusted intermediariesSupply chain attacksOutput validation before execution
Unattended executionExcessive autonomy, high-impact action abuseHuman-in-the-loop approval for high-impact actions
Excessive permissionsTool abuse and privilege escalationLeast privilege; fail closed for unknown tools
Unmanaged agentsNot a separate categoryMonitoring and observability: log agent decisions and tool calls

The last row is the gap. OWASP's controls assume you know which agents you run. For coding agents on developer laptops, building that inventory is the first job.

Who owns AI agent security?

Coding agent risk sits between teams, which is why it often goes unowned. A workable split:

TeamOwns
SecurityPolicy on approved agents and endpoints, review of high-risk sessions, incident response
Platform or ITAgent inventory across devices, rollout of approved configurations, secrets management
Engineering leadsTeam habits: confirmation settings, what agents may run unattended, keeping secrets out of repos
DevelopersUsing approved endpoints and accounts, and reporting agents that behave unexpectedly

Whoever owns what, all four need the same shared record of which agents run where and what they did.

Where should security teams start?

  • Inventory every coding agent installed across developer machines, including those on personal accounts.

  • Record which models and endpoints each agent is configured to use.

  • Move secrets out of plain-text files that agents can read.

  • Require human confirmation for high-risk tool calls.

  • Keep traces of agent sessions so you can review what ran, when, and for whom.

For broader guidance, see the OWASP AI Agent Security Cheat Sheet.

Where does TrueWatch AgentMeter fit?

TrueWatch AgentMeter is a desktop client that detects the supported coding agents installed on each developer's machine (Codex, Claude Code and WorkBuddy) and reports their activity to a TrueWatch workspace, attributed to each user.

  • Inventory: see which supported agents and accounts are active on which devices, per user. The connector AgentMeter installs can also bring in traces from other agents, such as Kiro, Cursor and Qoder.

  • Session records: with Enhanced Collection, each agent session is reported as a trace of model calls, tool calls and skill calls. In the Agent Monitoring Explorer you can drill down from a user to their sessions, traces and individual steps.

  • Risk events: once you set up Agent Behavior Analytics (ABA) detection rules in TrueWatch Security Monitoring, sessions and traces show a risk event count and alert level for abnormal operations, privilege escalation and sensitive data leakage during agent runs.

  • Access control: viewing agent data requires the Agent Monitoring Data Query permission, which custom roles can withhold, and workspace data access rules and sensitive data scanning apply to it.

  • Content control: Enhanced Collection can include a preview of prompts, responses and tool input and output. The connector supports three capture modes (none, preview and full), and you can turn capture off with the obs-agent-connector CLI (--capture-content none).

  • Secret redaction on the device: before anything is sent, values that look like passwords, tokens, API keys, bearer tokens or private keys are replaced with [REDACTED]. That matters for the exact risk this post describes: secrets that slip into an agent's context don't also end up in your observability data.

  • Attribution you choose: each user is identified by a User ID that only needs to be unique, so teams can attribute sessions per person without exposing names.

  • Its own hygiene: AgentMeter's diagnostic logs never record task content, full tokens, webhook addresses or signing secrets.

AgentMeter is a visibility and detection layer. It doesn't block tool calls, and it doesn't inspect which network endpoint an agent sends requests to, so pair it with a policy gate, secrets management and network controls for approved endpoints.

Visibility won't stop every attack on its own. But it's the foundation every other control is built on. Read more on the AgentMeter product page or in Introducing AgentMeter.

Frequently asked questions

What is shadow AI?

Shadow AI is AI tools used inside an organization without the security or IT team's knowledge or approval. With coding agents, that includes agents installed on company laptops, running on personal accounts or sending traffic through unapproved endpoints.

What is prompt injection in coding agents?

Prompt injection is when instructions hidden in content an agent reads, such as a README, an issue, a web page or a tool's output, change what the agent does. Because coding agents can run commands, an injected instruction can lead to real actions on a developer's machine.

What is an LLM API router, and why is it a risk?

An LLM API router is a third-party service that forwards an agent's requests to model providers. Because it reads every request and response in plain text, a malicious router can steal credentials or inject instructions, as the 2026 "Your Agent Is Mine" study showed.

How do I stop coding agents from leaking secrets?

Keep secrets out of files and terminal output that agents can read, use a secrets manager, send agent traffic only through approved endpoints, require confirmation for high-risk tool calls, and keep session traces so you can scope any incident.

Can TrueWatch AgentMeter block risky tool calls?

No. AgentMeter provides visibility and, with TrueWatch Security Monitoring, flags risky operations after they happen. Use it alongside a policy gate that enforces an allowlist of tool calls.

Does AgentMeter collect prompt content?

Basic Collection reports usage metrics only. Enhanced Collection can include a preview of prompts and responses, with passwords, tokens, API keys and private keys redacted on the device before anything is sent. You can turn content capture off with the obs-agent-connector CLI (--capture-content none).

See what your coding agents are doing

Download AgentMeter or book a demo to see every coding agent on your team's machines, per person.

Sources

By Jimmy Soh

Jimmy Soh leads presales and product at TrueWatch. He writes about the thinking behind TrueWatch's product design, the direction of its Toby AI products, and the questions customers ask most often when they start onboarding. His articles draw on his day-to-day work with engineering teams as they evaluate and roll out the platform.

Featured posts