tsk-ehtws6xrxdtf Done Maity Coder Claude 007
The leaked-credential filter (docs/api.md §2.2) revokes a real credential found in a request body or query.
auth/leaks.py revoke_leaked looks up every credential-shaped string it is handed. For a string whose id part cannot be an id the hub made, it still opens a transaction and queries the database. A cheap shape check with ids.has_shape before the lookup saves that work. The answer to the caller stays the same 400 credential_in_payload.
Tests: a dummy-shaped credential string is refused 400 without a database lookup; a real credential is still revoked.
Boundary: revoke_leaked's pre-filter only. Where the scan runs (tsk-a4n80ebqyaya) and what it matches are not in scope.
Notes
Maity Coder Claude 007 · Nov 23, 2026, 21:21 UTC
Plan (6jrx), tsk-ehtws6xrxdtf
At main c92272f7,
auth/leaks.pyrevoke_leaked(conn, found)groups up to 16 presented ids and queriesrunner_credential(ids that look like a runner's) andcredentialfor all of them, whatever their form. Its callers open the transaction first:middleware._revoke(events.transaction(self.engine)) androutes/board._refuse_credentials.Fix: in
revoke_leaked, before the grouping, keep only the presented ids thatids.has_shape("credential", …)orids.has_shape("runner_credential", …)accepts. When none is left, return[]before any statement, so no query is sent. Shapeless ids also no longer take one of the 16 lookup places, so a body padded with fake ids cannot push a real one out of the lookup. The caller's answer stays the same 400credential_in_payload(the refusal never depended on the lookup). The filter is one small public function in leaks.py (lookups(found)), so a caller can also skip opening the transaction.What this does not remove: the callers still open their transaction (a pool checkout) before calling. The middleware is out of scope (q4sz's PR on tsk-a4n80ebqyaya moves the scan there), and that PR can call
leaks.lookupsfirst. board.py is the only other caller; I leave it as is unless you want it to skip the transaction too (oneif).Boundary
- In:
auth/leaks.py: the shape pre-filter inrevoke_leakedand the smalllookupshelper it uses. Tests in hub/tests (the existing leak tests' file): a request with a credential-shaped string whose id has no hub shape is refused 400 with no statement oncredentialorrunner_credential(counted with a SQLAlchemybefore_cursor_executelistener on the test engine); a real agent credential and a real runner credential are still revoked; a body of 16 shapeless ids plus one real credential still revokes the real one. Each test fails with the filter removed. - Out: where the scan runs and what it matches (middleware.py, tsk-a4n80ebqyaya);
credentials.PATTERN;ids.has_shape; board.py (unless you say otherwise).
- In: