Public: anyone can read this; the crew can change it.
The operator guard treats a trailing-dot hostname as the host it names #14976
Check · Review · Land · Live done — Landed and live in production.
The operator guard now treats git.example. as git.example. Before this change, an origin connected as https://git.example.
shipped production is serving it deploy 6b7374e
The operator guard now treats git.example. as git.example. Before this change, an origin connected as https://git.example. passed every check that the plain hostname's rules set up (#14954, from the deepsec report in #14771). Admin accounts and accounts that can push to protected repositories got through, and denied() said a protected repository wasn't protected.
The fix, in src/origins/operator.ts: a new normalHost() lowercases a hostname and removes one trailing dot. hostnameOf() and operatorHosts() both go through it. guarded, denied, checkCredential and writesPaused (which goes through guarded) all compare hostnames using those two functions, so they now see one spelling of each host. Push rules written as host.:owner/name get normalized the same way, because splitHost uses hostnameOf. The origin broker compares hosts with these same two functions, so it stays consistent too.
The test: test/origin-guard-trailing-dot.test.ts. I ran it before the fix to confirm the bypass: all 6 cases failed, and both the admin case and the push case came back passed. After the fix they all pass. It covers:
- the hostname normalizing itself
- the operator's variables written with a trailing dot
guardedanddeniedon a dotted origincheckCredentialrefusing an administrator (admin_account)checkCredentialrefusing an account that can push, under both an exact rule and a wildcard rule (can_push)
Not done: operatorClientId in src/origins/oauth.ts still compares hostnames on its own. With a dotted URL it doesn't find the operator's registered client id, so the person is asked to paste one. That makes sign-in less convenient but doesn't let anything past the guard, and the issue limits the change to operator.ts, so I left it alone.
Checks: scripts/gate.ts --fix and tsc --noEmit are clean. scripts/fast.ts said the change reaches 2382 test files, too many to run here, so I ran the 7 suites that cover the guard, the broker and operator sign-in: 66 pass, 0 fail. The forge's full check runs on this push.
To try it: bun test test/origin-guard-trailing-dot.test.ts. With the change to src/origins/operator.ts reverted, all 6 cases fail.
🤖 Generated with Claude Code
Approved. normalHost() lowercases and strips one trailing dot; hostnameOf() and operatorHosts() both use it, so guarded, denied, checkCredential and writesPaused see one spelling. Tests cover the admin and can_push bypasses and fail without the fix. No new dependency, no web surface, nothing dead. Next: (1) add a direct writesPaused test with a dotted host, since box 1 names it and it is currently covered only through guarded; (2) normalize the remaining hand-rolled host compares (oauth.ts:863 operatorClientId, origin_fetch.ts:43) so sign-in works with a dotted URL.
The operator guard now treats
git.example.asgit.example. Before this change, an origin connected ashttps://git.example.passed every check that the plain hostname's rules set up (#14954, from the deepsec report in #14771). Admin accounts and accounts that can push to protected repositories got through, anddenied()said a protected repository wasn't protected.The fix, in
src/origins/operator.ts: a newnormalHost()lowercases a hostname and removes one trailing dot.hostnameOf()andoperatorHosts()both go through it.guarded,denied,checkCredentialandwritesPaused(which goes throughguarded) all compare hostnames using those two functions, so they now see one spelling of each host. Push rules written ashost.:owner/nameget normalized the same way, becausesplitHostuseshostnameOf. The origin broker compares hosts with these same two functions, so it stays consistent too.The test:
test/origin-guard-trailing-dot.test.ts. I ran it before the fix to confirm the bypass: all 6 cases failed, and both the admin case and the push case came backpassed. After the fix they all pass. It covers:guardedanddeniedon a dotted origincheckCredentialrefusing an administrator (admin_account)checkCredentialrefusing an account that can push, under both an exact rule and a wildcard rule (can_push)Not done:
operatorClientIdinsrc/origins/oauth.tsstill compares hostnames on its own. With a dotted URL it doesn't find the operator's registered client id, so the person is asked to paste one. That makes sign-in less convenient but doesn't let anything past the guard, and the issue limits the change tooperator.ts, so I left it alone.Checks:
scripts/gate.ts --fixandtsc --noEmitare clean.scripts/fast.tssaid the change reaches 2382 test files, too many to run here, so I ran the 7 suites that cover the guard, the broker and operator sign-in: 66 pass, 0 fail. The forge's full check runs on this push.To try it:
bun test test/origin-guard-trailing-dot.test.ts. With the change tosrc/origins/operator.tsreverted, all 6 cases fail.🤖 Generated with Claude Code
Closes #14954