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

Sign-in is also rate-limited per source, alongside the per-account and per-forge windows #2434

Parked opened this
Closed without merging

Sign-in now has a third throttle window, signin.persource, keyed on the socket's peer address. bun x tsc --noEmit is clean. I ran forge-signin, limits, passkeys and signup-allowed tests (36 pass) but not the whole suite.

Notes

stopped parked by the crew deploy 803ffff

opened this

Sign-in now has a third throttle window, signin.per_source, keyed on the socket's peer address. bun x tsc --noEmit is clean. I ran forge-signin, limits, passkeys and signup-allowed tests (36 pass) but not the whole suite.

  • New limit: signin.per_source defaults to 60 attempts a minute, with a range of 1–10,000. It's defined in src/settings/limits.ts, so it appears on /admin/limits and can be set through the same API as the other limits.
  • Which sign-ins it covers: signinAllowed in src/web/pages/site.ts runs the per-account check, then the new per-source check, then the per-forge check. The password form and every first sign-in through a linked method already go through signinAllowed, so they all get the new window, and no other route is limited.
  • How the source is keyed: it uses clientAddress and bucketOf, the same helpers signup.per_source uses, so an IPv6 client is counted by its /64. Headers don't affect the key.
  • Order of checks: a per-account attempt is counted before the per-source check runs. If the source is then refused, that attempt still used one slot of the account's window.

Tests

  • New: a test in test/forge-signin.test.ts sets the limit to 5. One source trying six accounts is throttled on the sixth, even with a spoofed x-forwarded-for. A different source at the same moment is not throttled.
  • Changed: the existing "a refused key does not spend the forge budget" test sent all its attempts from one unknown source, which the new window would now throttle. I changed that test, not the code, so it gives each attempt its own peer.

Left out: the README doesn't mention the new limit, because it doesn't list the other sign-in limits by name either.

Closes #2278

1 earlier comment · 1 event
commented

Sign-in now has a third throttle window, signin.per_source, keyed on the socket's peer address. bun x tsc --noEmit is clean. I ran forge-signin, limits, passkeys and signup-allowed tests (36 pass) but not the whole suite.

  • New limit: signin.per_source defaults to 60 attempts a minute, with a range of 1–10,000. It's defined in src/settings/limits.ts, so it appears on /admin/limits and can be set through the same API as the other limits.
  • Which sign-ins it covers: signinAllowed in src/web/pages/site.ts runs the per-account check, then the new per-source check, then the per-forge check. The password form and every first sign-in through a linked method already go through signinAllowed, so they all get the new window, and no other route is limited.
  • How the source is keyed: it uses clientAddress and bucketOf, the same helpers signup.per_source uses, so an IPv6 client is counted by its /64. Headers don't affect the key.
  • Order of checks: a per-account attempt is counted before the per-source check runs. If the source is then refused, that attempt still used one slot of the account's window.

Tests

  • New: a test in test/forge-signin.test.ts sets the limit to 5. One source trying six accounts is throttled on the sixth, even with a spoofed x-forwarded-for. A different source at the same moment is not throttled.
  • Changed: the existing "a refused key does not spend the forge budget" test sent all its attempts from one unknown source, which the new window would now throttle. I changed that test, not the code, so it gives each attempt its own peer.

Left out: the README doesn't mention the new limit, because it doesn't list the other sign-in limits by name either.

Approved

Sign-in gets a third window keyed on the socket peer (bucketOf, /64 for IPv6) via the same helpers as signup. Headers cannot move the key, and the test proves it with a spoofed x-forwarded-for. The limit is listed with a reason and bounds, and the changed existing test was wrong for the new window, so changing it is right. Next two things: (1) The per-account attempt is counted before the source check, so a refused source still burns an account slot. Take the source first, or note it in the limit reason, so a noisy source cannot lock a victim account. (2) Name signin.per_source in the README next to the other limits, or list all three, so an owner behind a shared NAT knows which knob to raise.

commented

Parked by the crew: the check failed ("an account's whole-life budget > (unnamed)") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs