Basar Tuncay

Notes ·

I had my own security tool audited before opening it. It took six reviews.

Firebreak is a gateway that sits between an AI agent and its MCP servers. It records what the servers return as untrusted, and when the agent later tries to send something to an address that only ever appeared in that untrusted output, a deterministic rule stops the call and asks a person. No model takes part in the decision.

It was already on npm. Before putting the source back on GitHub I set a rule for myself: an independent reviewer, a separate AI agent that did not write the code, has to say "open", on the exact tree, or it stays closed. The reviewer was allowed to run the code. Whoever fixed a finding was never the one who checked the fix.

It took six reviews. The first five said no. The sixth said no five more times, each time on a smaller point, before it said yes. The source is public again since 1 December 2026. This is what each review found.

Round 1: the documentation promised more than the code did

No remote code execution, no hole in the local dashboard. But several security claims in the README and the threat model were not true as written, and three were real bypasses:

  • An agent with a shell could approve its own calls. firebreak approve <id> needed no token and no terminal, and the approval id was printed in the text the agent reads. The project's own security policy listed "approve a call without the dashboard token" as a vulnerability.
  • The recipient allowlist could be bypassed. With @corp.com allowlisted, a value such as "bob@corp.com"@evil.net counted as allowlisted, because the check looked at the address it recognised and only loosely at what was left over.
  • Tool descriptions were not tracked. An address planted in a tool's description, rather than in a tool's result, was invisible to the rule that is supposed to catch exactly that.
  • A tool named in camelCase (sendEmail) matched none of the name patterns, so a server could declare it read-only and skip three rules.

Round 2: one fix opened a new hole

The second reviewer confirmed most fixes and found that one of them had made things worse. Splitting camelCase names meant that findAndReplace was now judged by its first word and classified as a read. Before the fix it had been "unknown", which counts as a write. A stricter-looking change had made the tool laxer.

The allowlist was still open, to a more realistic value this time: bob@corp.com.еvil.net, where the е is Cyrillic. An attacker who registers that domain receives the mail. And recording every word of a tool description as untrusted caused the opposite problem: an argument like target: "main" now needed approval because a description said "e.g. main". Approval prompts that fire on harmless calls teach people to click approve.

Round 3: results that arrive by another door

The third reviewer ran the proxy and showed three things:

  • Under the newer MCP protocol a tool call can run as a task whose output comes back later through a different method. That output was never recorded. The same text that was blocked as a plain result went through when delivered as a task result.
  • A line from the server that is not valid JSON was passed to the client unchanged, skipping every check.
  • One very large result could freeze the proxy for minutes, because trimming the internal archive was quadratic.

The fix for the first one was a change of default: every answer the server gives is recorded as untrusted unless there is a reason to treat it differently. Listing the methods to watch had been the mistake.

Round 4: memory is a security boundary

The fourth reviewer accepted those fixes and went after the limits I had added. A cap on how much is remembered per result is also a way to make the tool forget:

  • Put the attacker's address after 20,000 other addresses in one page. The proxy that read the page noticed and became strict, but a second proxy for another server did not, so the mail went out through it.
  • Or flood the archive with ordinary-looking reads until the injected address is evicted, then send.

Both were closed the same way: when the gateway loses provenance for any reason, it says so, tells the other proxies, and from then on asks a person before any write to a destination that is not on the allowlist.

Round 5: the code held, the documentation did not

The fifth reviewer found no way around the checks. It still said no, because two sentences in the documentation were false: one said the strict state ends when the client restarts (it did not, with a fixed group name), and one overstated how short names are tracked. I had said the documentation counts as part of the tool, so that was a no.

Round 6: one class of bug, six times

The fix for round 5 touched how two proxies share what they have read. The sixth reviewer accepted that change and then went after the sharing itself. When one proxy reads a very long result, a second proxy for another server only sees a copy: the first and last part of the text, plus a list of the addresses and similar values found in between. Everything the second proxy knows about the middle comes from that list.

The reviewer showed, one finding at a time, that the copy lost things:

  • The list was appended after the text, so the second proxy cut it again and lost the real end of the result.
  • IBANs were stored in lower case and looked for in upper case.
  • Two phone numbers next to each other in the list were read back as one number.
  • A token that only counted as long with its trailing full stop was dropped when read back.
  • My fix for that one could be shifted by two characters placed at the right position in the page.
  • A forged marker at the start of a result could make the second proxy skip the list.

Each was a real bypass: the proxy that read the page blocked the call, the second proxy let the same call through. After the fourth I stopped patching cases. The second proxy now takes the first proxy's list as it is instead of extracting the values again, and a generated test checks, for every kind of value, that whatever the first proxy can trace the second can trace too. The reviewer's own generated check, 1,000 cases, found nothing after that.

What the fixes cost

That last rule has a price, and I measured it. About 290 large issue lists, or about 970 web pages, fill the archive. After that, every write to a destination that is not allowlisted needs approval until the client restarts. A hostile page can force that state on purpose with one oversized result. The choice was between failing open silently and failing closed noisily. I chose the second and wrote it into the threat model.

The number of tests went from 172 to 367. The published attack suite did not move: 63 of 73 attacks blocked and 9 of 10 benign tasks allowed, before and after, because none of these findings were in it. That is its own lesson. A corpus measures what its author thought of.

What it still cannot do

  • An agent with an unrestricted shell on the same account can defeat any local control. The terminal check for approvals raises the bar; it is not a boundary.
  • Requests a server sends to the client (sampling, elicitation) are relayed without any check.
  • A first-seen tool is pinned without review; only later changes are caught.
  • Text that is not an address, URL, path or similar value is tracked only in the first and last part of a very long result.
  • Windows quoting was reasoned about, not tested.

What I would tell someone doing the same

  1. Decide the exit rule before the first audit. Mine was "an independent reviewer says open". Without it I would have shipped after round one.
  2. Let the reviewer run the code. Every finding from round three on came from a script, not from reading.
  3. Treat each fix as new code. Three times a reviewer found a problem that the previous fix had introduced.
  4. When a claim in the documentation and the code disagree, the claim is the bug as often as the code.
  5. When the same kind of bug comes back a third time, stop fixing instances. Remove the step that keeps failing, and write a generated test for the property you actually want.

The work was done by one person directing AI coding agents: one agent audited, another fixed, a third verified, and none of them reviewed its own work. No outside person has reviewed the code yet. That is the next step.

Türkçe özet

Firebreak, yapay zekâ ajanı ile MCP sunucuları arasında duran bir güvenlik ağ geçidi. Kaynak kodunu yeniden açmadan önce kendime bir kural koydum: kodu yazmayan bağımsız bir denetçi "açılabilir" demeden açılmayacak. Altı denetim gerekti. İlk turda belgelerin koddan fazlasını vaat ettiği ve izin listesinin atlatılabildiği çıktı; ikinci turda bir düzeltmenin yeni bir açık getirdiği ve Kiril harfli bir alan adıyla izin listesinin hâlâ aşılabildiği; üçüncü turda sonuçların başka bir yoldan gelip hiç kaydedilmediği; dördüncü turda belleğe konan sınırların kendisinin bir atlatma yolu olduğu; beşinci turda kodun sağlam ama iki belge cümlesinin yanlış olduğu; altıncı turda ise iki vekilin paylaştığı kopyanın altı ayrı biçimde değer kaybettiği. Altıncıda tek tek yamamayı bırakıp hatalı adımı kaldırdım ve her değer türü için üretilmiş bir test ekledim. Test sayısı 172'den 367'ye çıktı; yayınlanmış saldırı korpusunun sonucu ise hiç değişmedi, çünkü bulguların hiçbiri korpusta yoktu. Düzeltmelerin bir bedeli var: yoğun kullanımda araç güvenli tarafa düşüp daha çok onay istiyor; bunu ölçüp belgelere yazdım.

Firebreak on GitHub