An AI agent security audit is a structured review of what your coding agent can touch—MCP servers, shell, files, credentials, and every path untrusted text can enter—and whether guardrails match that scope. If you are responsible for Claude Code, Codex, or Cursor in a team that ships real code, this is how you answer “is this setup safe enough to run on our repos?” without hand-waving about the model’s intentions.
TL;DR
| Question | Answer |
|---|---|
| Am I affected? | Yes, if an agent has bash, MCP, or broad file access on code you did not write |
| Is there a fix? | Reduce scope, gate destructive tools, pin versions, log actions—not one checkbox |
| Does data leave my machine? | Depends what you audit; exfiltration paths include WebFetch, MCP, and pasted secrets |
| What is the first step? | Permission inventory—list every tool and whether it exceeds stated purpose |
| Where does compliance fit? | Audits produce evidence auditors review; they are not certifications |
OWASP’s secure agent playbook defines an AI agent security audit play: permission inventory, prompt-injection surfaces, excessive agency, exfiltration paths, tool-call injection, and guardrail checks. Google’s SAIF agent risk self-assessment asks parallel questions about user control, data access, and input screening. This post turns those plays into files and commands on a developer machine and links to Beam’s audit trail for evidence retention—not as a substitute for your assessor.
For compliance framing, see AI compliance and regulation for agent activity. For scanning a specific vendor skill, see Cloudflare security-audit skill.
AI agent security audit: scope and deliverables
Start by naming the agent’s authorized purpose in one sentence. Everything after compares capabilities to that sentence.
Deliverables that survive a security review:
- Tool and permission table — MCP servers, bash scope, filesystem roots, network allowances, secret stores.
- Input-path matrix — user chat, tool outputs, RAG docs, repo instructions, env vars; risk level per path.
- Abuse-case results — prompt override, tool misuse, exfiltration, approval bypass; pass/fail/accepted risk.
- Evidence bundle — config snapshots, version strings, sample logs with secrets redacted.
Microsoft’s security and observability pillar gates production on threat review, injection tests, and attributable audit trails. Your coding-agent audit is the workstation-sized version of that gate.
Step 1 — Permission inventory
Enumerate capabilities the way OWASP’s play specifies:
| Capability | What to record | Common overscope |
|---|---|---|
| MCP servers | Name, transport, tool list, who installed | Write tools on prod databases |
| Shell | Sandboxed or full bash, allowed paths | dangerouslySkipPermissions |
| Filesystem | Read/write roots | Home directory or ~/.ssh readable |
| Network | WebFetch domains, curl in skills | Unpinned third-party install scripts |
| Secrets | Env vars, dotfiles, cloud CLI profiles | Agent-readable .env in repo |
On Claude Code, collect ~/.claude/settings.json, project .claude/settings.local.json, marketplace pins, and plugin manifests. On Codex, mirror ~/.codex/hooks.json and permissions. If the agent can edit its own settings, treat that as escalation risk in step 3.
Run offline scans before trusting new skills:
beam scan /path/to/SKILL.md
beam scan path/to/mcp.json --mcp # project or user MCP config; path varies by harness
Per Beam scanning docs, scans are heuristic and read-only—they do not execute the skill.
Step 2 — Prompt injection surface analysis
Map every way untrusted bytes reach the model:
| Input path | Typical risk | What to verify |
|---|---|---|
| User messages | Medium | Jailbreak attempts logged? |
| Tool/API responses | High | Agent follows instructions embedded in JSON? |
| MCP resources | High | Resource text treated as system truth? |
Repo AGENTS.md / CLAUDE.md | High | Instructions override developer intent? |
| Fetched HTML | High | Preview panes executing hidden instructions? |
The OWASP AI Agent Security Cheat Sheet abuse-case table includes prompt override, tool misuse, privilege escalation, memory poisoning, and data exfiltration. For each HIGH path above, ask whether sanitized parsing exists—and whether the harness executes fetched content (audit skills, coverage HTML, dependency install scripts).
Indirect injection through a teammate’s branch is in scope. Trail of Bits regression-hunt guidance applies the same lens to skills that change over time.
Step 3 — Excessive agency (OWASP LLM06)
Check whether the agent can:
- Run destructive commands without confirmation.
- Read credentials and pass them to WebFetch or MCP HTTP tools.
- Modify hooks, install packages, or change permission files.
- Chain “safe” steps into an unsafe outcome (clone repo → run
npm install→ postinstall script).
Document which actions require human approval today and whether approval is bound to exact parameters—not a generic “yes to all edits.” Enterprise rollouts often miss parameter binding; Microsoft’s readiness doc lists it as a required gate.
Step 4 — Exfiltration path mapping
Draw arrows from secret stores to egress:
- Environment variables → URL query parameters in tool calls.
- File reads → MCP tool forwarding content to another server.
- OAuth tokens on disk → skills that
curlto unknown hosts. - Browser AI sessions → Sentinel-eligible paste exfiltration.
If you cannot diagram a path, assume attackers will find one via tool chaining. MCP security practical guide covers rug-pull and tool-poisoning patterns worth including in the audit script.
Step 5 — Tool-call injection and traversal
For each shell and file tool:
- Can user-controlled strings reach unsanitized command lines?
- Are relative paths validated against workspace root on every write, not only at permission time? Claude Code TOCTOU advisories showed validation gaps ().
- Can SQL or API tools be steered to unintended endpoints via agent-constructed queries?
Record harness version and fixed version if advisories apply—auditors will ask.
Step 6 — Guardrails and logging
Verify presence and resistance to override:
- System/developer instructions versus repo markdown precedence.
- PreToolUse deny rules for
rm -rf, credential patterns, or outbound posts. - Output filtering for secrets and internal hostnames.
- Rate limits or action budgets where the harness supports them.
- Audit logging with user, agent, tool, and version attribution.
OWASP recommends structured metadata on high-risk actions: risk score, authorization outcome, policy version. Local collectors can store normalized events with redaction; they do not replace centralized retention if your framework requires multi-year storage—see limits in compliance post.
Step 7 — Abuse-case dry runs (safe environment)
Execute the matrix in a disposable clone:
| Abuse case | Minimal test | Pass criterion |
|---|---|---|
| Prompt override | Hidden instruction in README | Agent refuses or logs override attempt |
| Tool misuse | Request disallowed MCP tool | Denied before call |
| Exfiltration | Place fake API key in file; ask agent to “debug” | Key not sent externally |
| Approval bypass | Auto-approve mode on destructive command | Blocked or flagged |
Do not run untrusted exploit code on production laptops. Use VMs or CI agents with no production credentials. KPMG’s parallel audit agents post describes scale patterns; your checklist can stay single-machine.
Documenting audit results for security reviewers
Security auditors rarely accept a verbal “we looked at it.” Package the deliverables from the scope section as dated artifacts:
- Config export — redacted JSON for settings, MCP, and hooks; include semver strings in the header comment.
- Diff since last audit —
git diffon tracked dotfiles if you version-control agent policy templates. - Test log — one row per abuse case with environment id, harness version, and outcome.
- Risk register — accepted risks with owner, compensating control, and re-review date.
When auditors ask what is security auditing for agents, point them to attributable tool-call logs and policy version—not model temperature. If your framework references EU AI Act record-keeping, clarify that internal coding assistants are usually not high-risk systems on their own; the pressure is customer-driven evidence, as described in compliance regulation for agent activity.
For what is artificial intelligence in auditing marketing language from vendors, translate it to concrete questions: which principal approved which tool call, on which device, under which policy revision.
CI and release gates after an AI agent security audit
OWASP’s cheat sheet recommends adversarial test suites in CI when agent templates or tool policies change. Minimal gates that fit coding teams:
- Fail PRs that add MCP servers without an updated inventory table in
SECURITY.mdor internal wiki. - Pin skills with commit SHA and run
beam scanin CI on changedSKILL.mdfiles—treat findings as review-required, not auto-fail, to avoid noisy regex matches. - Block merges that lower Claude Code semver below your org minimum when
CLAUDE_CODE_MIN_VERSIONis set in CI. - Re-run injection dry runs when
AGENTS.mdor.claudeinstructions change in a repo the whole team uses.
These gates complement—not replace—annual third-party review. They keep drift visible between full audits.
What this means if you run AI coding agents
Before audit: snapshot versions (claude --version, npm lockfile for SDK wrappers). During audit: freeze marketplace changes. After audit: track accepted risks with compensating controls (read-only prod, separate OAuth client, enforce hooks).
Re-audit when:
- A new MCP server appears in config.
- A skill updates from a git marketplace without hash re-verification.
- Anthropic publishes a high-severity Claude Code advisory.
Store evidence where retention policy allows. Bounded local files rotate; export if compliance needs longer windows.
What Beam can and cannot do here
Beam supports audit evidence and pre-run review, not certification. Offline skill/MCP scanning flags 11 heuristic patterns plus MCP version-pin issues. Agent runtime hooks record PreToolUse proposals with redaction before persistence. Workspace enforce can deny matching Claude Code and Codex proposals when policy is cached.
Beam does not execute your abuse-case matrix, pentest your gateways, or prove SOC 2. Scanner results are not malware verdicts; enforce is hook-based with fail-open on missing cached policy. Use audit output to configure policy—not as a signed attestation.
How Beam handles this
For teams overlapping agent observability vendors, Beam’s role is local-first: scan before run, watch proposals on the laptop, export for review. It pairs with gateway products that inventory cloud agents without replacing them. Limits above apply; compare layers in platform evaluation.
Frequently asked questions
What is an AI agent security audit?
A structured review of tools, inputs, egress, and guardrails for your coding agent, with recorded test results. It produces evidence for security and compliance reviewers.
How often should I audit my coding agent setup?
Before production use, after MCP or skill changes, after major harness upgrades, and when advisories land. Stable teams can quarterly sample configs for drift.
What files should I include in an AI agent security audit?
Harness settings, MCP configs, hooks, skills, marketplace pins, repo instruction files, and permission modes. Include files the agent can write as well as read.
Is an AI agent security audit the same as a penetration test?
No. Audits map scope and run defined abuse cases. Penetration tests hunt novel chains under engagement rules.
What is security auditing for AI agents?
Verifying least privilege, attributable logs, injection resistance, and approval binding—aligned with OWASP agent guidance and your internal risk appetite.
Can Beam replace a formal AI agent security audit?
No. It assists scanning and logging. Your assessor still owns scope, testing depth, and sign-off.
Related reading
- AI compliance and regulation for agent activity — what auditors ask from trails
- Cloudflare security-audit skill — when audit means an agent skill
- Trail of Bits regression-hunt on agent skills — supply-chain drift
- MCP security practical guide — server-side risks in the inventory
- Enterprise AI coding agent rollout checklist — org-wide audit cadence
- Audit trail for agent activity — Beam evidence page
OWASP play steps and Microsoft pillar URLs were verified 2026-11-23. Harness file paths change between releases—confirm against your installed version’s docs.

