A spending cap for AI agents is only worth something if it holds when the agent misbehaves: when it loops, fires requests in parallel, retries everything, and gets creative with the input.
So I published a live key for one. Try to break it.
https://ut181749ut.github.io/saifuban/challenge.html?src=devto
The setup
Saifuban is a spending guard for AI agents. Before an agent pays for anything, it asks Saifuban. Small amounts are approved automatically, anything bigger goes to your phone, and API calls can go through a proxy that stops at a daily, weekly or monthly budget.
The challenge agent has:
- a daily budget of ¥100 (about $0.65)
- a per-payment limit of ¥100
- auto-approval for anything up to ¥100
That last part matters. There's no human in the loop to reject anything. If Saifuban gets the math or the timing wrong, the money goes through.
You win if the total approved amount for one day goes over ¥100. Parallel requests, retries, odd currencies, strange merchant names, idempotency tricks: anything through the public API or MCP endpoint counts. No real money moves. The page shows a live counter of what's been approved today.
What I tried first
The obvious attack is a race. Fire a lot of requests at once and hope several pass the budget check before any of them is recorded.
I sent 30 payment requests at the same time, mixing ¥60 requests with $0.40 and $0.45 ones and giving each a different merchant name.
One was approved. The other 29 were rejected with "over daily budget".
The reason is boring on purpose. Each request locks that agent's row in the database before it reads the budget, so requests for the same agent are processed one at a time. There's no gap between "check the budget" and "record the spend" for a parallel request to slip through.
The hole I did find
Rounding.
Amounts are stored in whole yen, and I was rounding to the nearest yen. So a request for ¥99.2 was stored as ¥99, and a following request for ¥0.3 was stored as ¥1. Both were approved, for a total of "¥100", while the agent had actually been allowed ¥99.5 against a budget it believed was respected. Worse, a single ¥100.4 request was approved as ¥100.
It wouldn't have won the challenge, since the counter uses the stored amounts. But in real use, the agent could pay slightly more than it was approved for, and a cap that's "off by less than one yen" is still not a hard cap.
Amounts are now always rounded up. ¥99.2 becomes ¥100, so the ¥0.3 that follows is rejected, and ¥100.4 becomes ¥101 and is rejected by the per-payment limit.
Two more things I added before posting this
A request rate limit. Each agent can make at most 30 payment requests a minute. Without it, the challenge would just be an invitation to fill my database. Extra requests get a 429.
A concurrency limit on the API proxy. This one came from reading about a $78k runaway agent bill, where hundreds of calls were already in flight when the budget was reached, and the cap couldn't stop them. Now each agent can have only a few API calls in flight at once (4 by default). Extra calls get a 429, which the official OpenAI and Anthropic SDKs already retry with backoff. A loop can't outrun the budget check.
The honest limit
Saifuban can only stop what goes through it. If an agent has a raw card number and pays without asking, no approval layer will catch that. The hard guarantees are where Saifuban sits in the path: API spend through the proxy, where the agent never has the real key, and payments where the merchant checks Saifuban's single-use payment token.
Try it
Key, curl example and MCP URL are on the challenge page. If you break it, open an issue on GitHub with how, and you'll be credited in the README. Failed attempts are interesting too.
Top comments (0)