Repository navigation
Conversation
A bot has been submitting the public sign-up and forgot-password forms
about one second after loading them, making the server email third
parties. The forms are now guarded, and nothing a dropped submission
gets back tells it apart from a success.
- Form ticket: GET /api/v1/auth/form-ticket returns a single-use JWT
(key derived from the JWT secret for the "form-ticket" purpose) with
the issue time in ms. Register and request-password-reset drop a
submission with no ticket, a forged, expired, reused or other-form
ticket, one younger than auth.form_guard.min_fill_time (3s; 0 in test
run mode unless set), or a filled "website" honeypot.
- Budgets per form: 12 submissions per client IP per hour (429) and 3
emails per address per hour (silent), via BumpGlobalCounter.
- Drops answer exactly like a success, send no email, log at INFO and
count in solidping_auth_form_dropped_total{form,reason}.
- The password-reset per-minute IP limit uses the trusted-proxy IP
instead of a raw X-Forwarded-For.
- The HTTP request log line carries the client IP (trusted-proxy rule)
and the user agent.
- dash0 sends the ticket and a hidden honeypot; forgot-password waits
out the ticket's minimum age (its email is often pre-filled).
- The confirm-registration page confirms on a "Confirm my account"
click, not on load, so mail link scanners cannot burn the token.
- sp auth register / request-password-reset fetch a ticket and wait.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #718 +/- ##
==========================================
+ Coverage 89.74% 89.81% +0.06%
==========================================
Files 1297 1301 +4
Lines 132288 132604 +316
==========================================
+ Hits 118728 119103 +375
+ Misses 13551 13492 -59
Partials 9 9
🚀 New features to boost your workflow:
|
…in the UI (#719) Co-authored-by: Claude Opus 5.5 <[email protected]>
A team signing up from one office shares one IP. Counting every submission would block the 13th colleague within the hour. The sign-up budget now counts the pending registrations created from that IP in the last hour: confirming deletes the entry and frees its slot, and signing the same address up again does not take a second one. Password reset keeps counting every request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… personal org Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…and CLI self-service Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Owner
Author
|
Superseded by a minimal version: per-IP cap on unconfirmed sign-ups, see the new PR on branch |
fclairamb
added a commit
that referenced
this pull request
Oct 31, 2026
…minute) (#727) Replaces #718 with the minimal version: per-IP limits on sign-ups, as one server setting, on by default in SaaS mode only. ## Cause A bot uses the public sign-up form to make the server email third-party addresses (about 200 pending registrations since 2026-10-12, while real sign-ups stay around 8 a week). ## Fix - **Setting:** `auth.registration_max_pending_per_ip` (env `SP_AUTH_REGISTRATION_MAX_PENDING_PER_IP`, also a system parameter applied at startup). - Default **10 in SaaS mode** (`SP_DEPLOYMENT_MODE=saas`), **0 (off) otherwise**. An env or config-file value wins over the mode default. - Off in test run mode unless the variable is set, because the Playwright suites leave many sign-ups unconfirmed from one address. - Prod and dev run in SaaS mode with `TRUSTED_PROXIES=1`, so both get it with no extra setting. - **Once a minute:** while the limit is on, one client IP may sign up at most once a minute. A second request answers `429 RATE_LIMITED` with `Retry-After: 60` and sends nothing. This also caps re-sends to an address that is already pending. - The counter (`registration_ip_rl:<ip>`) is bumped atomically by the database, so a parallel burst lets one request through on any replica. - **Unconfirmed per day:** the pending registration now keeps the client IP. An IP with that many pending registrations written in the last 24 hours gets `429 RATE_LIMITED`, without `Retry-After`. - Confirming deletes the entry and frees the slot, so colleagues behind one NAT get through as long as they confirm. - Signing up again for an address already pending rewrites its entry and is not counted against itself. - **No enumeration oracle:** both checks run before the taken-email branch, and a taken email spends the minute like a real sign-up. - **Client IP:** taken with `ExtractTrustedClientIP` and `SP_SERVER_RATE_LIMITING_TRUSTED_PROXIES`, so a forged `X-Forwarded-For` does not get a fresh budget. - **dash0:** the register page tells the two 429s apart by `Retry-After` and shows a translated message for each (en, fr, de, es). - **API:** OpenAPI documents the 429 on `register`; `pkg/client` regenerated. - **Docs:** "Limiting Unconfirmed Sign-Ups per IP" in `configuration/authentication.md`, a row in `configuration/index.md`, and `wiki/api-specification/auth.md`. ## Verification - `internal/handlers/auth/registration_ip_limit_test.go`: - Pending cap: over it, no entry and no email. Positive controls: another IP, re-registering a pending address, and confirming one freeing a slot. - Once a minute: a second sign-up, and a re-send, are refused with nothing sent. Another IP passes, and the same IP passes a minute later. - A taken email spends the minute, and an IP over the cap is refused for taken and free addresses alike. - A pending entry older than 24 h no longer counts. - Limit `0` or no client IP: back-to-back sign-ups all pass. - A parallel burst of 6 stores exactly 1. - Through the HTTP handler: `429` with `Retry-After: 60` within the minute, `429` without it for the pending cap, a forged `X-Forwarded-For` ignored, the port stripped, another client sent. - `internal/config/registration_limit_test.go`, through `Load`: self-hosted off, SaaS 10, test mode off even in SaaS, explicit value wins (also in test mode), garbage and negative values ignored, a config-file value kept over the mode default. - `internal/systemconfig`: `ApplyFunc` coercion and `TestAuthEnvVarsDocumented`. - `go test -short ./...`: green. - `golangci-lint run ./...`: 0 issues. - dash0: `tsc -p tsconfig.app.json` clean, locale parity tests green. - Not run: `make test-postgres` and Playwright (CI). No e2e spec for the 429s: the CI server runs in test mode with the limits off. ## Notes - `make dev-saas` (SaaS mode, not test run mode) now has the limits on: a developer trying sign-ups in a loop there hits the once-a-minute limit. `SP_AUTH_REGISTRATION_MAX_PENDING_PER_IP=0` in `dev.priv.env` turns it off. - Not covered: a bot that rotates IPs, a per-address cap across IPs, and the password-reset form. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cause
Since 2026-10-12 a bot has been using the public sign-up and forgot-password forms to make the server email third parties ("subscription bombing"): about 200 pending registrations for distinct webmail addresses, while real sign-ups stayed around 8 a week. The server logs show the same sequence for every one, within about 3 s, from a JS-running browser: load
/d/forgot-password,POST /auth/request-password-reset, load/d/orgs/default/register,POST /auth/registerabout 1 s after the page loaded. Nobody fills a name, an email and a password that fast. The request log line had no client IP or user agent, so the source could not be traced.Separately, the confirm-registration page spent the one-shot token in a
useEffecton load, so mail link scanners that run JavaScript could burn it before the human clicked, leaving them on "Confirmation failed".Fix
Form guard (
auth.form_guard, enabled by default in every mode)GET /api/v1/auth/form-ticket?form=register|password-resetreturns a signed, single-use ticket: a JWT whose key is derived from the JWT secret for theform-ticketpurpose (it can never verify as a session token), carrying the form, the issue time in ms and a random ID. The dashboard fetches it when the form renders and sends it back asformTicket.BumpGlobalCounterwith a limit of 1) or other-form ticket, a ticket younger thanmin_fill_time(3 s), or a filledwebsitehoneypot (off-screen,tabindex=-1,autocomplete=off,aria-hidden, password-manager opt-outs).429, like the existing per-minute reset limit) and 3 emails per address (silent). For sign-up the IP budget counts only registrations still pending: the client IP is kept in the pending entry, confirmation deletes it and frees the slot, and the address being signed up again is left out of the count. So 20 colleagues behind one NAT get through as long as they confirm. Password reset counts every request.solidping_auth_form_dropped_total{form,reason}.SP_AUTH_FORM_GUARD_ENABLED(true),_MIN_FILL_TIME(3s,0sin test run mode unless set, so Playwright keeps passing while the ticket stays required),_TICKET_TTL(24h),_PER_IP_PER_HOUR(12),_PER_EMAIL_PER_HOUR(3).0turns a budget off.Client IP
ExtractRemoteAddr(trustsX-Forwarded-Forblindly), so it could be dodged with a fresh header per request. It now usesExtractTrustedClientIPwithSP_SERVER_RATE_LIMITING_TRUSTED_PROXIES, like the new budgets.HTTP requestlog line now carriesip(same trusted-proxy rule) anduserAgent(truncated to 256 chars).Clients
sp auth register/sp auth request-password-resetfetch a ticket before prompting and wait outminAgeMs. Against an older server without the endpoint, they send the request as before.getFormTicket,formTicket/websiteon both request bodies,429documented on register;pkg/clientregenerated.Confirm page
confirm-registration/$tokennow shows a "Confirm my account" button (confirm-registration-button) and spends the token only on click. The ref-based double-call guard is kept (now guarding double clicks). New strings in en, fr, de, es.Docs: a "Sign-Up and Password-Reset Forms Are Guarded" section in
web/docs/docs/configuration/security.md(with the env table checked byTestDocumentedDefaultsMatchCode), and anUnreleasedCHANGELOG entry.Verification
internal/handlers/auth/form_guard_test.go): for both forms, a valid aged ticket is sent; too fast, honeypot, missing, garbage, forged with another secret, expired and other-form tickets each answer the success response, store nothing and queue no email, then the same address with a valid ticket is sent. Single use (the replay is dropped, the first use is sent). Per-email budget through the real handlers: over budget the status and body are identical to a sent one, and another address is still sent. Per-IP budget:429past it, a forgedX-Forwarded-Fordoes not reset it, another client is unaffected. Reset per-minute limit ignores a forgedX-Forwarded-For.GET /form-ticket(200,Cache-Control: no-store, 422 on an unknown form).internal/app/request_log_test.go:ipwith no trusted proxy (forged header ignored) and with one,userAgenttruncation,erroronly on failure.internal/config/form_guard_test.go: defaults, env binding (0, garbage), test run mode.test/integration: register through the real router and generated client, without a ticket (dropped) then with a fetched, aged one (sent).formTicketDelayMs; locale parity.form-guard.spec.ts(ticket and empty honeypot sent, honeypot out of tab order and aria-hidden, forgot-password waits then succeeds, confirm spends nothing on load),confirm-registration-no-org.spec.ts(now clicks the button; the queued email proves dash0 sends a valid ticket),electric-identity-auth,login,email-language,membership-requests: all green. Also against a side-car withSP_AUTH_FORM_GUARD_MIN_FILL_TIME=3s: a ticket used at once, a filled honeypot and a replay are dropped with the same200, an aged ticket is sent.golangci-lint run ./...: 0 issues.make test: green.bun run lint:e2e,typecheck:e2e,tsc -p tsconfig.app.json: clean; no lint error in the touched files (the three files' testid suppressions are pruned).make test-postgres(CI), the full Playwright suite (CI), andmake lint-migrationslocally (the script needs bash 4; no migration is touched).Notes
POST /auth/registeror/auth/request-password-resetdirectly now needs a ticket; the docs and the OpenAPI description say how.SP_AUTH_FORM_GUARD_ENABLED=falserestores the previous behavior (the budgets still apply).🤖 Generated with Claude Code