Skip to content

Security (low): 10,000 anonymous GETs to /auth/login block every sign-in for ten minutes #419

Closed

Description

@BeSovereign

Where

  • server/src/auth/routes.ts:35-47 — GET /auth/login is public and calls createLoginAttempt on every hit.
  • server/src/auth/sessions.ts:27-43 — LOGIN_ATTEMPTS_MAX = 10_000; at that many live attempts (TTL LOGIN_TTL_MS = 10 min) every new login is refused with /?loginError=1; live attempts are never evicted. No address is stored with an attempt and nothing limits attempts per address (AttemptLimiter/addressKey from http/attempts.ts are not used here).

What happens

The #255 cap stops the table from growing but turns an anonymous flood into a sign-in outage: one client sending about 17 requests per second (10,000 per TTL window) keeps the table full, and every member of the shard, the admin included, is sent back to the app with the login error. The IdP is never reached, so nothing upstream limits it.

Probe

startTestApp(); 10,000 × GET /auth/login from 203.0.113.77 — all answered 302 to the IdP in 4.9 s; then GET /auth/login?login_hint=testuser from 198.51.100.7 → 302 /?loginError=1; the harness's login(t, 'testuser') fails. server/test/auth.test.ts:160-172 pins this behaviour as intended for a full table, which is why the attacker-driven case was never considered.

Expected

A flood from one address (or one IPv6 /64) cannot stop members on other addresses from signing in. The global cap stays as the last resort for a distributed flood.

Fix

  • Rate-limit login starts per addressKey(req.ip) with the existing AttemptLimiter (e.g. 30 per minute; over it answer LOGIN_FAILED_URL or 429 with retry-after, logged at warn).
  • Store the address key on login_attempts (migration 033_login_attempt_address.sql, address TEXT) and cap live attempts per address (e.g. 50): a new attempt from an address at its ceiling evicts that address's oldest attempt instead of counting towards the global cap. Keep LOGIN_ATTEMPTS_MAX.
  • Record the trade-off in the Security (low): PROPFIND quota walk per child folder; unbounded login_attempts rows #255 DECISIONS entry.

Tests that must fail without the fix

  • server/test/auth.test.ts: "a flood from one address does not stop other members from signing in" — inject LOGIN_ATTEMPTS_MAX starts from 203.0.113.77; assert that address's live rows never exceed the per-address ceiling, that it is refused once over its rate, and that login(t, 'testuser') from 198.51.100.7 still completes (302 to the IdP, callback 302 with a session cookie). Removing the per-address limiter/ceiling lets the table fill and the other address gets /?loginError=1.
  • Keep the existing table-full test but fill it from many distinct addresses so it still proves the global cap.

🤖 Generated with Claude Code


Found by the automatic review round (claude-fable-5-1, 24f3fc6); per CLAUDE.md the fix starts with a failing behaviour test.

Activity

  1. added
    rebuild
    security
    on Oct 20, 2026
  2. added a commit that references this issue on Oct 20, 2026
  3. BeSovereign commented on Oct 20, 2026

    @BeSovereign
    ContributorAuthor

    Fixed: PR #429 squash-merged into main after green CI (one commit; git revert it to undo).

    • Suites: typecheck: 1 passed, 0 failed | lint: 1 passed, 0 failed | unit: 1203 passed, 0 failed | e2e: 616 passed, 0 failed
    • Declared tests fail without the production change and pass with it (output in the PR).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    rebuildsecurity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions