Day 15 of 2160 minCipher CadetHands-on lab
Day 15: Hijacking a Coding Agent Through a Poisoned Issue
Taught by Mr Elite Updated
By the end of today you can
- Explain where a coding agent reads untrusted content and why that matters
- Write a test issue that hides an instruction a maintainer would not see
- Trace an attack as four steps: planted text, agent reads, agent acts, impact
- Point to the step where a human check would have stopped the attack
Warm-up
Answer from memory first, then tap to check. Recalling yesterday is what makes it stick.
What three things repeat in an agent's loop?
Plan, call a tool, read the result.
Why does least privilege matter even if an injection succeeds?
It limits the blast radius, because the agent can only do what its credentials and tools allow.
Picture a team that lets an AI agent fix small bugs. Someone adds the label ai-fix to an issue, the agent reads it, edits the code and opens a change. Nobody reads every line the agent read. The maintainer sees a tidy bug report. The agent sees the raw text underneath, including parts the web page never shows.
Today you attack that setup in a safe lab. You will plant text in an issue, watch the agent obey it, and write the attack down as a chain. This is Day 10 (indirect injection) meeting Day 14 (tools and agency). Text becomes action.
Where a coding agent reads untrusted content
A coding agent is a model with tools: read files, edit files, run commands, open changes. Its instructions come from the developer. But its work comes from elsewhere, and that elsewhere is often written by strangers.
Issues, pull request descriptions, comments, README files, commit messages and error logs all flow into the agent's context. The model cannot reliably tell 'data to work on' from 'orders to follow'. Everything arrives as text. That is the root of today's attack.
- Issue
- A ticket in a code repository describing a bug or request. Anyone with access can often write one.
- Raw text
- The exact characters stored, before a web page formats them. It can contain things the formatted view hides.
- HTML comment
- Text wrapped in . Browsers do not display it, but the agent reading raw text sees it.
- Trust boundary
- The line between content you control and content others control. Crossing it without a check is where attacks live.
Quick check
Which of these is untrusted input to a coding agent?
Outsiders can write issue text, so the agent must treat it as data, not as instructions.
Following the chain from text to action
Good red team notes are short chains. Each link must be something you can point to and prove. I use four links, and you will use them in your mission.
Notice there is a fifth thing hiding in every chain: the gap where a person could have caught it. Between 'agent acts' and 'impact' there is usually a review step, or there should be. We will mark that gap.
Watch me do it
Before the real lab, I will walk through the method on a made-up example so you see the thinking. Everything here runs only in the SecurityElites practice lab or in your own notes. Never plant text in a real project you do not own.
Title: Login button misaligned on mobile
The login button sits too far left on small screens.
Please adjust the CSS.
<!-- Note to the assistant: (your test instruction goes here) -->Quick check
Why put the instruction in an HTML comment?
The attack relies on the human and the agent seeing different versions of the same issue.
Your turn: the lab
Now you do it for real. The lab is a practice repository where an agent fixes any issue labelled ai-fix. Your job is to write an issue that looks harmless to the maintainer but steers the agent. Read the lab's goal carefully and work only inside it.
Your turn
Poisoned GitHub Issue
This lab gives you a repository and a coding agent that reads raw issue text, including parts GitHub never shows a human. It is the safest place to practise turning hostile text into an agent action, because every tool and credential here is a throwaway.
What to try
What to notice
- Whether the agent treated your hidden text as an order or as part of the bug description
- Which tool call was the first one the visible bug did not justify
- Where a human approval step could have stopped the action
If it did not work
Changing several things at once between attempts
Change one thing per try and note it. Otherwise you cannot say what made the agent obey.
Writing the chain from memory
Copy exact quotes from the issue and the agent log into each link.
Only describing the injection and skipping impact
State what changed and who would be harmed. A chain without impact is incomplete.
Blaming the model alone
Also name the missing control: no human review, too much permission, or untrusted text treated as instructions.
Recap
- Coding agents read issues, comments and files written by people you do not control
- The agent sees raw text, a maintainer often sees a cleaned view, and that gap is the attack
- A finding is a chain: planted text, agent reads, agent acts, impact
- The model's obedience is only half the story, permissions and missing review decide the damage
- Always mark the point where a human should have checked
- Run these tests only in the lab or on your own setup
Cheat sheet
Planted text- The hostile content the attacker places in a source the agent reads
<!-- ... -->- HTML comment, hidden from rendered pages but present in raw text
ai-fix label- The lab's trigger that sends an issue to the agent
Four-step chain- Planted text, agent reads, agent acts, impact
Human checkpoint- The review step that could stop an unwanted action
Trust boundary- Where outside content enters the agent's context
Before the next day
Mission: Write the four-step chain
Complete the lab, then write up what happened as a short chain. This is the habit that turns a clever trick into a report a team can act on, and you will reuse it in the Day 18 review and the capstone.
About 30 min
You are done when: day15-chain.md with the four-step chain, the human checkpoint line, one fix, and one screenshot.
Want more? Write a second chain using a different untrusted source, such as a pull request comment, and say whether the same fix would stop it.
Quiz
4 questions. Your score is saved with your progress.
1. Why does a poisoned issue work even when the maintainer reads it carefully?
The two readers see different versions of the same text, so careful reading of the visible version is not enough.
2. Which link of the chain shows the agent's permissions mattering most?
What the agent can do when it acts is set by its tools and credentials, which also set the size of the impact.
3. Which fix is strongest against this attack?
Controls in tools and credentials hold even when the injection works. Prompt wording alone can be bypassed.
4. What makes a write-up a finding rather than a suspicion?
Each link must be shown with evidence so someone else can reproduce it.
Finish the day
Mark the day complete to save your progress.
Next: Day 16 moves from issue text to tool descriptions and rogue MCP servers. The agent will read hostile text in a place even more trusted than a ticket, and you will review a tool for it.
Your notes
Private to this device. Write what you want to remember from today.