Public: anyone can read this; the crew can change it.

"tries at /signin close the API door" passes every time on a loaded check machine #16904

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I changed only test/signin-password-doors.test.ts; it now passes 20 of 20 alone and 5 of 5 beside a parallel run of the sign-in, users and hash tests. The test never failed on this machine, so the cause below comes from reading the code, not from a reproduction.

Notes

opened this

I changed only test/signin-password-doors.test.ts; it now passes 20 of 20 alone and 5 of 5 beside a parallel run of the sign-in, users and hash tests. The test never failed on this machine, so the cause below comes from reading the code, not from a reproduction. The 20 runs also ran quiet, so they say nothing about a loaded machine. I did not run bun x tsc --noEmit or the gate checks as a separate pass; a bare bun x tsc --noEmit printed nothing and the gate --fix changed no files.

Cause. The test fired its three wrong /signin posts through a loop that ended after 50 asks. It only checked for a 422, which is what a counted wrong password answers. Argon2 hashes are capped process-wide at 4 at a time (src/core/hash-gate.ts), and a try the gate turns away is refused without being counted. It comes back as a 429 with Retry-After: 1. On a busy check machine, other hashes could fill the gate for longer than that loop waited, so the loop ended with fewer than three tries counted. The API call then did not meet a full window, and the test failed.

The same loop would swallow a 403 from the origin check, because it never looked at what a non-422 answer was. So the test could not tell a counted refusal from a try that counted nothing.

The suspect about the window's clock rolling does not apply, since the window is a sliding minute. Full-cost argon2 contributes only through the gate, and the /signin posts are awaited.

Fix.

  • Each /signin try is retried against a 20 s deadline instead of 50 asks.
  • Every non-422 answer must be the gate's 429 with Retry-After: 1. Anything else, such as a 403, fails the test with its status.
  • The final POST /api/v1/sessions must be a 429 whose Retry-After is greater than the gate's 1 s. That shows the sign-in window closed the door and not the gate.

I left production code alone, because I found no race in counting tries. I did not add an injected clock or a low hash cost, since neither affects the cause. To try it: for i in $(seq 20); do bun test test/signin-password-doors.test.ts || break; done.

Closes #4406

commented

I changed only test/signin-password-doors.test.ts; it now passes 20 of 20 alone and 5 of 5 beside a parallel run of the sign-in, users and hash tests. The test never failed on this machine, so the cause below comes from reading the code, not from a reproduction. The 20 runs also ran quiet, so they say nothing about a loaded machine. I did not run bun x tsc --noEmit or the gate checks as a separate pass; a bare bun x tsc --noEmit printed nothing and the gate --fix changed no files.

Cause. The test fired its three wrong /signin posts through a loop that ended after 50 asks. It only checked for a 422, which is what a counted wrong password answers. Argon2 hashes are capped process-wide at 4 at a time (src/core/hash-gate.ts), and a try the gate turns away is refused without being counted. It comes back as a 429 with Retry-After: 1. On a busy check machine, other hashes could fill the gate for longer than that loop waited, so the loop ended with fewer than three tries counted. The API call then did not meet a full window, and the test failed.

The same loop would swallow a 403 from the origin check, because it never looked at what a non-422 answer was. So the test could not tell a counted refusal from a try that counted nothing.

The suspect about the window's clock rolling does not apply, since the window is a sliding minute. Full-cost argon2 contributes only through the gate, and the /signin posts are awaited.

Fix.

  • Each /signin try is retried against a 20 s deadline instead of 50 asks.
  • Every non-422 answer must be the gate's 429 with Retry-After: 1. Anything else, such as a 403, fails the test with its status.
  • The final POST /api/v1/sessions must be a 429 whose Retry-After is greater than the gate's 1 s. That shows the sign-in window closed the door and not the gate.

I left production code alone, because I found no race in counting tries. I did not add an injected clock or a low hash cost, since neither affects the cause. To try it: for i in $(seq 20); do bun test test/signin-password-doors.test.ts || break; done.

commented

Left #4406 open: 2 unticked items remain (The pull names the cause of the load sensitivity, with evidence. Suspects: the sign-in window's clock rolls between the TRIES /signin posts and the API attempt; full-cost argon2 makes the test outlast its timeout; the /signin posts are not counted (the fetch sends no Origin, or its response is not awaited) before the API try.; for i in $(seq 20); do bun test test/signin-password-doors.test.ts || break; done passes 20 of 20, and once more beside a parallel bun test. Put the numbers in the pull.).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs