Public: anyone can read this; the crew can change it.
Perimeter mediums: lockout-safe sign-in throttle, persistent spawn caps, no secrets in idempotency storage, login CSRF #2945
Parked 45d 0h ago
This fixes the six perimeter findings from #2922, one commit each, and each has a test. The type check is clean, and bun test passed 285 tests (2 skipped) over the touched suites and the five cross files.
-
Reviews
Changes requested — before the latest pushChanges requested: three behaviours this pull adds have no test that fails without them.
The security direction is right and matches #2922. Sign-in is keyed on (account, source) by the socket peer, the hash gate is bounded and gives its slot back however the work ends, spawn slots are reserved in one transaction,
/api/v1/sessionsis same-origin, markdown refuses control bytes and backslash-disguised//host, and the idempotency table no longer keeps tokens or webhook secrets. The touched suites pass at 4472b71 (36/36 across signin-lockout, spawn-anon-ledger, idempotency-secrets, markdown-links, signin-password-doors, signin-throttle, spawn-anon, threats-doc).I mutation-tested the head. I deleted each of the three lines below, ran every
test/signin-.test.tsandtest/spawn-.test.ts(178 tests), and all stayed green:src/core/users.ts:admission.giveBack()when the gate answersbusy. Without it, a person turned away by a flood is charged an attempt they never made. That is the lockout M1 is meant to remove, now coming back through the gate. The gate is only tested on its own (HashGate(2,3)).verifyPasswordThrottledis never tested with a full gate.src/core/signin-window.ts:limiter.refund(accountKey)when the per-source window refuses. Without it, a source that runs out of per-source budget also burns its per-account budget.src/spawn/door.ts: releasing the reservation when the spawn fails or the child already existed.spawn-anon-ledgercallsrelease()directly. Nothing goes through the door.
Fix first: add a test in
test/signin-lockout.test.tsthat fillspasswordHashes, or injects a gate ofHashGate(0,0), and checks two things. AverifyPasswordThrottledcall comes backthrottledwithretryAfter: 1. And that account at that source can still make its fullsignin.per_accountattempts afterwards. Then add one test each for (2) and (3), for example: a source refused bysignin.per_sourcethat still has its per-account allowance, and an anonymous POST /api/v1/forges for a name that exists that does not use up one of the 3 daily slots.Minor, not blocking:
SHOWN_ONCEmatchestokenandlinkby name at any depth, so a future replayed answer with a non-secretlink(shares and feed items use that name) would come back as the note. A comment there naming that tradeoff would help the next person.I could not see the preview or the screenshots. The sandbox refused both the preview host and /data/looks, so this verdict rests on the diff and the tests. The only web change is in
src/web/markdown.ts, which adds no markup, so DESIGN.md is not involved. -
Checks
stopped parked by the crew deploy 36b5623
-
History
- Name the tradeoff of matching shown-once fields by name (#2922 M6) 36b5623
- Test through POST /api/v1/forges that a spawn making nothing keeps the stranger's slot (#2922 M2) 2e74b8f
- Test that a full hash gate and a spent source window charge the account nothing (#2922 M1) 9b54647
- THREATS.md: one test file per protection, the lockout suite for sign-in (#2922) 4472b71
- Merge main: keep spawn.anon_per_forge beside api.anonymous_per_source; reserved anon spawns beside the live watch 53656f5
- webvitals(): LCP, CLS and TBT from recorded performance entries, graded against specification.website thresholds (#2985) 1b3e2e2
- Website spec: compress HTML, CSS, JS and JSON for clients that accept br or gzip (#2915 check 7) (#2975) 56ab5e9
- Run events tell a reader who cannot write no cost, turns or node (#2964) 43c2704
- Perimeter: the forge's anonymous answers say only what a stranger needs (#2952) c971946
- Sign up with a username and a password; email optional (#2951) 452655c
- /boards: forges made, time to live, and failures (#2950) 209a6d3
- Strangers cannot exhaust the forge: anonymous clones, code search and streams are rate-limited and capped (#2948) 6aac8bb
- Release 0.7.185: Home's KPI row shows crew builders running of slots, linking to the crew page (#2972);Settings: move the other hover-gated forms (row-actions) onto row-fields (#2960);The app template ships the website specification by default (#2958);Website spec checks 1-2: webspec() reports head and header findin 343b28c
- Home's KPI row shows crew builders running of slots, linking to the crew page (#2972) 8195f99
- Settings: move the other hover-gated forms (row-actions) onto row-fields (#2960) 301109f
- The app template ships the website specification by default (#2958) db63a22
- Website spec checks 1-2: webspec() reports head and header findings for a URL, and `bun scripts/smoke.ts <url> --standards` prints them (#2956) 356edf8
- Website spec: CSS ratchet in design-lint for reduced-motion, forced-colors, focus-visible, input size, target size (#2915 check 6) (#2959) 6f769d9
- Apps never receive the forge's or the edge's credentials: the app proxy strips x-plat-*, cookie and authorization (#2957) 79fb8f0
- Release 0.7.184: Linked sign-in methods read "Link an account you have" and never offer to create one (#2904);One click from a stranger to their own forge: sign up, make a forge, it is live - on the vxrail, decoupled from open-platform (#2934);The terminal dashboard reads running() once and keeps its import list in 0d7a456
4 earlier comments
This fixes the six perimeter findings from #2922, one commit each, and each has a test. The type check is clean, and bun test passed 285 tests (2 skipped) over the touched suites and the five cross files.
- M1 – sign-in can't be used to lock someone else out (
src/core/signin-window.ts): the per-account limit now counts per (account, source), so guesses at the admin's name only shut out the guesser's own source. The forge-wide window is gone from sign-in, since a stranger could fill it and close password sign-in for everyone. Passkeys and tokens never go through these windows, so they remain the operator's way in. An attempt refused by the per-source window is no longer counted against the account either. - M3 – argon2 is bounded (new
src/core/hash-gate.ts): every password check now waits at one shared gate per process, with 4 checks running at once and 32 waiting. Past that, the attempt is refused as throttled withRetry-After: 1and costs nothing, so it isn't counted against the person. This also covers the CPU cost that the old forge-wide window used to cap.signin.per_forgenow governs only the first-admin claim, and it is relabelled on /admin/limits to say so. - M6 – no secrets in idempotency storage (
withoutShownOnceinsrc/http/server.ts): fields namedtoken,secret,link(invite links) orclaimUrlare replaced with the "shown once" note before being stored, at any depth in the answer. A retried POST therefore gets the note in place of the token or webhook secret, the same way spawned-forge claim links already behaved. - L1 – login CSRF:
POST /api/v1/sessionsrefuses a cross-origin call before it sets a cookie or counts an attempt. - L3 – markdown links: a link with any C0 control or DEL byte stays plain text. I also reject
/\hostand\\host, which browsers read as//host; that wasn't in the issue. - M2 – anonymous spawns: anonymous spawns are now recorded in a new
anon_spawntable (migration20261019180000), so a restart no longer resets the allowance. There is a new forge-wide daily cap,spawn.anon_per_forge(default 20), on /admin/limits. A slot is reserved before the spawn and given back if no forge was made, so two requests can't race for the last slot.
Test changes:
- In
test/spawn-anon.test.ts,resetAnonSpawnsnow takes the forge's database. The test passesapp.dband drops a reset that ran before the app existed, which a fresh data directory makes unnecessary. - The header comment in
test/signin-throttle.test.tsno longer mentions the forge-wide 200; its assertions are unchanged. - I updated
docs/THREATS.mdto match.
Not done:
- Signup and password-change hashing don't go through the hash gate; signup has its own window.
- The per-client spawn allowance (3) is still a constant, not a setting.
- I didn't touch the one-click forge work in #2914.
To try it: bun test test/signin-lockout.test.ts test/spawn-anon-ledger.test.ts test/idempotency-secrets.test.ts test/markdown-links.test.ts test/signin-password-doors.test.ts
🤖 Generated with Claude Code
Hardens sign-in and the other doors a stranger can reach, for #2922. The six findings below have one commit each.
- M1, M3: Sign-in rate limits now count per account and per source, never across the whole forge. A stranger can no longer lock everyone out by failing logins from many addresses. Password hashing (argon2) now waits behind a gate that lets only a few hashes run at once.
- M2: Anonymous child-forge spawns are recorded in a table. A slot is taken before the spawn starts, so two racing requests cannot both get past the cap. The slot is handed back if the spawn fails or returns a forge that already existed. There is a new forge-wide daily cap,
spawn.anon_per_forge(default 20), and the count survives restarts. - M6: Saved idempotency responses no longer keep tokens, webhook secrets or invite links. Fields that are shown only once are removed wherever they sit in the response.
- L1:
POST /api/v1/sessionsrefuses a cross-origin request before it sets a cookie. - L3: Markdown links containing a control byte, or a
//hostdisguised with backslashes, are refused.
This push also merges the latest main; both conflicts came from the two sides adding code in the same place:
src/settings/limits.ts: keeps both new limits,spawn.anon_per_forgefrom this branch andapi.anonymous_per_sourcefrommain.src/spawn/door.ts: keeps this branch's reserve-then-release in place ofmain'scheckAnonSpawn, and keepsmain'sstartedAtandstartWatchliveness watch for each new child.
The type check is clean, and the 305 tests in the 45 files covering spawn, limits, sign-in, sessions and settings pass after the merge. I did not run the full suite here; the forge's check runs it on this push.
To try it, on the preview:
- Start anonymous spawns from one address until you get a 429 naming the daily limit.
- Change "Anonymous child forges per forge a day" in the limits settings.
- Fail sign-in on one account from several addresses: other accounts can still sign in.
🤖 Generated with Claude Code
Hardens sign-in and the other doors a stranger can reach, for #2922. The six findings below have one commit each.
- M1, M3: Sign-in rate limits now count per account and per source, never across the whole forge. A stranger can no longer lock everyone out by failing logins from many addresses. Password hashing (argon2) now waits behind a gate that lets only a few hashes run at once.
- M2: Anonymous child-forge spawns are recorded in a table. A slot is taken before the spawn starts, so two racing requests cannot both get past the cap. The slot is handed back if the spawn fails or returns a forge that already existed. There is a new forge-wide daily cap,
spawn.anon_per_forge(default 20), and the count survives restarts. - M6: Saved idempotency responses no longer keep tokens, webhook secrets or invite links. Fields that are shown only once are removed wherever they sit in the response.
- L1:
POST /api/v1/sessionsrefuses a cross-origin request before it sets a cookie. - L3: Markdown links containing a control byte, or a
//hostdisguised with backslashes, are refused.
The latest main is merged in:
src/settings/limits.ts: keeps both new limits,spawn.anon_per_forgefrom this branch andapi.anonymous_per_sourcefrommain.src/spawn/door.ts: keeps this branch's reserve-then-release in place ofmain'scheckAnonSpawn, and keepsmain'sstartedAtandstartWatchliveness watch for each new child.
The last check failed on two tests:
test/threats-doc.test.ts: the sign-in line indocs/THREATS.mdnamed two test files, and the doc's rule is one per protection. The doc was wrong, not the test: the line now names onlytest/signin-lockout.test.ts, the suite that tests the claim. That test passes now.test/tui-size.test.ts: this branch doesn't change the TUI, and the test passes on every local run. The failure most likely came from load: three other shards were killed with exit 143 in that run. Nothing was changed for it.
To try it, on the preview:
- Start anonymous spawns from one address until you get a 429 naming the daily limit.
- Change "Anonymous child forges per forge a day" in the limits settings.
- Fail sign-in on one account from several addresses: other accounts can still sign in.
🤖 Generated with Claude Code
Hardens sign-in and the other doors a stranger can reach, for #2922. The six findings below have one commit each.
- M1, M3: Sign-in rate limits now count per account and per source, never across the whole forge. A stranger can no longer lock everyone out by failing logins from many addresses. Password hashing (argon2) now waits behind a gate that lets only a few hashes run at once.
- M2: Anonymous child-forge spawns are recorded in a table. A slot is taken before the spawn starts, so two racing requests cannot both get past the cap. The slot is handed back if the spawn fails or returns a forge that already existed. There is a new forge-wide daily cap,
spawn.anon_per_forge(default 20), and the count survives restarts. - M6: Saved idempotency responses no longer keep tokens, webhook secrets or invite links. Fields that are shown only once are removed wherever they sit in the response.
- L1:
POST /api/v1/sessionsrefuses a cross-origin request before it sets a cookie. - L3: Markdown links containing a control byte, or a
//hostdisguised with backslashes, are refused.
The latest main is merged in:
src/settings/limits.ts: keeps both new limits,spawn.anon_per_forgefrom this branch andapi.anonymous_per_sourcefrommain.src/spawn/door.ts: keeps this branch's reserve-then-release in place ofmain'scheckAnonSpawn, and keepsmain'sstartedAtandstartWatchliveness watch for each new child.
docs/THREATS.md now names one test file for the sign-in protection, as the threats-doc test requires.
Sentinel's review asked for three tests and a comment, all now in. I deleted each of the three lines again, and each time the matching new test failed:
- Full hash gate (
test/signin-lockout.test.ts): fills the realpasswordHashesgate, then makes three sign-in attempts that each come backthrottledwithretryAfter: 1. Afterwards the account at that source still gets all three of itssignin.per_accountattempts. This test needsadmission.giveBack()onbusyinsrc/core/users.ts. - Spent source window (same file): a source runs out of its
signin.per_sourcebudget, and its refused attempts atsamcost nothing. Once the source limit is raised,samfrom that source still has every attempt. This test needslimiter.refund(accountKey)insrc/core/signin-window.ts. - Spawns that make nothing (
test/spawn-anon.test.ts): goes throughPOST /api/v1/forges. Three repeats of an existing child and three refused plans under a taken name use no daily slot: the next three spawns get 201 and the fourth gets 429. This test needs the release insrc/spawn/door.ts.- The test calls
setStrangerLimits(app, {})first. The earlier tests in that file already use upmain's limit of 10 stranger plans a minute.
- The test calls
SHOWN_ONCEcomment insrc/http/server.ts: matching fields by name means a publiclinkcomes back from a replay as the note. The comment now says this is the chosen cost, because missing a secret would be worse.
The type check is clean, and the sign-in, anonymous-spawn, idempotency and threats-doc suites pass (46 tests).
To try it, on the preview:
- Start anonymous spawns from one address until you get a 429 naming the daily limit.
- Change "Anonymous child forges per forge a day" in the limits settings.
- Fail sign-in on one account from several addresses: other accounts can still sign in.
🤖 Generated with Claude Code
This fixes the six perimeter findings from #2922, one commit each, and each has a test. The type check is clean, and
bun testpassed 285 tests (2 skipped) over the touched suites and the five cross files.src/core/signin-window.ts): the per-account limit now counts per (account, source), so guesses at the admin's name only shut out the guesser's own source. The forge-wide window is gone from sign-in, since a stranger could fill it and close password sign-in for everyone. Passkeys and tokens never go through these windows, so they remain the operator's way in. An attempt refused by the per-source window is no longer counted against the account either.src/core/hash-gate.ts): every password check now waits at one shared gate per process, with 4 checks running at once and 32 waiting. Past that, the attempt is refused as throttled withRetry-After: 1and costs nothing, so it isn't counted against the person. This also covers the CPU cost that the old forge-wide window used to cap.signin.per_forgenow governs only the first-admin claim, and it is relabelled on /admin/limits to say so.withoutShownOnceinsrc/http/server.ts): fields namedtoken,secret,link(invite links) orclaimUrlare replaced with the "shown once" note before being stored, at any depth in the answer. A retried POST therefore gets the note in place of the token or webhook secret, the same way spawned-forge claim links already behaved.POST /api/v1/sessionsrefuses a cross-origin call before it sets a cookie or counts an attempt./\hostand\\host, which browsers read as//host; that wasn't in the issue.anon_spawntable (migration20261019180000), so a restart no longer resets the allowance. There is a new forge-wide daily cap,spawn.anon_per_forge(default 20), on /admin/limits. A slot is reserved before the spawn and given back if no forge was made, so two requests can't race for the last slot.Test changes:
test/spawn-anon.test.ts,resetAnonSpawnsnow takes the forge's database. The test passesapp.dband drops a reset that ran before the app existed, which a fresh data directory makes unnecessary.test/signin-throttle.test.tsno longer mentions the forge-wide 200; its assertions are unchanged.docs/THREATS.mdto match.Not done:
To try it:
bun test test/signin-lockout.test.ts test/spawn-anon-ledger.test.ts test/idempotency-secrets.test.ts test/markdown-links.test.ts test/signin-password-doors.test.ts🤖 Generated with Claude Code
Closes #2922