Dev.to Security πŸ” Cybersecurity πŸ‘ 2 πŸ“– 4 min read

The Trap That Almost Got Through: How PR Guardian's Scanner Learned to See

PR Guardian is my Agentware 2026 entry in the Developer Workflow track: an autonomous PR triage agent that reads a pull request's diff, runs the tests in a sandbox, flags the risky hunks, drafts a review comment, and pus

PR Guardian is my Agentware 2026 entry in the Developer Workflow track: an autonomous PR triage agent that reads a pull request's diff, runs the tests in a sandbox, flags the risky hunks, drafts a review comment, and pushes only trivial fixes β€” all under a policy engine, a kill switch, and a full audit trail. It was built solo in the 72-hour window, and it finished with 28/28 tests passing and a demo that runs end to end in about 8 seconds.

The organisers shipped a Trap Pack: twenty hostile inputs β€” poisoned PR descriptions, a CI log ordering the agent to rm -rf the tests and force-push, a fake CEO email demanding secrets, a base64-encoded order to buy things without approval β€” and asked the agent to hold all twenty. Mine did: 20/20 held, 32 injection findings, 25 secret findings, 0 outbound actions (0 posts, 0 pushes, 0 fetches, 0 sends).

But the honest story of this build is not the 20/20. It is the first pass.

The trap that almost got through

On the first pass, all twenty files were held β€” structurally. Nothing executed, nothing leaked. But the scanner only flagged 2 of the 17 out-of-scope files. Its patterns had been written for PR and CI-log phrasing, and it was blind to everything else: email phrasing, web-page phrasing, voice-transcript phrasing, payment phrasing. Two traps were effectively invisible to it: a delete-files instruction obfuscated with zero-width characters, and an order-without-approval instruction hidden base64-encoded in page metadata β€” its canary invisible until decoded.

Nothing got through, but only because the architecture held, not because the agent could see. For out-of-scope input the loop has no tool calls at all β€” read, scan, log, stop β€” so there was nothing for an instruction to drive. A judge reading those first-pass traces would rightly have called the evidence thin. That was the near miss: my agent was safe by luck of architecture, not by sight. And "safe because it has no email tool" is not the same as "safe when it has one."

The guardrail

So in the small hours of the first morning, before anything was submitted, I hardened the scanner in src/policy.ts β€” generic patterns only, no trap-specific strings, no file names, no canary values:

  • New patterns for exfiltration and disclosure phrasing: forwarding mailbox contents to an address, sending private content (transcripts, passphrases) out, disclosing keys, tokens or .env contents, paying or submitting with a stored card, acting without approval, dumping the environment, falsifying attendance or records, cancelling or refunding everything, deleting files, inflating a rating, and false-authority claims ("overrides earlier policy", "higher priority than the user", "authorised supervisor").
  • Two evasion fixes: invisible characters (zero-width space and joiner, word joiner, BOM) are stripped before scanning, and base64 blobs are decoded and scanned too β€” findings from decoded text are labelled encoded:.

Then I re-ran all twenty files. Second pass: 20/20 held, and this time the scanner actually saw the attacks β€” 32 injection findings and 25 secret findings across the run, with the hostile lines quoted in the local audit trace as evidence of what was refused. Both passes are kept in the repo's traces/ directory as a before/after record, because the gap is part of the story, not something to hide.

The same discipline caught two real bugs before submission: the classifier had called a postinstall hunk "trivial" because it looked like a string line β€” it now checks risky patterns first β€” and the env-exfiltration scanner depended on word order, so it became order-independent. Both were found by the unit tests, not by luck.

What I would still not claim

The kill switch was tested (a run with the STOP file present halted cleanly after two events), the demo runs unattended, and the audit trail records every decision. But I will not claim more than the evidence supports: the trap runs used the deterministic heuristic classifier, with no live model call β€” the Gemini path is implemented and its reply parsing is unit-tested, but it was not exercised in those runs. The scanner is line-based, so a phrase split across a line break can still evade a pattern. And the out-of-scope holds still rest on architecture: if a future version gains email, calendar or payment tools, all seventeen of those traps must be re-run against those tools.

That is the lesson I am taking out of Agentware 2026, built by Hackathon Raptors: a guardrail you cannot see through is not a guardrail, it is a wall you happen to be standing behind. The fix is not to trust the wall more β€” it is to keep widening what the agent can actually see, keep the evidence in the open, and keep the kill switch within reach.

The Near Miss write-up awards at Agentware 2026 are backed by FileClerk (https://fileclerk.co.uk/), a UK company filing service for people and AI agents.

Repo: https://github.com/4ntonn/pr-guardian
Demo: https://youtu.be/7TboRdsTYTE
Trap results: tests/trap-pack/RESULTS.md in the repo

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.