Skip to main content

Are AI Coding Tools Vulnerable to Prompt Injection?

Aya
AyaEngineer
Share

Are AI Coding Tools Vulnerable to Prompt Injection?

Yes. A coding agent can be exposed to direct or indirect prompt injection when it reads untrusted text and can also edit files, run commands, use credentials, or contact external systems. The practical risk is not merely a bad answer; it is an unintended action taken with the agent's permissions.

Apply layered controls:

  • Treat repository files, issues, web pages, dependencies, and tool output as untrusted data.
  • Limit filesystem, shell, network, credential, and deployment access to the current task.
  • Require human approval before destructive commands, secret access, publication, or production changes.
  • Use an isolated branch or worktree and review the full diff before merge.
  • Allow only expected tools and destinations, and log high-impact actions.
  • Stop and escalate when retrieved instructions conflict with the user goal or repository policy.

OWASP notes that prompt injection can be indirect and that no single prompt filter is foolproof. The safer design assumes the model may follow a hostile instruction and limits the blast radius. Test the workflow with harmless adversarial files that request an unrelated command, secret, or network destination; the expected result is refusal or escalation.

Pair instruction hierarchy with least privilege, isolation, deterministic validation, and human approval. Use the OWASP LLM01 Prompt Injection guidance and the NIST Generative AI Profile when building the threat model.

Related reading: Is my code safe with AI coding tools? and Does BYOK improve coding-tool privacy?.

Aya
Written byAyaEngineer

ソフトウェア開発の現場で、AIコーディングエージェントとワークフロー自動化を検証しています。公式ドキュメントと実際の挙動を突き合わせ、どこまでが仕様で、どこからが自分の環境の話なのかを分けて書くことを大事にしています。扱うのは主に、エージェントの権限設計、承認フロー、チームでの導入判断の3点です。

Related Guides