One night, a colleague pinged me: someone was probing our production. Nothing leaked. Even so, the probe found things our tests never found, including a route that was broken for every customer and that nobody had noticed.
What happened
The product is a multi-tenant analytics SaaS: each customer is a project with its own dashboard. There's an internal dashboard (invite-only login), a public partner API (API keys, paid plan), and a few dashboards that are public on purpose.
According to the incident report: at least 2h15 of probing, from 3 addresses. It started on production only and, about 1h45 later, moved on to dev and staging too. When the report was closed, it was still active.
The tools identified themselves as audit/pentest tools. Before treating it as hostile, I checked with the team: nobody had ordered anything.
The actor opened accounts in all three environments and created 2 API keys. Then the usual playbook: look for secret files, become admin, read other projects' data, and run a fuzzer against the partner API. Everything came back 401, 403 or 404. What they did manage to read was a public dashboard, the pricing, the empty lists of their own accounts, and a few open config routes (business info, no user data).
What held
Project isolation worked. No secret file was exposed. And invite-only signup meant the actor's accounts saw empty lists.
Routes that answered without login
Leftovers from when the frontend needed them before login. No user data, but more than they should have returned (the project list, inactive ones included).
The detail: most of them were already closed on the development branch. Production was dozens of commits behind. The fix existed and wasn't live.
And a mistake of mine: in the first analysis, I read a local copy of the repo that was way behind and listed as open some routes that had already been closed. I had to redo it against the remote branches and correct what I'd said. During an incident, check which version of the code you're looking at before you claim anything.
A 500 from a repeated parameter
?x=a&x=b makes the framework hand you an array instead of a string. The code cast it to string and blew up.
// the pattern that broke const sub = (req.query.subdomain as string).toLowerCase(); // the right pattern, which already existed in another middleware in the same codebase const raw = req.query.subdomain; if (typeof raw !== 'string') return res.status(400).json({ error: 'invalid_parameter' }); Nothing leaked, but a 500 tells the attacker there's an unhandled code path there, and they come back. as string on user input is a lie the compiler accepts.
A route broken for everyone
The best finding. A partner API route that updates a key setting returned 500:
The UPDATE writes two columns: the value and the updated-at timestamp. The service's database user has write permission per column, and it only covered the value. Postgres rejected the other one. It was like this in all three environments.
In other words: the route never worked for any partner, and none of them complained. The only one who tried it was the attacker.
CI didn't catch it because, in tests, the database user owns the tables. The owner can do anything, so no permission was ever exercised.
A 500 from a null byte
The fuzzer sent %00 in a text parameter and got a 500. The cause wasn't traced. The hypothesis is that the value reaches a text parameter in a query and Postgres rejects the 0x00 byte. The proposed fix: reject the null byte with a 400 in the layer that reads parameters, to cover all of them at once.
The loose limits
Not bugs, but they made the actor's job cheaper: a freshly created account could create API keys without a verified email; disabling an account doesn't kill the session (the token stays valid until it expires, up to 1 hour with our identity provider); rate limits let about 4,000 requests through; and there was no limit on sessions per login (about 70 in 30 seconds).
Current state
The config routes that were already closed in dev went to production the day after the incident. The other fixes had not been applied yet when I wrote this, and containing the actor (revoking the keys, disabling the accounts) was still a pending decision.
What I take from it
An attack that fails is a free audit. The actor tested paths our tests didn't: repeated parameter, null byte, a route no partner used. If the only question had been "did they get in?", the answer would be "no" and all four findings would have slipped by.
Test with production permissions, or your permissions aren't being tested. Least privilege in the database is right. But if tests run with a user more powerful than production's, you're not testing the system that runs in production. It's the same rule I use for test doubles: the fake can never be more generous than the real thing.
Have containment ready before you need it. Disabling an account isn't a button that takes effect immediately: the session stays valid for up to 1 hour. Knowing how to revoke a key, disable an account, and kill a session is the minimum. Knowing how long each one takes to kick in is what separates containing in seconds from containing in an hour.
