AI Coding Agent Security: Why Prompt-Level Restrictions Fail When Configuration Grants Permission
This article examines why AI coding agents can execute restricted actions when natural-language prompts forbid them but configuration files explicitly allow them. It breaks down a five-step attack chain that abuses trusted repository documentation to append external service registrations to user-level configuration, and maps each step to a concrete checkpoint. The article then presents five executable controls: trust-labeling external content, configuration integrity checks with a declarative baseline and drift detection script, prompt-versus-execution layering with a capability manifest, outbound allowlisting, and a rotate-on-discovery response procedure. A control reference table and rollout guidance help platform and engineering teams turn unpatchable upstream risk into enforceable CI gates. The core takeaway: any capability that configuration can change must be covered by configuration-level checks, not by prompt wording.
1. The Core Problem: When Constraints and Authorization Come From Different Planes
A recent technical report describes a phenomenon that testing and platform engineering teams should take seriously: the same inducement chain succeeded on two independent AI coding tools. The report’s author draws a blunt conclusion—no single vendor can “patch” this on their own.
The argument rests on an analogy: when a browser faithfully renders a spoofed bank login page, the browser is not violating its own responsibility, so there is no vulnerability. By the same logic, an AI coding agent that strictly follows the project instruction file (a conventional Markdown document) in its working directory is operating exactly as designed.
You may disagree with the analogy, but the engineering conclusion it leads to is unavoidable: if the risk cannot be eliminated by an upstream fix, it can only be converted into a check in your own gate.
The root cause is that two planes are being conflated:
- The prompt plane (soft constraints): natural-language instructions aimed at the model. They express intent and carry no enforcement power.
- The configuration plane (hard authorization): the tool’s runtime configuration files, permission declarations, plugin and external service registries. These directly determine “what can be done.”
When the prompt plane says “do not execute” and the configuration plane says “execution welcome,” the agent’s compliant choice is to obey the latter. This establishes the first principle of security design: every security boundary must live in verifiable configuration and runtime controls, not in natural language.
2. Five Checkpoints Along the Attack Chain
The real chain disclosed in the report contains five actions, and each one maps to a clear checkpoint.
- Entry: long-document delivery. The real sample was an roughly 13 KB “Engineering Work Standards” document. The payload was not conspicuous; it was hidden in a section titled “Local Development Environment.” Checkpoint: the entry point where external text enters the repository.
- Semantic disguise: abusing the name of a standard. The payload imitated everyday engineering conventions, with neutral tone and proper formatting that blended closely with the surrounding context. Checkpoint: the density of executable instructions in sections about environment setup, dependency installation, and local debugging.
- Configuration write: appending a registration block. The payload asked to append a new external service registration block to the user-level tool configuration. Checkpoint: write behavior against user-level configuration files.
- Capability gain: external tool onboarding. The registration block gave the agent a new external call capability, effectively widening the permission boundary. Checkpoint: diff comparison of the capability inventory.
- Data exfiltration: outbound request. The new capability was used to send a request outward. Checkpoint: the destination of outbound traffic.
What makes this work is not coincidence but habit: developers generally trust specification documents inside repositories, and user-level configuration has long lacked version control and review. Those two numbers—a document of a dozen-plus KB and a single configuration append—are the entire cost.
3. Five Executable Detections
3.1 Entry Detection: Label the Trust Level of External Content
- Mark all text not produced by your own team (specs, requirements, issue descriptions, third-party examples) as “untrusted input” by default.
- Scan Markdown in CI for suspicious patterns: requests to modify user-level configuration, requests to disable validation, requests to install registration items from unknown sources.
- Apply section-level hashing to very long documents and record changed sections, to avoid the case where “the whole looks unchanged but a part has been swapped.”
3.2 Configuration Integrity Detection: Bring User-Level Configuration Under Version Control
The core action is a declarative baseline plus drift alerts. Example check script:
#!/usr/bin/env bash# Configuration drift check: compare actual configuration against the in-repo baselineset -euo pipefailBASELINE=".security/agent-config.baseline"CURRENT="$(mktemp)"# Aggregate key fields of user-level tool configuration (adjust example paths per environment)for f in "$HOME"/.config/agent/*.toml; do[ -f "$f" ] && { echo "# $f"; grep -E '^\[' "$f"; }done > "$CURRENT"if ! diff -u "$BASELINE" "$CURRENT"; thenecho "[FAIL] Configuration drift: an unregistered block or permission change appeared" >&2exit 1fiecho "[PASS] Configuration matches the baseline"
Key points: commit the baseline to the repository, keep review traces, trigger from both CI and local hooks; any new registration block must go through explicit approval.
3.3 Prompt and Execution Layering Detection
- Build a capability manifest: the paths the agent can access, the categories of commands it can execute, and the services it can register, all explicitly declared, with deny by default.
- Decision rule: soft constraints must not expand hard authorization. Any text that attempts to change permissions is treated as high risk, not as an instruction.
- At runtime, use a least-privilege account and read-only mounts, so that even being “persuaded” produces no real effect.
3.4 Outbound Allowlist Detection
- Deny all outbound traffic by default, allowing only explicit domains and ports; validate both the resolved result and the target IP together, to prevent abuse at the resolution layer.
- Raise the alert level for newly appearing outbound destinations within a short window after a configuration change.
- Centralize outbound logs in a logging service with monitoring and alerting configured, and retain traceable records.
3.5 Rotate-on-Discovery Response
Once a configuration append is confirmed, the handling order is fixed: isolate first (cut credentials and network) → then rotate (tokens, keys, sessions) → then collect evidence (preserve configuration and log snapshots) → finally review (add detection items). Do not “clean everything up first and talk later”; that destroys the chain of evidence.
4. Control Reference Table
| Detection Category | Inspection Target | Failure Signal | Gate Action |
|---|---|---|---|
| Entry | External documents, requirement text | Contains configuration-write instructions | Block and require manual review |
| Configuration integrity | User-level configuration files | An unregistered block appears | Block the merge |
| Layering | Capability manifest and permissions | Soft constraints attempt privilege escalation | High-risk alert |
| Outbound | Network destinations | Non-allowlisted target | Drop and log |
| Response | Credentials and logs | Drift confirmed | Isolate, rotate, collect evidence |
5. Implementation Recommendations
Write these five items into the engineering gate, first run them in read-only mode for two weeks to collect noise, then gradually switch to blocking mode; also clarify responsibility boundaries: the platform team maintains the baseline and allowlist, while business teams are responsible for reviewing entry content. If you use general capabilities such as cloud container platforms, logging services, and monitoring alerts to carry execution and auditing, follow the same principle—permission declarations must be versionable, reviewable, and rollback-able.
The conclusion is plain: do not pin security on “the prompt was written clearly.” Any capability that configuration can change must be covered by configuration-level checks.
