Back to Intelligence

In-the-Wild Prompt Injection Attacks Weaponize Markdown Instruction Files in AI Coding Assistants — Detection and Hardening Guide

SA
Security Arsenal Team
October 26, 2026
13 min read

Security researchers have confirmed an in-the-wild attack technique that exploits the way AI coding assistants consume local Markdown instruction files — files like CLAUDE.md, AGENTS.md, .cursorrules, .github/copilot-instructions.md, and similar context/configuration documents that agentic AI tools automatically ingest and treat as trusted operating instructions. The attack blurs a line that defenders have long treated as sacrosanct: the boundary between passive text documents and executable actions.

This is not a theoretical prompt-injection proof-of-concept demonstrated at a conference. Malicious instruction content is being planted in real-world repositories, packages, and shared workspaces where AI agents will dutifully read it and act on it — executing shell commands, exfiltrating credentials, modifying source code, or pulling down second-stage payloads, all under the guise of a trusted local file.

If your developers use AI coding assistants — and in 2026, they do — your organization is exposed to this attack surface today. This post breaks down how the attack works, how to hunt for it, and how to harden your environment against it.


Technical Analysis: How Markdown Instruction Files Become an Attack Vector

The Trust Model Problem

Modern AI coding assistants (Claude Code, GitHub Copilot, Cursor, Windsurf, Aider, and similar agentic tooling) are designed to automatically discover and load local instruction files to ground their behavior in project context. Typical examples include:

File / PatternConsumed By
CLAUDE.mdAnthropic Claude Code
AGENTS.mdOpenAI Codex and multi-agent tooling
.cursorrules, .cursor/rules/*.mdcCursor IDE
.github/copilot-instructions.mdGitHub Copilot
.windsurfrulesWindsurf
.aider.conf, CONVENTIONS.mdAider
README.md, CONTRIBUTING.mdImplicitly ingested as context by most agents

The architectural flaw being exploited: these agents treat the contents of these files as high-priority instructions, not as untrusted data. When an agent with tool-use capabilities (shell execution, file writes, network access via MCP servers) reads a poisoned instruction file, the injected directives inherit the agent's authority.

The Attack Chain

From a defender's perspective, the observed attack chain looks like this:

  1. Delivery: The attacker plants malicious instructions in a Markdown file inside a repository (malicious pull request, compromised dependency, cloned/forked repo, poisoned package template, or even a public repo the victim is told to evaluate). Sophisticated variants obfuscate the payload using invisible Unicode characters, HTML comments (<!-- ... -->), zero-width joiners, or white-on-white text so the instructions are invisible to a human reviewer but fully parsed by the model.
  2. Ingestion: A developer opens the project in an AI-assisted IDE or runs an agentic CLI tool. The agent automatically reads the instruction file as part of its context-loading routine — no user action required beyond opening the project.
  3. Execution: The injected instructions direct the agent to perform attacker-controlled actions using its granted tools: run a shell command (curl/wget to fetch a payload), read and exfiltrate files (~/.ssh/id_rsa, .env, ~/.aws/credentials, cloud tokens), modify source code to insert backdoors, or suppress its own reasoning so the developer never sees the malicious step summarized.
  4. Persistence / Exfiltration: Fetched payloads establish persistence (launch agents, cron, Run keys) or beacon credentials to attacker infrastructure. Because the execution chain runs under the developer's identity and often through the agent's own tool-execution channel, it blends into legitimate developer activity.

Why This Is Different From Prior Prompt Injection

Earlier prompt-injection research focused on chat interfaces where a user had to paste malicious content. The 2025–2026 agentic shift changed the calculus:

  • Auto-ingestion: Agents load instruction files without prompting the user.
  • Tool access: Agents can execute shell commands, edit files, and call MCP tools — injection is no longer confined to text output.
  • Trust inheritance: Content from a local file is weighted as developer intent, giving injected directives priority over safety guardrails.
  • Silent execution: Agents can be instructed (by the payload itself) to hide or minimize the summary of malicious actions.

Exploitation Status

Per the Dark Reading report, this technique is confirmed in the wild — not theoretical. No CVE has been assigned; this is a systemic design weakness in how agentic AI tools handle trusted context files rather than a single patchable bug. That means remediation is architectural and procedural, not a version bump. Do not wait for a vendor patch that structurally cannot close the whole gap.


Detection & Response

The detection strategy centers on three observables: (1) AI assistant processes spawning unexpected child processes, (2) instruction files being created or modified outside normal change control, and (3) egress connections or credential-file access initiated by agent-spawned shells.

Sigma Rules

YAML
---
title: AI Coding Assistant Process Spawning Shell or Download Utility
id: 3f8c2a71-9b4d-4e6a-a1c3-7d5e9f0b2a41
status: experimental
description: Detects AI coding assistant processes (Claude Code, Cursor, Copilot agent hosts, Windsurf, Aider) spawning shells or download/cradle utilities, consistent with prompt-injected instruction files executing attacker commands via the agent's tool channel.
references:
  - https://www.darkreading.com/application-security/in-the-wild-attack-ai-agents-trust-markdown
  - https://attack.mitre.org/techniques/T1059/
author: Security Arsenal
date: 2026/04/06
tags:
  - attack.execution
  - attack.t1059
  - attack.t1059.004
logsource:
  category: process_creation
  product: windows
detection:
  selection_parent:
    ParentImage|endswith:
      - '\claude.exe'
      - '\cursor.exe'
      - '\Code.exe'
      - '\windsurf.exe'
      - '\node.exe'
  selection_child:
    Image|endswith:
      - '\powershell.exe'
      - '\pwsh.exe'
      - '\cmd.exe'
      - '\curl.exe'
      - '\wget.exe'
      - '\certutil.exe'
      - '\mshta.exe'
      - '\rundll32.exe'
      - '\wscript.exe'
      - '\cscript.exe'
  filter_vscode_ext:
    CommandLine|contains:
      - 'extensions\\'
      - '--ms-enable-electron-run-as-node'
  condition: selection_parent and selection_child and not filter_vscode_ext
falsepositives:
  - Legitimate agent tool calls running developer-requested build/test commands — baseline per project and alert on deviations
level: high
---
title: Creation or Modification of AI Agent Instruction Files Outside Change Control
id: 8d2e5b14-6c7a-4f19-b2d4-9a3e6c1f8b52
status: experimental
description: Detects creation or modification of Markdown-based AI agent instruction files (CLAUDE.md, AGENTS.md, .cursorrules, copilot-instructions.md) which may indicate planted prompt-injection payloads, especially when written by non-editor processes.
references:
  - https://www.darkreading.com/application-security/in-the-wild-attack-ai-agents-trust-markdown
  - https://attack.mitre.org/techniques/T1037/
author: Security Arsenal
date: 2026/04/06
tags:
  - attack.persistence
  - attack.t1037
logsource:
  category: file_event
  product: windows
detection:
  selection:
    TargetFilename|endswith:
      - '\CLAUDE.md'
      - '\AGENTS.md'
      - '\.cursorrules'
      - '\copilot-instructions.md'
      - '\.windsurfrules'
      - '\CONVENTIONS.md'
    TargetFilename|contains:
      - '\.cursor\rules\'
  filter_editors:
    Image|endswith:
      - '\Code.exe'
      - '\cursor.exe'
      - '\devenv.exe'
      - '\idea64.exe'
      - '\git.exe'
  condition: selection and not filter_editors
falsepositives:
  - Legitimate scaffolding tools or project generators creating instruction files — investigate source process and file content
level: medium
---
title: Hidden or Obfuscated Content Patterns in Markdown Instruction Files
id: 5a1c9d37-2e8b-4c6d-b3f5-8d7a0e2c4b63
status: experimental
description: Detects PowerShell or shell reads/searches for HTML comment blocks and zero-width Unicode characters inside agent instruction files, a hallmark of obfuscated prompt-injection payloads invisible to human reviewers. Deploy as a hunting rule over script/scan activity.
references:
  - https://www.darkreading.com/application-security/in-the-wild-attack-ai-agents-trust-markdown
  - https://attack.mitre.org/techniques/T1027/
author: Security Arsenal
date: 2026/04/06
tags:
  - attack.defense_evasion
  - attack.t1027
logsource:
  category: process_creation
  product: windows
detection:
  selection:
    CommandLine|contains:
      - 'CLAUDE.md'
      - 'AGENTS.md'
      - 'copilot-instructions.md'
    CommandLine|contains:
      - 'Select-String'
      - 'findstr'
      - 'find '
      - 'grep'
  condition: selection
falsepositives:
  - Analyst hunting and legitimate content searches — this is a hunt/analytic rule, tune to your scanning cadence
level: low

A note on tuning: rule one is your highest-fidelity signal. AI agents legitimately execute developer-approved commands, so pair the parent/child process correlation with command-line content review — injected instructions frequently direct agents to fetch remote scripts (curl ... | sh, iex (irm ...)), read credential paths, or write to persistence locations. Those command lines are the giveaway.

KQL (Microsoft Sentinel / Defender)

KQL — Microsoft Sentinel / Defender
// Hunt: AI coding assistant processes spawning shells, downloaders, or script engines
// Covers both Windows (DeviceProcessEvents) and ingested Linux/macOS Syslog
let aiParents = dynamic(["claude.exe", "cursor.exe", "code.exe", "windsurf.exe", "node.exe", "aider", "claude", "codex"]);
let suspiciousChildren = dynamic(["powershell.exe", "pwsh.exe", "cmd.exe", "curl.exe", "wget.exe", "certutil.exe", "mshta.exe", "rundll32.exe", "bash", "sh", "python", "python3"]);
let suspiciousCmdline = dynamic(["iex", "invoke-webrequest", "irm ", "curl ", "wget ", "| sh", "| bash", "base64", ".ssh", ".aws", "credentials", ".env", "id_rsa", "nc ", "ncat", "crontab", "launchctl", "reg add"]);
DeviceProcessEvents
| where TimeGenerated > ago(7d)
| where InitiatingProcessFileName has_any (aiParents)
| where FileName has_any (suspiciousChildren)
| where ProcessCommandLine has_any (suspiciousCmdline)
| project TimeGenerated, DeviceName, AccountName,
    Agent = InitiatingProcessFileName,
    ChildProcess = FileName,
    ProcessCommandLine,
    InitiatingProcessCommandLine, SHA256, ReportId
| sort by TimeGenerated desc
;
// Companion hunt: egress connections from agent-spawned shells to non-standard destinations
DeviceNetworkEvents
| where TimeGenerated > ago(7d)
| where InitiatingProcessFileName has_any (suspiciousChildren)
| where InitiatingProcessCommandLine has_any (suspiciousCmdline)
| where RemoteUrl !has_any ("anthropic.com", "openai.com", "github.com", "githubusercontent.com", "microsoft.com", "npmjs.org", "pypi.org")
| project TimeGenerated, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, RemoteIP, RemoteUrl, RemotePort
| sort by TimeGenerated desc

Velociraptor VQL

VQL — Velociraptor
-- Hunt: Enumerate AI agent instruction files and scan for obfuscation markers
-- Flags instruction files containing HTML comments, zero-width chars, or command directives
SELECT FullPath, Size, Mtime,
       Btime,
       count(string=Hits) AS ObfuscationHits
FROM foreach(
  row={
    SELECT FullPath, Size, Mtime, Btime
    FROM glob(globs=[
      '**/CLAUDE.md',
      '**/AGENTS.md',
      '**/.cursorrules',
      '**/copilot-instructions.md',
      '**/.cursor/rules/*.mdc',
      '**/.windsurfrules'
    ], root='C:/Users')
  },
  query={
    SELECT FullPath, Size, Mtime, Btime,
           Hits
    FROM foreach(
      row={
        SELECT Content
        FROM read_file(filenames=FullPath, length=Size)
      },
      query={
        SELECT FullPath, Size, Mtime, Btime,
               Content =~ '(<!--|\\x{200B}|\\x{200C}|\\x{200D}|\\x{FEFF}|curl |wget |iex |invoke-webrequest|base64 -d|\.ssh|\.aws/credentials|rm -rf|crontab|launchctl)' AS Hits
      })
  })
WHERE ObfuscationHits > 0

Remediation / Hardening Script

PowerShell
# Security Arsenal - AI Agent Instruction File Audit & Hardening (Windows)
# Run on developer workstations / via Intune or GPO. Audit first, enforce second.

$ErrorActionPreference = 'SilentlyContinue'
$report = @()
$instructionFiles = @('CLAUDE.md','AGENTS.md','.cursorrules','copilot-instructions.md','.windsurfrules','CONVENTIONS.md')
$scanRoots = @("$env:USERPROFILE\source", "$env:USERPROFILE\repos", "$env:USERPROFILE\Documents", "$env:USERPROFILE\projects")

# --- 1. Discover all agent instruction files on the workstation ---
foreach ($root in $scanRoots) {
    if (Test-Path $root) {
        Get-ChildItem -Path $root -Recurse -Force -File | Where-Object {
            $instructionFiles -contains $_.Name -or $_.FullName -like '*\.cursor\rules\*'
        } | ForEach-Object {
            $content = Get-Content $_.FullName -Raw
            # --- 2. Scan for obfuscation / injection markers ---
            $suspicious = @()
            if ($content -match '<!--')                              { $suspicious += 'HTML_COMMENT' }
            if ($content -match "[`u{200B}`u{200C}`u{200D}`u{FEFF}]") { $suspicious += 'ZERO_WIDTH_UNICODE' }
            if ($content -match '(curl |wget |iex |Invoke-WebRequest|base64 -d|certutil)') { $suspicious += 'COMMAND_DIRECTIVE' }
            if ($content -match '(\.ssh|\.aws\\credentials|\.env|id_rsa)') { $suspicious += 'CREDENTIAL_PATH_REF' }
            $report += [PSCustomObject]@{
                Path       = $_.FullName
                Modified   = $_.LastWriteTime
                SizeKB     = [math]::Round($_.Length/1KB,2)
                Findings   = ($suspicious -join ', ')
                Risk       = if ($suspicious.Count -ge 2) {'HIGH'} elseif ($suspicious.Count -eq 1) {'REVIEW'} else {'CLEAN'}
            }
        }
    }
}

$report | Sort-Object Risk | Format-Table -AutoSize
$report | Where-Object {$_.Risk -ne 'CLEAN'} | Export-Csv "$env:TEMP\ai-instruction-audit.csv" -NoTypeInformation
Write-Host "[+] Audit complete. $($report.Count) instruction files found; $(($report | Where-Object Risk -ne 'CLEAN').Count) flagged."

# --- 3. Enable script block + process creation logging (if not already on) ---
New-Item -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -Value 1
New-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\Audit' -Force | Out-Null
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\Audit' -Name 'ProcessCreationIncludeCmdLine_Enabled' -Value 1
Write-Host "[+] Script block logging and command-line process auditing enabled."
Bash / Shell
#!/usr/bin/env bash
# Security Arsenal - AI Agent Instruction File Audit (Linux/macOS)
# Scans developer home directories for planted/obfuscated agent instruction files.

REPORT="/tmp/ai-instruction-audit-$(date +%F).txt"
echo "=== AI Agent Instruction File Audit $(date) ===" > "$REPORT"

# --- 1. Locate instruction files ---
FILES=$(find /home /Users /root -maxdepth 6 -type f \
  \( -name 'CLAUDE.md' -o -name 'AGENTS.md' -o -name '.cursorrules' \
     -o -name 'copilot-instructions.md' -o -name '.windsurfrules' \
     -o -path '*/.cursor/rules/*' \) 2>/dev/null)

# --- 2. Scan each file for injection markers ---
for f in $FILES; do
  HITS=""
  grep -qP '<!--' "$f" && HITS="$HITS HTML_COMMENT"
  grep -qP '\xE2\x80\x8B|\xE2\x80\x8C|\xEF\xBB\xBF' "$f" && HITS="$HITS ZERO_WIDTH_UNICODE"
  grep -qiP 'curl |wget |base64 -d|\.ssh|\.aws/credentials|id_rsa|crontab|launchctl' "$f" && HITS="$HITS COMMAND_OR_CRED_DIRECTIVE"
  if [ -n "$HITS" ]; then
    echo "[FLAGGED] $f | modified: $(stat -c %y "$f" 2>/dev/null || stat -f %Sm "$f") | markers:$HITS" >> "$REPORT"
    # Print offending lines for analyst review
    grep -nP '<!--|curl |wget |base64 -d' "$f" | head -20 >> "$REPORT"
  fi
done

# --- 3. Audit recent child processes of agent CLIs from shell history / audit logs ---
echo "=== Recent agent-spawned command review ===" >> "$REPORT"
if command -v ausearch >/dev/null 2>&1; then
  ausearch -ts recent -i 2>/dev/null | grep -E 'curl|wget|base64|nc ' | head -50 >> "$REPORT"
fi

echo "[+] Audit complete. Review $REPORT"
grep -c FLAGGED "$REPORT" | xargs -I{} echo "[+] {} flagged files require analyst review."

Remediation & Hardening Recommendations

There is no vendor patch for this class of attack — it is a trust-boundary design flaw. Your remediation strategy must be architectural:

  1. Enforce human-in-the-loop approval for agent tool execution. Configure every agentic tool in your environment to require explicit user confirmation before shell commands, file writes outside the workspace, or network requests. Disable any "YOLO"/auto-approve mode via managed configuration. This single control breaks the attack chain at step 3.
  2. Treat instruction files as code, not documentation. Bring CLAUDE.md, AGENTS.md, .cursor/rules/, and equivalent files under the same pull-request review, branch protection, and signed-commit requirements as source code. A one-line Markdown change should never merge without review — it is now an executable artifact.
  3. Sandbox agent execution. Run agentic coding tools inside containers or dedicated dev VMs with: no access to production cloud credentials, short-lived tokens, egress allow-listing, and no mounted SSH keys. The blast radius of a successful injection should be an ephemeral container, not a developer's identity.
  4. Constrain the agent's tool surface. Disable or scope MCP servers that grant filesystem-wide reads, arbitrary network access, or package-install capabilities. Apply least privilege to the agent exactly as you would to a junior service account.
  5. Scan for obfuscated payloads in CI. Add a pipeline check that flags instruction files containing HTML comments, zero-width Unicode, homoglyphs, or embedded command directives before merge. This catches the invisible-to-reviewer variants described above.
  6. Telemetry and detection. Deploy the Sigma/KQL content above. Ensure command-line process auditing and PowerShell script block logging are enabled on developer endpoints — agent-driven execution is invisible without them.
  7. Developer awareness. Train engineers that cloning and opening an unfamiliar repo in an AI-assisted IDE is now an execution-risk decision, equivalent to running untrusted code. git clone && open in Cursor is the new Enable Content.
  8. Vendor management. Require AI tooling vendors to document their instruction-file ingestion behavior, priority ordering between system/user/file context, and available controls for disabling auto-ingestion. Make this a procurement gate.

Incident Response Considerations

If you confirm a poisoned instruction file executed in your environment, scope the incident as you would any code-execution compromise: collect the agent's session/transcript logs (most agentic tools persist these locally), enumerate child processes of the agent process during the exposure window, rotate every credential accessible from that workstation (SSH keys, cloud tokens, .env secrets), and review git history for agent-authored commits introducing unauthorized changes. Do not assume the damage is limited to what the agent summarized on screen — injected payloads routinely instruct agents to conceal their actions.


The Bottom Line

The weaponization of Markdown instruction files marks the moment prompt injection graduated from a chat-interface nuisance to a genuine code-execution and supply-chain vector. Attackers have identified that the AI agent — trusted, tool-enabled, and auto-ingesting — is the new weakest link in the developer workflow. Defenders must respond by treating instruction files as executable artifacts, gating agent tool use behind human approval, and instrumenting agent process behavior the way we already instrument Office macros and script interpreters. The organizations that build these controls now will absorb this technique as a nuisance; those that don't will be writing incident reports about it.

Related Resources

Security Arsenal Penetration Testing Services AlertMonitor Platform Book a SOC Assessment vulnerability-management Intel Hub

Is your security operations ready?

Get a free SOC assessment or see how AlertMonitor cuts through alert noise with automated triage.