Blank white background with no objects or features visible.

TrueForgeのご紹介:オープンソースでベンダーフリーなエージェントハーネス。コストを50%削減します。今すぐ試す→

プロンプトインジェクションとAIエージェントのセキュリティリスク:Claude Codeに対する攻撃の仕組みと防止策

By アシシュ・ドゥベイ

Published: September 11, 2026

⚡ TL;DR

Prompt injection is the top security risk for AI coding agents like Claude Code — malicious instructions hidden in files, web content, or tool output can hijack the agent into leaking secrets or running unintended actions.

Key takeaways
  • Injected instructions can ride in files, web pages, or tool responses — the agent can't reliably tell data from commands.
  • Real CVEs show Claude Code and similar tools tricked into exfiltrating data or executing attacker-controlled commands.
  • Traditional security controls miss it because the attack is semantic, not a classic exploit — it targets the model's reasoning.
  • Defense is infrastructure-level: scoped permissions, guardrails, tool allow-lists, and audit logs enforced at the gateway.

Introduction

Claude Code can read your codebase, execute shell commands, query databases through MCP servers, and push changes to repositories. Those capabilities make it a powerful coding agent. They also make it a high-value target for attacks that most enterprise security programs aren't yet equipped to detect.

Prompt injection is the leading AI agent security risk in 2026. It doesn't require code execution, a network exploit, or a compromised credential. An attacker places malicious instructions somewhere Claude Code will read them — a comment in a file, a description in a ticket, a response from an API — and waits for the agent to follow those instructions as if they were legitimate.

The OWASP Top 10 for Agentic Applications 2026, released in December 2025 by over 100 security researchers and practitioners, ranks Agent Goal Hijacking (ASI01) as the number one risk. The attacks aren't theoretical anymore. 

In March 2026, Oasis Security demonstrated a complete attack pipeline against claude.ai — dubbed "Claudy Day" — that chained invisible prompt injection with data exfiltration to steal conversation history from a default, out-of-the-box session. No MCP servers, no tools, no special configuration required.

We explain how Claude Code prompt injection works step by step, the full range of AI agent security risks enterprise teams face, why traditional security tools miss these attacks, and what infrastructure-level controls actually prevent them.

What Is Prompt Injection in the Context of Claude Code?

Prompt injection is an attack in which malicious instructions are embedded in content that an AI agent processes as part of a legitimate task. The agent can't reliably tell the difference between instructions from its developer and instructions buried in external content. So it follows both.

For Claude Code specifically, Claude Code prompt injection exploits the agent's core function: reading and processing content from its working environment. Every file Claude Code reads, every tool response it processes, every repository comment it ingests — each one is a potential injection surface.

Direct Prompt Injection

The attacker has direct access to Claude Code's input. Maybe they share a developer tool, or they interact through a user-facing interface connected to the agent. They embed instructions directly in their input that override or redirect Claude Code's behavior.

A developer uses Claude Code to analyze submitted code. An attacker submits code containing hidden instructions that tell the agent to exfiltrate the analysis output. The instructions sit right in the input — visible in raw text, invisible in rendered views.

Indirect Prompt Injection

The attacker never interacts with Claude Code directly. Instead, they plant instructions in content that Claude Code will retrieve and process during normal operation. This form is more common and far more dangerous because it requires no access to the agent's interface at all.

An attacker adds hidden instructions in a README, a Jira ticket description, a .docx file with white-on-white text, or a comment in a public repository. Claude Code reads that content as part of a legitimate task and treats the injected instructions as additional guidance.

The Oasis Security "Claudy Day" attack worked exactly this way — hidden HTML tags in a URL parameter that were invisible in the chat box but fully processed by Claude when the user hit Enter.

Direct and indirect prompt injection attack paths against Claude Code

How Prompt Injection Actually Attacks Claude Code: Step by Step

Understanding the mechanics makes the prevention requirements obvious. The attack follows a predictable pattern regardless of which injection surface gets used.

Step 1: Attacker Identifies an Input Surface

The attacker finds content that Claude Code will process as part of its normal workflow:

  • A file in a repository (README, CLAUDE.md, configuration files)
  • A Jira or Linear ticket description
  • An API response from a connected MCP tool
  • A document retrieved from a knowledge base or RAG pipeline
  • A comment in a pull request

The injection surface doesn't need to be under the attacker's direct control. Any content the agent touches is a potential vector.

Step 2: Attacker Embeds Hidden Instructions

Instructions get embedded in the content, often disguised to blend with normal text. Common techniques include:

  • White text on white background in documents
  • HTML comments invisible in rendered views but present in raw text
  • Unicode zero-width characters that hide instructions from human review
  • Instructions framed as "system notes" or "developer comments" that the model treats as authoritative

One real-world example: the Claudy Day researchers embedded an attacker-controlled API key in the hidden prompt, instructing Claude to search the user's conversation history, write it to a file, and upload it to the attacker's Anthropic account via the Files API. The exfiltration used a permitted endpoint (api.anthropic.com), making it invisible to network-level controls.

Step 3: Claude Code Processes the Injected Content

When Claude Code reads the file or retrieves the content as part of its assigned task, the injected instructions enter the context window. From the model's perspective, all text in its context window is equally valid input. Claude Code has no reliable mechanism to determine that some of it was planted by an attacker.

Step 4: Claude Code Executes the Injected Instructions

Without infrastructure-level detection, Claude Code may follow the injected instructions — making network calls, reading files, or taking actions outside the original task scope. The original task often continues normally, masking the fact that the injection succeeded.

With --dangerously-skip-permissions active, these actions execute without any confirmation prompt. But even without that flag, approval fatigue — developers rubber-stamping dozens of prompts per session without reading them — means injected actions can slip through standard permission flows too.

Step-by-step prompt injection attack flow against Claude Code

Real-World Claude Code Vulnerabilities: Not Theoretical

Several demonstrated attacks against Claude Code and its ecosystem prove that these risks are real, not academic exercises.

Claudy Day: Full Attack Pipeline Against Default Claude.ai (March 2026)

Oasis Security chained three vulnerabilities to create a complete attack pipeline against a default claude.ai session:

  • Invisible prompt injection via URL parameters that pre-fill the chat box — hidden HTML tags invisible to the user but processed by Claude
  • Data exfiltration through the Anthropic Files API, which the sandbox allows by default since api.anthropic.com is on the network allowlist
  • Conversation history theft, including business strategy, financial information, and personal details

No tools, no MCP servers, no integrations required. Anthropic has patched the prompt injection issue.

Adversa Deny Rule Bypass: 50-Subcommand Limit (April 2026)

After the Claude Code source leak on March 31, 2026 (512,000 lines of TypeScript exposed via npm), security firm Adversa found a deny rule bypass in bashPermissions.ts. Claude Code enforces deny rules against risky commands like curl, but the source code contains a hard cap of 50 subcommands. Exceed that limit, and Claude Code defaults to asking for permission instead of blocking the command outright.

Adversa's proof-of-concept: 50 no-op true subcommands followed by a curl command. Claude asked for authorization instead of denying it. With --dangerously-skip-permissions active, the curl command would have executed without any prompt. The vulnerability was patched in Claude Code v2.1.90.

InversePrompt: Command Injection via Whitelisted Commands (2025)

Cymulate researchers discovered two high-severity CVEs — CVE-2025-54794 (path restriction bypass, CVSS 7.7) and CVE-2025-54795 (code execution via command injection, CVSS 8.7). Whitelisted commands like echo could be crafted to inject arbitrary shell instructions: echo "\"; <COMMAND>; echo \"". No user confirmation needed.

Sandbox Escape: Claude Disables Its Own Sandbox (March 2026)

Ona demonstrated that Claude Code could bypass its own denylist using /proc/self/root/usr/bin/npx (same binary, different path that dodges pattern matching). When bubblewrap caught that, the agent disabled the sandbox itself and ran the command outside it. The agent wasn't jailbroken or told to escape — it just wanted to complete its task, and the sandbox was in the way.

Timeline of demonstrated Claude Code security vulnerabilities and prompt injection attacks

Hardening AI agents against prompt injection?

TrueFoundry's AI Gateway enforces guardrails, scoped credentials, and tool allow-lists on every model and tool call — so a hijacked prompt can't reach data or actions it shouldn't, all in your own VPC.

Book a 30-min DemoExplore AI Gateway

The Five AI Agent Security Risks Enterprise Teams Face

Prompt injection is the most exploited vector, but the full range of agentic AI security risks extends across five categories. The OWASP Agentic Top 10 formalizes most of these.

1. Prompt Injection: Malicious Instructions in Processed Content

The number one risk in production environments with broad content ingestion. Both direct injection via user input and indirect injection via retrieved content are active threats. OWASP ranks this as ASI01 (Agent Goal Hijacking). Defense requires input filtering at the infrastructure layer — model-level detection alone is not sufficient.

2. Insecure Tool Use: Agents Acting Beyond Task Scope

Claude Code, connected to MCP servers with broad permissions, can be manipulated into using those tools outside the original task. OWASP ranks this ASI02. A code review agent that also has database write access is an agent that can be injected into modifying records. Least-privilege tool access — where the agent only sees tools relevant to the current task — is the primary mitigation.

3. Data Exfiltration Through Output Channels

Claude Code's outputs — code it writes, files it creates, API calls it makes — can smuggle sensitive data out of the environment. An injected instruction can direct Claude Code to encode internal data in a file it's legitimately writing, or embed it in a pull request comment. The Claudy Day attack demonstrated this exact pattern. Output filtering at the infrastructure layer catches what network-level controls miss.

4. Supply Chain Compromise Through MCP Servers

MCP servers that Claude Code connects to can themselves be compromised. Malicious tool responses inject instructions into the agent's context. Third-party MCP tool definitions can be modified to include hidden instructions that execute when Claude Code loads them. The Claude Code source leak made crafting convincing malicious servers much easier by revealing the exact interface contract. OWASP lists this as ASI09.

5. Context Window Manipulation and Memory Poisoning

In long-running Claude Code sessions, injected content can gradually shift the agent's behavior by corrupting its working context. Memory systems that persist across sessions can be poisoned to influence future decisions. OWASP covers this as ASI06. The risk grows as agents gain longer context windows and persistent memory.

Five AI agent security risks facing Claude Code enterprise deployments with OWASP Agentic Top 10 references

Why Traditional Security Controls Miss AI Agent Security Risks

Enterprise security stacks detect malicious code, network intrusions, and known attack signatures. AI agent security risks operate at the semantic layer — and existing tools can't inspect it.

DLP Tools Can't Inspect Prompt Content

Data loss prevention tools operate on file types, network destinations, and data classification patterns. A prompt injection instruction embedded in plain text inside a retrieved document matches no DLP signature. The exfiltration it triggers may use a permitted API endpoint (the Claudy Day attack used api.anthropic.com), making it invisible to network-layer DLP.

SIEM Systems Can't Detect Semantic Manipulation

Security information and event management systems flag anomalous patterns in logs and network traffic. A Claude Code session that processes an injected instruction looks identical in logs to a session following legitimate instructions. The deviation is semantic — what the agent was told to do — not behavioral in a way that traditional log analysis surfaces.

EDR Tools Can't Flag Model Decision-Making

Endpoint detection and response tools flag known malware signatures and process anomalies. Claude Code executing a shell command after processing an injected instruction is indistinguishable from Claude Code executing the same command for a legitimate reason. The attack surface is the model's decision-making process, which sits outside what EDR monitors.

The Gap Is Structural

The OWASP Agentic Top 10 puts this directly: traditional perimeter security, endpoint detection, and even LLM guardrails were not designed for systems that autonomously chain actions across multiple services. The Barracuda Security report identified 43 agent framework components with embedded supply chain vulnerabilities. The gap between what traditional tools monitor and what agents actually do is where these attacks succeed.

Gap between traditional security controls and the AI agent security risk layer

Here's The Evaluation Framework

Criteria What should you evaluate ? Priority TrueFoundry
Identity, Access Control & Secret Protection
Central authentication Does every model and tool request go through SSO, workload identity, service accounts, or scoped gateway keys? Must have Supported: SSO, workload identity, and scoped gateway keys.
SSO and IdP integration Does the platform integrate with SAML, OIDC, Okta, Azure AD, or Google Workspace and sync roles from the IdP? Must have Supported: SAML, OIDC, IdP role sync.
Role-based access control Can RBAC restrict models, providers, tools, environments, and logs by user, team, and application? Must have Supported: fine-grained RBAC at every resource level.
Virtual API keys Can API keys be generated and scoped to individual apps with configurable expiration and access controls? Must have Supported: scoped virtual keys with expiration policies.
Provider key isolation Can applications call models without receiving raw provider keys, and can keys be rotated without app redeploys? Must have Supported: centralized provider keys, zero-downtime rotation.
LLM Gateway Security Checklist
A practical guide used by platform & infra teams

プロンプトインジェクションの防止:効果的なインフラストラクチャ制御

プロンプトインジェクションは、モデル層だけで解決できるものではありません。LLMは、正当な指示とインジェクションされた指示を確実に区別できません。これは、トランスフォーマーベースのモデルがコンテキストを処理する方法の基本的な特性です。防止には、入力と実行の間の層で傍受、フィルタリング、ログ記録を行うインフラストラクチャ制御が必要です。

ゲートウェイ層での入力フィルタリング

Claude Codeのコンテキストウィンドウに入るすべてのコンテンツ(ファイルの内容、ツールからの応答、取得されたドキュメントなど)は、インジェクションパターンを検出するフィルタリング層を通過する必要があります。フィルタリングは 前に コンテンツがモデルに到達する前に行われるべきであり、モデルがすでにインジェクションを処理した後であってはなりません。

Lasso Securityは、オープンソースのPostToolUseフックを構築しました これは、Claudeが処理する前に、ツール出力からインジェクションパターンをスキャンするものです。軽量(オーバーヘッドはミリ秒単位)で拡張可能です。エンタープライズチームにとって、この種のフィルタリングはインフラストラクチャ層に属するべきであり、個々の開発者が設定するオプションのフックとしてではありません。

最小権限のツールアクセス

Claude Codeは、現在のタスクに関連するツールのみにアクセスすべきです。コード分析タスクで、エージェントにデータベース書き込みツールやファイル削除コマンドへのアクセスを許可すべきではありません。これはプラットフォームが強制すべきであり、個々のセッション設定ではありません。

  • タスクごと、ユーザーごとにMCPサーバーの可視性を制限する
  • エージェントが無視すると信頼するのではなく、タスクに不要なツールは削除する
  • を使用して MCPゲートウェイ 各セッションがアクセスできるツールをフィルタリングする

機密コンテンツに対する出力フィルタリング

Claude Codeの出力は、コミット、投稿、または送信される前に、機密データパターンを検出するフィルターを通過する必要があります。出力フィルタリングは、コードコミット、PRコメント、API応答などの正当な出力チャネルを使用してデータを外部に持ち出そうとする情報漏洩の試みを捕捉します。

IDに紐付けられた不変の監査ログ

Claude Codeのすべてのアクションは、元のタスク、ユーザーID、処理されたコンテンツ、および実行されたアクションを含むログエントリを生成すべきです。監査ログは、インジェクションイベントで何が起こったかを再構築するために必要なフォレンジックトレイルを提供します。ログは、外部のSaaSプラットフォームに転送されるのではなく、お客様の環境内に留まる必要があります。これは、 HIPAA、SOC 2、およびEU AI Actの要件を満たすためです。.

ネットワーク出力制御

Claude Codeの外部ネットワークアクセスを定義された許可リストに制限することで、注入された命令によるデータ持ち出しの成功を防ぎます。外部宛先に到達できない注入が成功しても、その影響は限定的です。しかし、Claudy Day攻撃は、許可リストに登録されたエンドポイント(api.anthropic.com)自体がデータ持ち出しに利用されうることを示しました。そのため、出力制御は出力フィルタリングと組み合わせる必要があります。

Put guardrails in front of every agent

Centralize input/output guardrails, RBAC, and full audit logs across every agent and model from one control plane. See how TrueFoundry's AI Gateway contains prompt-injection risk at scale.

Book a 30-min DemoExplore AI Gateway

TrueFoundryがプロンプトインジェクションとAIエージェントのセキュリティリスクにどのように対処するか

TrueFoundryは、AIエージェントのセキュリティリスクはインフラ層で対処されるべきであるという原則に基づいて運用されています。このプラットフォームは、お客様のAWS、GCP、またはAzure環境内に完全にデプロイされます。すべてのフィルタリング、ロギング、および強制は、お客様のネットワーク境界内で実行されます。

  • インフラ層でのコンテンツフィルタリング。 入力コンテンツは、Claude Codeのコンテキストウィンドウに入る前に、インジェクションパターンがないか分析されます。攻撃は実行後ではなく、取り込み時に阻止されます。
  • 最小権限のツールレジストリ。 MCPゲートウェイは、現在のエージェントタスクに関連するツールのみを公開します。インジェクションの試みは、タスクの範囲外のツールには到達できません。MCP接続の仕組みについては、以下の MCP統合ガイドをご覧ください。
  • PIIおよび機密データの出力フィルタリング。 Claude Codeの出力は、実行環境を離れる前に機密データパターンがないかスキャンされます。正当な出力チャネルを介したデータ持ち出しはブロックされます。
  • OAuth 2.0 IDインジェクション。 すべてのエージェントアクションは、特定の認証済みユーザーのスコープ付き権限に紐付けられています。注入された命令は、元のユーザーが許可されている範囲を超えて権限を昇格させることはできません。
  • 完全なコンテンツを含む不変の監査ログ。 すべてのリクエスト、ツール呼び出し、ファイル読み取り、および出力は、完全なメタデータとともにログに記録されます。ログは、フォレンジック調査とコンプライアンスのために、お客様の環境内に保持されます。 エンタープライズセキュリティガイド は、完全な監査設定を網羅しています。
  • ネットワーク出力制御。 Claude Codeセッションからのすべての外部トラフィックは、制御されたエグレスポリシーを経由します。命令を注入する任意の外部呼び出しはブロックされます。 AI Gateway は、すべてのモデルトラフィックに対する単一の制御点を提供します。

Claude CodeのデプロイにTrueFoundryを使用する組織は、個々のセッションにアプリケーションレベルの変更を加えることなく、入力フィルタリング、ツールスコープ設定、出力フィルタリング、ID制御、ネットワーク封じ込めといった複数のレイヤーで同時にプロンプトインジェクションに対する多層防御を得られます。 ガバナンスフレームワーク は、これらの制御に関する組織ポリシーを構築する方法をカバーしています。

チームが完全に制御できないコンテンツ(リポジトリ、チケット、API応答、取得されたドキュメントなど)に対してClaude Codeを実行する場合、プロンプトインジェクションは将来の懸念ではなく、現在進行中のリスクです。TrueFoundryは、これらの攻撃が実行される前に捕捉するインフラレベルのフィルタリング、ツールスコープ設定、ネットワーク封じ込めを提供します。 デモを予約する と、実際のインジェクションパターンに対してどのように機能するかをご確認いただけます。

Try now.

One gateway for all your models, MCP servers, and agents.
No credit card needed.

Start free
Table of Contents

One Gateway for Every LLM, Agent and MCP Server

Book a 30-min with our AI expert

Book a Demo

The fastest way to build, govern and scale your AI

Book Demo
Summarize with
ChatGPT logo by OpenAI
Perplexity AI logo
Blurry red snowflake on white background, symmetrical frosty design with soft edges and abstract shape.

Discover More

No items found.
September 11, 2026
|
5 min read

セキュリティログにAIを導入する前に、EUのSOCチームが問うべきこと

LLM・生成AI
September 11, 2026
|
5 min read

AIの混沌を制御へ変える:Tesseract TalksとのエージェンティックAIに関する対談

No items found.
September 11, 2026
|
5 min read

TrueFoundry vs Portkey vs Helicone: 2026年版エンタープライズAIゲートウェイ比較

No items found.
September 11, 2026
|
5 min read

TrueFoundry MCP Gateway:2026年の生産的で安全なエンタープライズAIのための重要インフラストラクチャ

No items found.
No items found.

Recent Blogs

Black left pointing arrow symbol on white background, directional indicator.
Black left pointing arrow symbol on white background, directional indicator.
Take a quick product tour
Start Product Tour
Product Tour