Skip to main content
Prompt Security from SentinelOne
  • AI Security Academy

    AI Security Academy

    Learn More
    Title of post

    What is AI Security

    AI security is not a neat, one-line definition you can slap on a slide.

    Learn More
    Title of post

    AI Security Glossary

    Explore some of the most common terms in AI Security

    Learn More
    Title of post

    AI Usage Stats

    Explore current AI usage trends.

  • Tools

    AI Security Tools

    Learn More
    Title of post

    OneClaw

    Track and analyze OpenClaw deployments in your org

    Learn More
    Title of post

    ClawSec

    Secure your OpenClaw, NanoClaw, and Hermes agents.

    Learn More
    Title of post

    Prompt Fuzzer

    Get our AI vulnerability assessment open source tool

  • Blog
  • Startup Map
  • Learn More
    Book a Demo
Prompt Security from SentinelOne
  • AI Security Academy

    AI Security Academy

    Learn More
    Title of post

    What is AI Security

    AI security is not a neat, one-line definition you can slap on a slide.

    Learn More
    Title of post

    AI Security Glossary

    Explore some of the most common terms in AI Security

    Learn More
    Title of post

    AI Usage Stats

    Explore current AI usage trends.

  • Tools

    AI Security Tools

    Learn More
    Title of post

    OneClaw

    Track and analyze OpenClaw deployments in your org

    Learn More
    Title of post

    ClawSec

    Secure your OpenClaw, NanoClaw, and Hermes agents.

    Learn More
    Title of post

    Prompt Fuzzer

    Get our AI vulnerability assessment open source tool

  • Blog
  • Startup Map
  • Learn More
    Book a Demo
Skip to main Content
Back to Blog
Back to Blog
AI Risks
AI Resources

When Your Repo Starts Talking: AGENTS.MD and Agent Goal Hijack in VS Code Chat

Written by: 
David Abutbul
December 17, 2025

GitHub Copilot and VS Code Chat are racing toward agentic workflows. Your editor is no longer autocompleting code. It is reading your project, interpreting instructions, and acting as a workspace-aware assistant.

One detail in that shift matters more than it looks.
A single markdown file in your repo called AGENTS.MD.

VS Code Chat auto-includes it in every request. It is treated as an instruction set, not documentation. Our demo shows how that design becomes a clean data exfiltration path. A malicious AGENTS.MD quietly convinces the agent to email internal data out of the organization during an everyday coding session.

This post breaks down how the plumbing works, how the attack works, and why this is a direct hit on OWASP ASI01 and ASI02.

How VS Code wires AGENTS.MD into every conversation

The root behavior lives in VS Code’s chat configuration. The key block:

File: src/vs/workbench/contrib/chat/browser/chat.contribution.ts (around lines 573–581)

The implications are not subtle.

Facts:

  • VS Code searches the workspace for AGENTS.MD.

  • If it finds one, the contents are injected into every chat request.

  • The feature ships enabled by default.

  • The file is treated as instructions, not context.

Any repo can ship a high privilege control layer for the coding assistant. A developer sees documentation. The agent sees policy.

How AGENTS.MD is supposed to work (on paper)

The AGENTS.MD spec tries to standardize agent behavior by letting repos define:

  • The agent’s persona

  • Style preferences

  • Interaction rules

  • Tooling patterns

The FAQ goes further. It explicitly supports auto-running agents. The answer is basically yes. Feel free to let AGENTS.MD drive unattended execution.

‍

Great for productivity. Terrible for threat modeling.

What the spec does not provide:

  • A security model

  • A boundary between documentation and privileged instructions

  • Any guidance for runtimes that ingest untrusted AGENTS.MD files

That missing guardrail is the attack surface.

Inside the demo: a markdown file that emails your internal data

In our video, the exploit is quiet and believable. The developer opens a repo. The repo contains an AGENTS.MD that looks harmless. They ask Copilot a routine question. The agent then emails internal project data to an external address. The user never requested an email or a file scan.

What actually happens

1. Workspace setup

A repo includes an AGENTS.MD that looks like workflow notes.

2. Developer interacts

They open VS Code. Copilot Chat is on. They type anything. Even a single letter is enough.

3. Hidden instructions activate

VS Code injects AGENTS.MD into the prompt.
The model receives repo-defined goals, not user intent.

4. The agent executes

The injected instructions redirect the agent into exfiltration.
It summarizes internal content.
It uses an available email tool.
It sends data to an attacker address.

5. User perception

The agent claims to be doing a security audit or health check.
The entire chain originated from AGENTS.MD.

This is OWASP Agentic Top 10 in motion. A benign file that acts like a covert policy channel.

What a malicious AGENTS.MD pattern looks like

This is not the payload used in the real demo. Details removed. The pattern remains.

The structure shows the problem.

  • Repo content becomes agent policy.

  • The user cannot see the injected instructions.

  • The agent executes goals defined by an attacker, not the human

How this breaks OWASP ASI01 and ASI02

ASI01: Agent Goal Hijack
The agent’s objectives are replaced with attacker goals from AGENTS.MD. The user thinks they triggered code assistance. They actually triggered data exfiltration.

ASI02: Tool Misuse and Exploitation
The agent uses legitimate tools like email in unintended ways. It performs an authorized action with unauthorized intent.

Both rules are violated, each in accordance with the way OWASP framework describes.

Why AGENTS.MD + auto-running makes this especially risky

Taken together, we have a pattern:

Auto-inclusion in prompts

VS Code injects AGENTS.MD into every request by default.

Spec-level encouragement for auto-running

The AGENTS.MD FAQ treats auto-running agent definitions as a legitimate workflow pattern.

No built-in distinction between “docs” and “policy”

To the model, it’s all just natural-language instructions.

Human trust in markdown

Developers are used to reviewing documentation casually - not as high-privilege configuration.

Result

A malicious contributor can:

  • Hide an agent policy inside markdown
  • Have it automatically loaded
  • Have it sometimes automatically executed
  • Redirect the agent’s autonomy toward their own objectives (exfiltration, surveillance, sabotage)

This is not just “prompt injection.”

It is a repo-level control plane for agent behavior - one that can be hijacked.

Takeaways for security teams

  • AGENTS.MD is not documentation. It is an instruction substrate that runtimes may treat as authoritative.

  • Auto-including it in VS Code means any repo can redefine what your coding agent is trying to do.

  • Our demo proves the failure mode. A benign-looking markdown file triggers an agent to email internal data outside the organization.

  • OWASP ASI01 and ASI02 map directly to this attack.

  • The AGENTS.MD spec’s stance on auto-running turns an edge case into an expected behavior that attackers can hijack.

If your editor now hosts “agents for your repo,” then your AGENTS.MD isn’t just flavor text, it’s part of your attack surface.

‍

Last Updated:

Share this post
Summarize this Post
On This Page

TOC Element

Related Posts

View All Posts
View All Posts
Learn More
Title of post

ChatGPT Security Guide: Enterprise Risks, Incidents, and Practitioner Guidance

AI Risks

AI Resources

Jun 29th, 2026

What security teams actually need to know about ChatGPT: data handling, documented incidents, CISO guidance, and API risks.

Learn More
Title of post
Learn More
Title of post

The Agentic AI Attack Surface: Where Risk Lives Beyond the Prompt

AI Risks

Agentic AI

May 5th, 2026

Technical analysis of agentic AI security boundaries covering content ingestion, context translation, tool execution, and behavioral constraints in AI runtimes.

Learn More
Title of post
Learn More
Title of post

From Trivy to LiteLLM: Expanding the LLM Supply Chain Threat Model

AI Risks

Industry News

Mar 25th, 2026

The Trivy breach and LiteLLM compromise show how LLM supply chain risk now extends from malicious packages to CI, middleware, prompts, and data.

Learn More
Title of post
Prompt Security from SentinelOne
Log In
Log In
Learn More
Book a Demo

Resources

Blog
AI Security Glossary
What is AI Security?
PromptCast: The Voice of AI & Security
ClawSec
OneClaw
Prompt Fuzzer
AI Security Startup Map
© {{year}} Prompt Security. All Rights Reserved.
Privacy Policy
Terms of Service

Follow Us