Skip to content

fix(control-plane): overlong login emails skip the throttle; a transient store error keeps the session - #131

Merged
CMGS merged 4 commits into
mainfrom
review/round-2026-09-25
Sep 26, 2026
Merged

CMGS merged 4 commits into
mainfrom
review/round-2026-09-25

Conversation

@CMGS

@CMGS CMGS commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two control-plane fixes, each with a regression test that fails on the old code:

  • Login refuses an email longer than 254 bytes before it keys the throttle.
    • The throttle kept the client IP plus the normalized email for five minutes, and the body limit is 1 MiB.
    • So unauthenticated logins with unique megabyte emails held about a megabyte each.
    • An address longer than the SMTP limit cannot belong to an account, so it gets the usual 401 without creating a throttle entry.
  • A transient user-store error answers 503 and keeps the session.
    • requireAuth deleted the session on any ByID error, so a Postgres restart or failover logged every active admin out for good.
    • Now only a missing, disabled or password-reset user drops the session. Any other store error is logged and answered with 503.

Plus a review commit: own-line comments start uppercase unless they open with an identifier.

Evidence

Real Postgres 17 (container), CP_STORE=postgres, main vs this branch. Steps: log in, stop Postgres, request, start Postgres, request again.

session Postgres stopped Postgres back
main 200 401 authentication required 401: the session was deleted, so the admin is logged out
this branch 200 503 authentication is temporarily unavailable 200: the session survived

The email cap is not visible from outside (both arms answer 401 to a 312-byte email). The difference is the throttle entry, which TestLoginRejectsAnOverlongEmailBeforeTheThrottle pins.

Gates (control-plane):

  • make fmt-check and make lint: 0 issues.
  • go test -race ./...: pass.
  • asl on darwin and linux: clean.

Size: prod +12/-2, tests +57.

…re it keys the throttle

The throttle kept client IP plus the normalized email for five minutes, and the body limit is 1 MiB, so unauthenticated logins with unique megabyte emails held a megabyte each (64 such logins retained 65 MiB). An address longer than the SMTP limit cannot belong to an account, so it gets the usual 401 without a throttle entry.
…s the session

requireAuth deleted the session on any ByID error, so a Postgres restart or failover logged every active admin out for good. Only a missing, disabled or password-reset user drops the session now; any other store error is logged and answered 503.
…w scope, the live-matrix group argument, login and session responses in the OpenAPI
@CMGS
CMGS merged commit 41648c1 into main Sep 26, 2026
2 checks passed
@CMGS
CMGS deleted the review/round-2026-09-25 branch September 26, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant