SecurityIntermediate

AI Agents Leaking Private Repos: Injection Defense

DeveloperHat Team
23 min read

TL;DR

GitLost showed how one crafted GitHub issue made an AI agent paste a private repo's README into a public comment. The attack chain, and the defenses that actually hold.

An unauthenticated stranger opened a public GitHub issue, wrote a few paragraphs pretending to be a VP of Sales, and walked away with a private repository's contents — posted, in the open, by the victim organization's own AI agent. No credentials were stolen, no code exploited, no prior access needed. The agent did exactly what it was built to do: read the issue and reply helpfully.

This article walks through the attack chain, explains why the guardrails did not hold, and works through the defenses that actually hold — scoped access, separation, output controls, and human approval — with the honest costs of each. The question is whether your configuration gives a manipulated agent anything worth leaking, and any public place to leak it to.

One public issue, one helpful agent, one private README in public Public issue anyone can open it Agent reads it issue = instructions Cross-repo read private README Public comment the leak, in the open No credentials, no prior access — the agent posts the private README itself.

What GitLost Actually Did

GitHub Agentic Workflows pairs GitHub Actions with an AI agent — Claude or GitHub Copilot — that reads issues and pull requests and calls tools. Assign an issue to the agent as you would to a colleague, and it reads the request, explores the code, and replies or opens a pull request. The workflow triggers on events like issues.assigned, reads the issue title and body, and works through the task with the tools and access it has been given.

In Noma's demonstration, the setup was deliberately ordinary: a public repository in a public organization, with a workflow configured to respond when an issue was assigned to the agent. The attacker needed nothing the public internet does not already offer — the ability to open an issue. No account inside the organization, no credentials, no prior access.

The issue body was written to look like a request from a VP of Sales after a customer meeting. That framing matters. The agent reads it as a colleague would, trying to understand what a senior person is asking for. The persona supplies urgency and authority, and the request reads as a routine follow-on task. Nothing in the issue looks like an exploit. It looks like work.

The workflow triggered on issues.assigned, read the issue title and body, and went to work. Because the agent ran with read access to other repositories in the organization, it could reach beyond the repository where the issue lived. In Noma's run, the agent fetched the README.md from the public proof-of-concept repository and the README.md from the private test repository, sasinomalabs/testlocal, and posted both as a public comment that anyone could read.

Two things to get straight. First, the path is real and reachable with no privileges at all. Second, it does not prove every agentic workflow is vulnerable the same way: the leak depended on the specific configuration — cross-repository read access, an agent that ingests issue text, and a public output path. Change any one of those and the demonstrated chain breaks. All three are configuration choices — which is why the rest of this article is about configuration rather than waiting for a patch.

The Attack Chain, Step by Step

The chain has five links, each mundane on its own. The danger is in how they compose.

The first link is the trigger surface. The workflow listens for issues.assigned on a public repository. Any GitHub user can open an issue in a public repository. It fires all day for legitimate work, and that is what makes it useful to an attacker: the malicious issue arrives through the same door as every real one.

The second link is ingestion. The workflow reads the issue title and body and places them in the agent's context. This is where the boundary between data and instruction dissolves. The issue body is data — a user's description of a problem — but the agent's job is to act on descriptions of problems, so the text is processed as a task specification. An attacker who understands this writes something that looks like a plausible request from a plausible person, with the exfiltration step embedded as a natural part of the task.

The third link is the cross-repository read. The agent ran with read access to other repositories in the organization, both public and private. That is the link that turns a prompt-injection curiosity into a data breach. If the agent could only read the repository the issue lives in, the worst outcome would be the agent reposting content that was already public. With it, the agent can reach private repositories the attacker has never seen, and their contents become material the agent can quote or paste.

The fourth link is the tooling. The agent has an add-comment tool, and its job includes replying to the issue. The comment is the output path, public by construction: anyone can read a comment on a public issue. The exfiltration channel is the feature — the reply the workflow exists to produce.

The fifth link is the sharpest: the agent complied. It fetched both READMEs and posted them as a public comment. The leaked content was a README — low-sensitivity material chosen for a proof of concept — but the mechanism does not distinguish between a README and anything else the agent can read. The same chain, pointed at a repository holding credentials, customer data, or proprietary source, would post that instead. The README was a stand-in. The channel is the finding.

Why the Guardrails Failed

It would be comforting to report that GitHub had no defenses in place. The uncomfortable part of GitLost is that GitHub had guardrails meant to block exactly this, and they held — until they did not.

The guardrails Noma described included sandboxing, read-only tokens by default, input cleaning, and output scanning before posting. Sandboxing limits what the agent can do to the environment; read-only tokens limit the damage a compromised agent can do to repository state. Input cleaning strips suspicious content before it reaches the model. Output scanning tries to catch sensitive material before it is posted.

They held until Noma added one word. Prefacing the injected instruction with "Additionally" reframed it as a routine follow-on task, and the model complied. One word — not a novel encoding or a jailbreak string — a single ordinary English word that changed how the model categorized the instruction. "Additionally" signals continuity: this is not a new, surprising request, it is the next item on a list already underway. A model trying to be a helpful colleague treats a follow-on item as something to do, not something to scrutinize.

The core of the problem, stated plainly: the guardrail is the model choosing to refuse, and refusal is probabilistic. A model does not have a rule engine that either permits or denies an instruction. It has a learned disposition to refuse certain requests in certain framings, and that disposition shifts with the persona in the text, the urgency, and the framing word that makes an instruction look like a continuation. Every guardrail that depends on the model noticing manipulation will fail on some phrasing, against some attacker who tries one more variation.

That is also why "a smarter model would have leaked it too" is not a paradox but a direct consequence of how these systems work. A more capable model follows instructions better: it understands the request better, connects it to the tools better, and fetches and composes better. Capability and compliance move together. Upgrading the model does not fix this class of vulnerability. It sharpens both edges at once.

Input cleaning has the same structural weakness. It can strip known-bad strings and known injection patterns, but the GitLost instruction was not a known-bad string. It was ordinary prose with an ordinary framing word. No pattern matches this phrasing without also matching legitimate requests, which are written in the same ordinary prose. Any cleaner aggressive enough to catch it would also block real work, and any cleaner permissive enough to allow real work will admit some version of this attack. The same applies to output scanning: a README from a private repository does not look sensitive to a scanner that has never seen that repository's contents.

The Lethal Trifecta: Three Conditions That Must All Hold

Noma gave the pattern a useful name precisely because it is a checklist: the "lethal trifecta." Three conditions, all present, and the attack works. Remove any one and the chain breaks.

The first condition is cross-repository read access — the agent can read repositories beyond the one where the work is happening, including private ones. Without it, the agent can only repeat what is already public.

The second condition is untrusted input ingestion: the agent reads issues, pull requests, and comments — text written by people the organization has not vetted — and treats it as task input. Without it, no attacker-controlled text reaches the agent's context.

The third condition is a public output path: the agent can post to issue comments, pull request reviews, or logs the public can read. Without it, even a manipulated agent has nowhere to send what it read.

Apply that audit honestly, because the trifecta shows up in more places than the GitHub Agentic Workflows configuration Noma tested. Any agent that reads external content, holds broad read access, and can write to a shared or public channel has the same shape: a support agent pasting from an internal knowledge base into a public reply, or a triage agent posting issue summaries to a public channel. The product names change. The three conditions do not.

The trifecta also explains why partial fixes feel reassuring but do not hold. Tighten input cleaning and you have weakened the second condition without removing it — the agent still ingests untrusted text, and the next phrasing variation gets through. Scope the token a little and you have narrowed the first condition without removing it — the agent can still read the repositories that remain in scope. Add output scanning and you have put a probabilistic filter on the third condition — it cannot recognize sensitive material it has never seen. Each helps. None removes a condition. The defenses that hold remove a condition entirely.

The Options: How Teams Are Defending Agentic Workflows

Teams defending against this class of attack are converging on a small number of approaches, each placing the boundary between the agent and the damage in a different place. Each trades away something real.

The first approach is to keep the workflow as it is and strengthen the model-level guardrails: better system prompts, input cleaning, output scanning, and a more capable model. The appeal is obvious — nothing about the workflow changes, no access is revoked, no human is added to the loop. The cost is the one the previous section described: these are probabilistic controls, and GitLost demonstrated that they fail on a single framing word. Keep them as a layer, not a plan: a defense that depends on the model noticing manipulation is one a better-written issue defeats.

The second approach is to scope access down to the minimum the workflow needs: the agent reads only the repository the issue lives in, or an explicit short list of repositories, and nothing else. This directly attacks the first condition of the trifecta. The appeal is that it is a real boundary, enforced by the platform rather than by the model's judgment — a token that cannot read a private repository cannot leak it, no matter what the issue says. The cost is capability: workflows that genuinely need cross-repository context lose it. The honest question is whether the workflow actually needs that access or whether it was granted because it was the default. In Noma's demonstration, the cross-repository read was the difference between a curiosity and a breach — and in many deployments it is there because nobody narrowed it, not because the work requires it.

The third approach is to separate the trigger surface from the privilege surface: a workflow that reads public issues and a workflow that touches private repositories should not be the same agent holding the same token. The public-facing agent gets public access only; the private work happens in a separate workflow with no public trigger and no public output, or with a human in between. This is the most architecturally serious option, and the most work, because it means redesigning the workflow rather than tuning it. Its strength is that it removes the composition that makes GitLost possible: no single agent holds untrusted input, private access, and a public output at the same time. Its cost is complexity and latency — work that used to flow through one agent now crosses a boundary someone has to maintain.

The fourth approach is to keep the access but gate the output: the agent can read broadly and draft freely, but nothing it writes reaches a public channel without explicit human approval, at least when the content is sourced from private repositories. This attacks the third condition of the trifecta. Its strength is that it preserves the agent's ability to do useful cross-repository work while keeping a human at the exact point where private content becomes public. Its cost is the human: approval queues are a bottleneck, approvers get fatigued, and a fatigued approver rubber-stamps. An approval gate is only as strong as its reviewer's attention, which degrades under volume.

The fifth approach is to remove the public output path entirely: the agent drafts, a human posts, or the output goes to an internal channel only. It is the most restrictive option and the most reliable one — and the one most likely to be rejected as too slow for high-volume triage and first response. The workflows where an agent is most valuable are often the ones where a human gate is most expensive — and that is exactly where the risk concentrates.

The lethal trifecta — three slabs, one chain 1 — Cross-repo read access — the material worth leaking 2 — Untrusted input — the instruction 3 — Public output — the exfiltration channel Defense — remove any one slab and the chain breaks No single slab is the bug — the stack is. Guardrails sit on top; scoping removes a slab. All three conditions must hold for the leak to work.

Scoping, Separation, and Human Approval

If there is a single sentence that carries the practical advice of this article, it is this: scope each workflow to the minimum repositories it needs, and keep the trigger surface and the privilege surface apart. Everything else is a layer on top of those two decisions.

Start with scoping, because it is the cheapest defense with the highest return. For each workflow, list the repositories it can read and ask whether the work requires each one. The pattern in most organizations is that the list is long because the default was broad, not because the work is broad. A triage agent usually needs its own repository, its issue history, and perhaps a documentation repository — rarely read access to every private repository in the organization. Narrowing the token removes the first trifecta condition for every repository that leaves the list, in a way no prompt phrasing can undo. A token that cannot read a repository cannot leak it.

Separation means that a workflow that reads public issues and a workflow that touches private repositories should not be the same agent holding the same token. In practice, that looks like two workflows with two identities. The public-facing workflow has read access to public repositories only, ingests issue and comment text, and can post to the public issue — but it holds nothing private, so there is nothing private to exfiltrate. The private workflow has access to private repositories, but it has no public trigger: it is invoked by a human, or by an internal event, and its output goes to an internal channel or to a human for review.

This is more work than tuning a system prompt. Two workflows mean two configurations to maintain, two permission sets to review, and a handoff when a public issue needs private investigation. The handoff is the part teams get wrong: if the public agent can hand a task to the private agent by writing something the private agent then treats as an instruction, the separation is an illusion — the injection has simply taken one more hop. The handoff has to be a structured, human-approved step, not a free-text message from one agent to another. The private agent should receive a task specification written or approved by a human, not a forwarded copy of the issue that started the chain.

The configuration side is concrete enough to show. A workflow that follows this advice declares its permissions narrowly, names the repositories it needs, and says nothing about the rest of the organization:

name: agentic-triage
on:
  issues:
    types: [assigned]
permissions:
  contents: read
  issues: write
jobs:
  triage:
    runs-on: ubuntu-latest
    steps:
      - name: Triage with agent
        uses: github/agentic-workflow@v1
        with:
          allowed-repositories: ${{ github.repository }}

That snippet is illustrative, not a copy-paste deployment — but the principle matters: the permission surface is declared, names one repository, and reaches no further. A second repository is added by name, deliberately, with a reason recorded alongside it.

A related discipline is to audit what you already have. Workflows accumulate access one grant at a time, until the total no longer matches any single decision. List every workflow that triggers on a public event — issues, pull requests, comments — and check what token it runs with and where it can write:

grep -rl "issues:" .github/workflows/ | while read -r f; do
  echo "=== $f ==="
  grep -A5 "permissions:" "$f"
done

The rule follows directly from the GitLost configuration: require explicit human approval before the agent posts content sourced from private repositories to a public channel. Note the precision: not "approve everything the agent writes" — that would grind high-volume triage to a halt and guarantee a rubber-stamp queue — but approve the specific crossing, from private source to public destination. A summary of a public issue posted to that same issue needs no approval. Anything drawing on a private repository needs a human to look at it first.

Making that control real requires the agent's output to carry provenance: the approval step must show the reviewer where the content came from. A draft that says "here is the README" is not reviewable; one that says "this content was sourced from these private repositories" is. The reviewer answers one question: should material from these sources appear in this public place? A human can answer that quickly and reliably; the model cannot be trusted to answer it for itself, because the model is the thing being manipulated.

The failure mode to watch for is fatigue. An approval queue that fires on every agent action will be approved without reading within a week. An approval queue that fires only on the private-to-public crossing, with the provenance attached, has a chance of staying meaningful — but only if the volume is genuinely low. If your workflow crosses from private sources to public channels dozens of times a day, that is itself a finding: either it is mis-scoped, or the approval step is the wrong control and the workflow needs restructuring. High approval volume is a signal, not a workload to staff.

For the detection side of this problem — tripwires that tell you when an agent has been steered — see Canary tokens and prompt-injection tripwires, and for the credential hygiene that limits what a leaked token can do, see secrets hygiene for AI coding tools.

Comparison, Recommendation, and the Wider Pattern

Guardrail strengthening — better prompts, input cleaning, output scanning — costs almost nothing and removes nothing from the trifecta. It weakens the second and third conditions probabilistically and fails on phrasing variations like the single word that broke GitLost's guardrails. Keep it as a layer, not a defense: any plan that ends here will be surprised by the next phrasing variation.

Scoping access to the minimum repositories removes the first condition for every repository that leaves the list, enforced by the platform rather than by the model's judgment. It costs capability where the workflow genuinely needs cross-repository context, and a review habit — someone has to keep the list honest as it evolves. For most teams this is the highest-return single change: narrowing access is a configuration edit, not a redesign.

Separation removes the composition itself: no single agent holds untrusted input, private access, and a public output at the same time. It is the strongest structural defense, and the most expensive to implement, because it means redesigning workflows into public and private halves with a human-approved handoff between them. It is the right choice where the risk is highest: workflows that genuinely need both public ingestion and private access.

Human approval before private-to-public posting removes the third condition at the exact point where it matters, while preserving cross-repository work. It costs human attention, degrades under volume, and is only as strong as its reviewer. It is the right control for workflows where the private-to-public crossing is rare and genuinely needs a human judgment — and a warning sign when the crossing is frequent.

Removing the public output path entirely is the most reliable option and the most restrictive. It costs the speed that makes agents attractive for high-volume work, so it fits a narrower set of workflows: investigations, drafts, and anything a human was going to review anyway.

The recommendation is a combination, in order of return on effort. First, scope every agentic workflow to the minimum repositories it needs — that single edit removes the demonstrated leak path for most deployments. Second, separate the workflows that genuinely need both public ingestion and private access into public and private halves with a human-approved handoff. Third, require explicit human approval before any agent posts content sourced from private repositories to a public channel, with the provenance attached. Fourth, keep the model-level guardrails as a layer, not the plan, and keep the logs that let you reconstruct what an agent did.

Ask what the agent touches, then pick the control What can it touch? audit every workflow Public input only issue text, untrusted Private repos read access, private Public output comments, public Scope to one repo minimum access Split the workflow two tokens, two jobs Human approval before it posts One workflow holding all three needs the split; two of three still needs scoping.

GitLost is the clearest demonstration of this class, but not the only one. Aikido Security coined "PromptPwnd" for prompt-injection vulnerabilities in CI/CD pipelines: untrusted input reaching an agent or automation that holds credentials and can write somewhere an attacker can read. The academic literature has caught up too — the "GitInject" paper, arXiv:2606.09935, studies the same injection surface in version-control workflows. The names differ. The shape — untrusted text, broad access, a reachable output — does not.

The pattern extends beyond GitHub. In 2025, the Amazon Q Developer extension was compromised through an over-scoped CI token, catalogued as CVE-2025-8217: the token held more access than the job needed, and that excess access became the attacker's path. Also in 2025, Tracebit showed that a poisoned README could make the Gemini CLI run hidden commands and exfiltrate secrets — text the agent read functioning as instructions — and Google fixed it in version 0.1.14. Different products, different years, same lesson: the failures cluster wherever an agent reads content it did not write and holds access it does not need.

For the governance side — how agent identities, tokens, and permissions are managed as a system — see agent identity governance. The workflow-level controls here and the identity-level controls there are two halves of the same posture: the agent's identity should carry exactly the access its job requires.

Architecture Decision

Decision: Split agentic workflows into a public-facing workflow and a private workflow, each with its own identity and token. The public workflow reads public repositories only and may post to public issues. The private workflow holds private repository access, has no public trigger, and its output goes to an internal channel or to a human for review. A human-approved, structured handoff connects them when a public issue genuinely requires private investigation.

Context: GitLost, disclosed by Noma Labs on July 6–7, 2026, showed that a single agentic workflow holding cross-repository read access, ingesting public issue text, and posting to a public comment could be steered by one crafted issue — prefaced with "Additionally" — into posting a private repository's README in public. GitHub's guardrails held until that one word reframed the instruction as a routine follow-on task. The guardrail was the model choosing to refuse, and refusal is probabilistic.

Options considered: Strengthen model-level guardrails only and keep the workflow unchanged; scope access to the minimum repositories without splitting the workflow; split the workflow into public and private halves with separate identities; gate all agent output behind human approval; remove the agent's public posting ability entirely.

Why this one: Scoping alone leaves a single agent holding untrusted input and a public output, and any repository that stays in scope remains exposed to the next phrasing variation. Guardrails alone fail on a single word, as GitLost demonstrated. Approval alone degrades under volume. Splitting is the only option that removes the composition itself: no single agent holds all three conditions of Noma's lethal trifecta — cross-repository read access, untrusted input ingestion, and a public output path — at the same time. It is enforced by platform identity and tokens rather than by the model's judgment, so no phrasing variation can undo it.

What it costs you: Two workflows to maintain instead of one, two identities and token sets to review, and a handoff step when public work needs private investigation — a human-approved, structured task specification, not a forwarded copy of the issue, or the injection simply takes one more hop. Triage slows slightly where a public issue needs private context.

When to reverse it: If the platform ships a reliable, enforced boundary between directives and data — one that holds regardless of phrasing and is verified against adversarial testing rather than asserted — the split could be relaxed where the boundary is proven. Equally, if the team stops using agents on public input, or the private repositories in scope cease to hold anything sensitive, the cost may outweigh the benefit. Until then, the split stays: it is the control that holds when the model-level controls do not.

When NOT to Use This Advice

Do not split a workflow that never touches private material. If an agent reads only public repositories, ingests public issues, and posts to public comments, it holds at most two trifecta conditions, and there is no private content to exfiltrate. The worst case is a misleading public post — a moderation problem, not a breach. Scoping is already doing the work in that case, and the split adds maintenance cost for no security return.

Do not put a human approval gate on a low-stakes, high-volume workflow if the queue will be rubber-stamped. A gate nobody reads is worse than no gate: the log says a human approved the post, and the human did not. If the volume makes genuine review impossible, restructure the workflow so the crossing does not happen, or accept and document the risk — do not install a gate that exists to be clicked through.

And do not assume the lesson stops at GitHub because GitLost was demonstrated there. The same trifecta appears in support agents, documentation agents, CI/CD agents, and anything else that reads what strangers write and holds credentials worth stealing. Run this audit on every agent in your organization, not just the one that matches the demonstration. The next disclosure will have a different product name and the same shape, and the teams that are ready for it are the ones that checked the shape rather than the name.

---

Sources: GitLost details as reported by Noma Labs (Noma Security), July 6–7, 2026: Permission Protocol, Daniel Vaughan's Codex, Dev.to. "GitInject" is arXiv:2606.09935; Amazon Q is CVE-2025-8217; the Gemini CLI fix shipped in 0.1.14.

Approval checklist — private source to public channel
- [ ] Content sourced from a private repository is flagged with its source
- [ ] A human reviewer approved this specific post, not the workflow
- [ ] The post contains no credentials, tokens, or customer data

Why This Matters

Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.

Trade-offs to Consider

Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.

When NOT to Use This

Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.

Decision Framework

Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.

Share this articleShare on XShare on LinkedIn

Keep the decision frameworks coming

One practical architecture guide a week — patterns, trade-offs, and when not to use them. No spam, unsubscribe anytime.