Public: anyone can read this; the crew can change it.
A sign-in or consent redirect target that points off this origin is ignored #13607
Merged 18d 14h ago, live in production
A return address containing a tab no longer sends a signed-in person off this forge. safeNext in src/web/returnto.ts is the one check every door uses on its next. It already refused //host, https://host, backslashes and CR/LF, but let tabs and other control characters through.
-
Reviews
ApprovedApproved. Preview checked: /login?next=%2F%09%2Fevil.example redirects to /signin with no next; a deep link /settings/keys?a=1 is kept. safeNext now refuses every control character and any value a URL parser resolves off-origin. The 16-row hostile table runs through safeNext, POST /signin, the aliases, both forms, consent and the everyday switch. The fork-follow-word race fix is small, and its comment says why. No UI markup changed, so there is no design-principle break. Next, two things I would do: (1) hoist the HOSTILE table into test/helpers so the OAuth redirect_uri and other next-readers can reuse it; (2) add a gate or lint rule that every door reads next through safeNext, so a new door cannot skip it.
-
Checks
shipped production is serving it deploy bd6dc66
-
History
- The fork-follow-word test stops racing its own background follow: the fork is not following while the parent moves in setup 0c05967
- Merge remote-tracking branch 'origin/main' into scout/13580-a-sign-in-or-consent-redirect-target-tha bf58b85
- Every error response (400, 404, 405, 413, 429, 500) keeps the security floor headers, proven by provoking each (#13611) 1e1f4e8
- From an owner's app and a preview, the toolbar's home, comment and tell links all answer, proven by one journey test (#13608) e9a3c7c
- The wallet's spends download as one CSV through the data export door (#13412) ce1f2f0
- A wave's page says how close it is to done: closed of total changes in one sentence and one bar, server-rendered (#13450) 96a8a99
- The toolbar's panel closes on Escape and returns focus to the button that opened it (#13596) 8d243e0
- The forge toolbar's script and style stay under a stated size and add no layout shift, proven by a test (#13532) da75a4f
- The signed-in home answers its first page inside a stated budget on a forge with 5,000 events, measured by query plan and Server-Timing (#13595) c5a7eaa
- The data volume has under 15% free (#13594) edc375d
- The home page carries no warning banner: a test fails if any notice renders above the first content on / for a healthy forge (#13452) f40dc80
- An app's fetch to an undeclared host fails with the forge's own words, and a test shows the text names the host and forge.json egress (#13552) 13d731e
- A template page shows how long its last forge took from the click to a first live change, as one line (#13454) 066c590
- A maintenance duty files one issue naming open pulls whose check has been red for over 24 hours with no push (#13554) a5a2fb6
- A story wave page shows how many of its milestone's issues are done as 'N of M' with one bar drawn in CSS (#13479) 6d0822a
- /templates filters by name with a ?q= kept in the URL, and says so when nothing matches (#13547) 64fd138
- The signed-in home's first paint reserves space for everything that loads later, proven by a test on the rendered HTML (#13503) dfa578c
- The not-found and failed pages have looks at 390 and 1280 px, light and dark (#13536) b6a5c4b
- The feed filters by one app with a plain link, kept in the URL, and a filtered feed says which app it shows and how to clear it (#13439) 8e1544d
- An app's page lists its forks as a plain list with each fork's owner and how long ago it last changed (#13509) 274c390
2 earlier comments
A return address containing a tab no longer sends a signed-in person off this forge. safeNext in src/web/return_to.ts is the one check every door uses on its next. It already refused //host, https://host, backslashes and CR/LF, but let tabs and other control characters through. A browser deletes those before reading an address, so /signin?next=%2F%09%2Fevil.example became //evil.example after sign-in.
The fix:
safeNextnow refuses every control character (U+0000–U+001F and U+007F).- It also refuses any value that the URL parser resolves to another origin, which covers forms nobody listed.
- Plain paths with a query string still come through unchanged, so deep links keep working.
The test: test/redirect-targets.test.ts has one table of 16 hostile inputs, including //host, https://host, javascript:, backslashes, tab, LF, CRLF, NUL, %2F%2F…, a leading space and a bare host. It runs them through:
safeNextitself;POST /signin, which redirects to/;- the
/loginand/sign-inaliases, which redirect to/signinwith nonext; - the
/signinand/signuppages, which must not mention the hostile host anywhere; - the OAuth consent page
/oauth/authorizeand the everyday-account switchPOST /settings/everyday/switch. Signed out, both send the person to/signin?next=with their own path, whatevernextorredirect_uriis passed.
Three deep links, including /kim/proj/issues?state=open&q=a%20b, still go back to themselves.
With the old safeNext, four of the six tests fail. The consent and everyday-switch rows already held before this change; for those, the test is the proof. I didn't change OAuth redirect_uri handling: by design it goes to the client's own registered address, which can be on another origin, and it is checked against what that client registered.
Checks: the gate, tsc --noEmit and seven test files pass (the new one plus web-ui, deadends, deadends-fixes, toolbar-signed-out, web-browse and guest-contribute). scripts/fast.ts named 2015 test files, too many to run in the sandbox, so the forge's full check covers the rest. I couldn't record the plan on the issue because there was no keep_plan tool in this session.
Try it: on the preview, open /login?next=%2F%09%2Fevil.example and sign in. You land on /. Then open /login?next=%2Fsettings%2Fkeys%3Fa%3D1 and sign in. You land on /settings/keys?a=1.
🤖 Generated with Claude Code
<!-- look-pages b3e3124961c1 --> Look pages for b3e3124, from the gate:
look pages (inferred): this pull changes src/web/return_to.ts; the forge pictures / (src/web/return_to.ts), /docs (src/web/return_to.ts), /explore (src/web/return_to.ts) and 20 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
A return address on sign-in or consent is now refused if it contains a tab or other control character, or if a URL parser would read it as another origin. Opening /login?next=%2F%09%2Fevil.example and signing in lands on /, not on evil.example (#13580).
Changes
src/web/return_to.ts:safeNextrejects these addresses, which the old check let through.test/redirect-targets.test.ts: covers them at the boundary and through a real sign-in.
Fix for the check's red
The check failed on 2 tests in test/fork-follow-word.test.ts, which is unrelated to this change. They pass here every time, alone and in all of check shard 9, before and after merging main.
The cause is a race in that test. In setup, the parent's second commit starts a follow of the fork in the background. On a busy shard that follow can finish after the first test has switched the fork to take-updates. The follow reads the mode only when it finishes, so it then merges the parent, and the fork is no longer "1 behind". The test was wrong, not the app: setup now sets the fork to dont-follow for that one push, and every later test sets the mode it needs.
That leftover follow also printed "Cannot use a closed database" after the file finished. That error no longer appears, which confirms the follow was outliving the file.
Checks
bun scripts/gate.ts --fixpasses; it noted that/,/docs,/exploreand 25 more pages importreturn_to.ts, so the forge pictures them.bun x tsc --noEmitis clean.test/fork-follow-word.test.tsandtest/redirect-targets.test.tspass, 11 tests.
The branch also merges current main.
🤖 Generated with Claude Code
A return address containing a tab no longer sends a signed-in person off this forge.
safeNextinsrc/web/return_to.tsis the one check every door uses on itsnext. It already refused//host,https://host, backslashes and CR/LF, but let tabs and other control characters through. A browser deletes those before reading an address, so/signin?next=%2F%09%2Fevil.examplebecame//evil.exampleafter sign-in.The fix:
safeNextnow refuses every control character (U+0000–U+001F and U+007F).The test:
test/redirect-targets.test.tshas one table of 16 hostile inputs, including//host,https://host,javascript:, backslashes, tab, LF, CRLF, NUL,%2F%2F…, a leading space and a bare host. It runs them through:safeNextitself;POST /signin, which redirects to/;/loginand/sign-inaliases, which redirect to/signinwith nonext;/signinand/signuppages, which must not mention the hostile host anywhere;/oauth/authorizeand the everyday-account switchPOST /settings/everyday/switch. Signed out, both send the person to/signin?next=with their own path, whatevernextorredirect_uriis passed.Three deep links, including
/kim/proj/issues?state=open&q=a%20b, still go back to themselves.With the old
safeNext, four of the six tests fail. The consent and everyday-switch rows already held before this change; for those, the test is the proof. I didn't change OAuthredirect_urihandling: by design it goes to the client's own registered address, which can be on another origin, and it is checked against what that client registered.Checks: the gate,
tsc --noEmitand seven test files pass (the new one plusweb-ui,deadends,deadends-fixes,toolbar-signed-out,web-browseandguest-contribute).scripts/fast.tsnamed 2015 test files, too many to run in the sandbox, so the forge's full check covers the rest. I couldn't record the plan on the issue because there was nokeep_plantool in this session.Try it: on the preview, open
/login?next=%2F%09%2Fevil.exampleand sign in. You land on/. Then open/login?next=%2Fsettings%2Fkeys%3Fa%3D1and sign in. You land on/settings/keys?a=1.🤖 Generated with Claude Code
Closes #13580