prompt-file-security.md

April 17, 2026 · View on GitHub

The Blind Spot

AI coding agents (GitHub Copilot, Claude Code, Cursor, and similar) consume configuration from markdown-based files that are auto-loaded as trusted system instructions. These files include .instructions.md, .agent.md, .prompt.md, copilot-instructions.md, AGENTS.md, and SKILL.md.

Traditional DevSecOps pipelines focus scanning on source code (SAST), dependencies (SCA), container images, infrastructure as code, and runtime applications (DAST). None of these tools inspect agent configuration files for prompt injection, data exfiltration directives, or supply chain manipulation. The result is a critical blind spot: malicious instructions can be committed to a repository, pass every CI check, and silently alter how an AI agent generates code for every developer on the team.

Agent configuration files are:

  • Checked into source control like regular code
  • Auto-consumed by AI coding agents as system-level prompts
  • Contributed via PRs from external contributors
  • Not covered by standard SAST, SCA, or secret scanning tools
  • Distributed through agent plugin marketplaces, introducing a new supply chain vector

Attack Categories

Six attack categories target agent configuration files. Each exploits the gap between what human reviewers see in a markdown file and what an AI model interprets as instructions.

#AttackTechniqueRisk
1Prompt injection via Unicode homoglyphsZero-width characters (U+200B, U+200C, U+200D), bidi overrides (U+202A-E, U+2066-9), and variation selectors (U+E0100-E01EF, the Glassworm vector) embed invisible instructions that the model reads but humans cannot seeAgent follows hidden commands invisible to code reviewers
2Hidden instructions via base64 encodingBase64-encoded payloads or markdown comments (<!-- ... -->) carry directives that bypass casual reviewMalicious behavior triggered on decode or model interpretation
3Exfiltration via embedded URLsInstructions directing the agent to include calls to external endpoints in generated code (error handlers, logging, telemetry)Sensitive data sent to attacker-controlled servers
4Tool manipulation via shell commandsHook configurations (post-test.json, lifecycle hooks) execute arbitrary shell commands; agent profiles grant access to unauthorized tools or MCP serversArbitrary code execution on developer machines
5Override patterns (system prompt overrides)Instructions that tell the agent to "ignore previous instructions," bypass safety restrictions, or override output formattingSecurity guardrails disabled, behavior altered
6MCP server hijackingAgent profiles declare mcp-server configurations connecting to attacker-controlled services; plugin marketplace entries mimic legitimate plugin namesExternal code execution, dependency confusion, data exfiltration

OWASP LLM Top 10 Alignment

These attack categories map directly to four entries in the OWASP Top 10 for LLM Applications (2025).

OWASP RiskIDRelevance to Agent Config Files
Prompt InjectionLLM01Malicious instructions placed in configuration files alter coding agent behavior. Covers both direct injection (instructions in the file itself) and indirect injection (files that cause the agent to process external untrusted content). MITRE ATLAS: AML.T0051.000, AML.T0051.001
Supply ChainLLM03Agent configuration files are part of the LLM supply chain. Compromised PRs, plugin marketplace poisoning, and dependency confusion all apply. SBOM inventories typically do not include agent instruction files
Excessive AgencyLLM06Agent profiles define tool access, MCP server connections, and autonomy levels. Overly broad configurations grant excessive functionality, permissions, or autonomy beyond what the task requires
System Prompt LeakageLLM07Agent configuration files are system prompts. If leaked, they reveal the application's security architecture, trust boundaries, and tool access patterns

Note

LLM02 (Sensitive Information Disclosure) also applies when agent configuration files inadvertently contain API keys, internal URLs, or organizational secrets.

APM as the Primary Defense

Daniel Meppiel (@danielmeppiel), creator of Microsoft's APM (Agent Package Manager), identified this gap and built content security scanning directly into APM as a first-class feature. His LinkedIn article "Scan Your Coding Agent's Configuration for Hidden Supply Chain Attacks" details the threat model. APM's apm audit and install-time scanning represent the first dedicated tooling to address this attack surface.

What APM Provides

APM (microsoft/apm, MIT license) is an open-source dependency manager for AI agents. It functions like package.json but for agent configurations: instructions, skills, prompts, agents, hooks, plugins, and MCP servers. The apm.yml manifest declares all agentic dependencies, enables transitive resolution, and supports installation from any Git host.

apm audit Severity Levels

SeverityDetections
CriticalTag characters (U+E0001-E007F), bidi overrides (U+202A-E, U+2066-9), variation selectors 17-256 (U+E0100-E01EF, the Glassworm attack vector)
WarningZero-width spaces/joiners (U+200B-D), variation selectors 1-15 (U+FE00-FE0E), bidi marks (U+200E-F, U+061C), invisible operators (U+2061-4), annotation markers (U+FFF9-B), deprecated formatting (U+206A-F), soft hyphen (U+00AD), mid-file BOM
InfoNon-breaking spaces, unusual whitespace, emoji presentation selectors (U+FE0F). ZWJ between emoji characters is context-downgraded to info

Exit Codes

CodeMeaning
0Clean, no findings
1Critical findings detected
2Warnings only

CLI Examples

# Scan all installed packages
apm audit

# Scan a specific file (works on non-APM-managed files too)
apm audit --file .github/copilot-instructions.md

# Remove dangerous characters while preserving emoji
apm audit --strip

# Preview what --strip would remove without modifying files
apm audit --strip --dry-run

Defense-in-Depth

Content security scanning runs at three points in the APM lifecycle, creating layered protection from installation through compilation.

Install-time                  Audit                        Compile-time
─────────────────────────     ─────────────────────────    ─────────────────────────
apm install                   apm audit                    apm compile
│                             │                            │
├─ Blocks compromised         ├─ On-demand scanning of     ├─ Scans compiled output
│  packages before agents     │  installed packages or     │  before writing to disk
│  can read them              │  arbitrary files            │
│                             │                            │
└─ Critical findings block    └─ Full severity reporting   └─ Final gate before
   (use --force to override)                                  agent consumption

CODEOWNERS Protection

Protect agent configuration directories with mandatory security team approval. This prevents unauthorized modifications from reaching the default branch without review.

# .github/CODEOWNERS
.github/copilot-instructions.md  @devopsabcs-engineering/security-team
agents/                          @devopsabcs-engineering/security-team
instructions/                    @devopsabcs-engineering/security-team
prompts/                         @devopsabcs-engineering/security-team
skills/                          @devopsabcs-engineering/security-team
**/AGENTS.md                     @devopsabcs-engineering/security-team
**/SKILL.md                      @devopsabcs-engineering/security-team
apm.yml                          @devopsabcs-engineering/security-team
mcp.json                         @devopsabcs-engineering/security-team

Important

CODEOWNERS enforcement requires branch protection rules that mandate PR review. Without branch protection, CODEOWNERS entries are advisory only.

CI Pipeline Scanning Checklist

Every PR that modifies agent configuration files should be scanned for the following patterns:

CheckPatternRationale
Base64 encodingStrings matching [A-Za-z0-9+/=]{40,}May contain hidden instructions decoded by the model
Unicode anomaliesZero-width characters, bidi overrides, tag characters, variation selectorsInvisible text the model reads but reviewers cannot see
Embedded URLshttp:// or https:// links to external domainsPotential exfiltration endpoints injected into generated code
Shell commandsPatterns containing &&, |, ;, backticks, $()Arbitrary code execution via hook configurations
Override patternsPhrases like "ignore previous instructions," "override," "bypass"Attempts to disable agent safety guardrails
MCP server allowlistmcp-server configurations referencing servers not on the approved listUnauthorized external service connections

CI/CD Integration with microsoft/apm-action

Add APM security scanning to your GitHub Actions pipeline using the official microsoft/apm-action:

# .github/workflows/apm-security.yml
name: APM Security Scan
on:
  pull_request:
    paths:
      - 'apm.yml'
      - 'agents/**'
      - 'instructions/**'
      - 'prompts/**'
      - 'skills/**'
      - '**/*.agent.md'
      - '**/*.instructions.md'
      - '**/*.prompt.md'
      - '**/SKILL.md'
      - '.github/copilot-instructions.md'

jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: microsoft/apm-action@v1
        with:
          command: audit

The workflow triggers on every PR that touches agent configuration files and fails the check when apm audit returns exit code 1 (critical findings).

Supply Chain Parallels

The agent configuration supply chain mirrors traditional software supply chain attacks in structure and risk.

Traditional Supply Chain AttackAgent Config Equivalent
Malicious npm packageMalicious agent plugin in a marketplace
Typosquatting package namesAgent plugin name confusion
Compromised dependency updatePR modifying copilot-instructions.md
Poisoned Docker imageAgent profile with unauthorized MCP server
Malicious GitHub ActionHook configuration executing shell commands
Dependency confusionOrganization vs. repository instruction conflicts

APM Security Domain Artifacts

The threat model described in this document is operationalized by the APM Security domain. The following framework artifacts implement the 4-engine scanning architecture:

ArtifactPathPurpose
Detector agentagents/apm-security-detector.agent.md4-engine scanner with OWASP LLM mapping
Resolver agentagents/apm-security-resolver.agent.mdAutomated remediation for all 4 engines
Instructionsinstructions/apm-security.instructions.mdScanning rules and CI gate thresholds
Scan promptprompts/apm-security-scan.prompt.mdScan workflow entry point
Fix promptprompts/apm-security-fix.prompt.mdRemediation workflow entry point
Domain skillskills/apm-security-scan/SKILL.mdComprehensive domain knowledge package
GH Actions samplesamples/github-actions/apm-security-scan.ymlReference CI pipeline
ADO pipeline samplesamples/azure-devops/apm-security-pipeline.ymlReference ADO pipeline
DIY guidedocs/DIY-APM-Security-Domain.mdStep-by-step domain build guide

References