Repository navigation
Commit 1e692d1
fix(plugin-auth)!: SSO discovery fetches only hosts that resolve to public addresses (#35697)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D1WDVL9JpCQhTUF97fpymtZ)_
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no published skill teaches SSO provider
registration; the rule is written into the hand-written SSO guide in
this diff
## 维护者速读
- 平台管理员登记 SSO
身份提供方时,服务器先确认其发现文档所在主机解析到公网地址;解析到内网、回环等非公网地址且未列入部署受信来源的,现在直接拒绝并说明原因,其余登记照旧。
- 替部署运维统一规则:登记时就按登录时已在执行的同一条规则检查发现文档的主机,两处说法一致。
- 碰到的是把身份提供方放在内网、又没把它列入受信来源的部署:登记会被拒,运维把它的来源加入受信来源即可;本改动不动已存数据,可直接回滚。
- 无。
## What changes
SSO discovery fetches only hosts that resolve to public addresses.
- **The rule** (`refuseSsoDiscoveryHostNotPublic`,
`sso-discovery-companion-origins.ts`): before the vendor's `POST
/sso/register` endpoint runs, the host whose OpenID Connect discovery
document the registration reads (the explicit
`oidcConfig.discoveryEndpoint`, else the issuer's well-known URL,
computed with the vendor's own `computeDiscoveryUrl`) is resolved, and
every address must be public, judged by the vendor's own predicate
(`isPublicRoutableHost`). Otherwise the registration is refused `400
VALIDATION_FAILED` on `issuer` / `oidcConfig.discoveryEndpoint` and
nothing is read from the host. The Register SSO Provider bridge relays
it as `400 SSO_REGISTER_FAILED`.
- **Unchanged on purpose:** the origins a registration names stay
trusted for that registration's discovery checks (the untrusted-origin
verdicts); a discovery URL the deployment's configured trusted origins
(`OS_TRUSTED_ORIGINS`) list is not resolved here, so an identity
provider on an internal network still registers once listed; an address
literal and a non-public name are left to the vendor's own synchronous
refusals; a name that does not resolve, or a runtime with no
`node:dns/promises`, is left to the read, as the vendor leaves it.
- **Scope of the resolution is the one host the registration reads.** A
SAML registration and an `oidcConfig.skipDiscovery` registration read
nothing at registration and resolve nothing; endpoints such as the
token, userinfo and key-set URLs are not read at registration either
(the vendor resolves them when it reads them at sign-in).
- **The register door hands the body-named origins on only for an
admitted actor, and only after the check**
(`auth-manager-before-hook.ts`). A request with no session still gets
the vendor's `401`, and resolves no name.
- The code is the ledger-registered `VALIDATION_FAILED` (plugin-auth's
entry), so no error-code ledger change.
- Docs: the SSO guide's discovery section states the rule
(`content/docs/permissions/sso.mdx`).
## Read first
1. `packages/plugins/plugin-auth/src/sso-discovery-companion-origins.ts`
— `ssoRegisterDiscoveryRead` / `refuseSsoDiscoveryHostNotPublic`: which
host is resolved, and every early return (configured trust, literal,
non-public name, no resolver, lookup failure). Risk: a host the vendor
reads that this does not resolve.
2. `packages/plugins/plugin-auth/src/auth-manager-before-hook.ts` — the
`/sso/register` branch: the check sits after the platform-admin,
held-actor and domain gates and before the sign-out switch's check (so a
registration with that switch on is refused on the same member before
anything is read), and `bodyOrigins` is filled only inside the
admitted-actor block. Risk: ordering against the sign-out switch's own
discovery read.
3.
`packages/plugins/plugin-auth/src/sso-discovery-companion-origins.test.ts`
— the new top-level describes and the shared name-resolution double.
## Two-minute verification
`pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2
src/sso-discovery-companion-origins.test.ts` — expect every case green,
including the describe "SSO discovery reads only hosts that resolve to
public addresses".
## Tests
All readings on the final head `ba221aaa508`, under the shared verify
lock (lock outcome `command-exit`, rc 0).
- `@objectstack/plugin-auth` test: Test Files 287 passed (287) · Tests
6066 passed, 10 skipped (6076).
- `@objectstack/plugin-auth` typecheck: exit 0, including
`check:test-typecheck: OK` for the test layer.
- Full dogfood battery (`pnpm --filter @objectstack/dogfood test`, no
shard, no path, after building its dependency closure): exit 0 · Test
Files 482 passed, 3 skipped (485) · Tests 4093 passed, 68 skipped (4161)
· 1766.26s.
- New cases:
- describe "SSO discovery reads only hosts that resolve to public
addresses" drives the real register door with a `node:dns/promises`
double and a fetch recorder. It covers an issuer whose host resolves to
`10.0.0.5`, `127.0.0.1` or `169.254.169.254` (each refused `400
VALIDATION_FAILED` on `issuer`, nothing fetched, no row), a mixed public
and private answer, an explicit `oidcConfig.discoveryEndpoint`, and the
bridge (`400 SSO_REGISTER_FAILED`). With the sign-out switch on, a
privately resolving issuer is refused on `issuer` before the sign-out
check reads it. Controls: a non-platform-admin session answers `403
SSO_REGISTER_FORBIDDEN`, asks no name, fetches nothing and stores no
row; a public answer registers, the name is asked and exactly the
discovery URL is fetched; a configured trusted origin registers on a
private answer; no session answers `401` and asks no name.
- describe "the host a registration's discovery reads is the one host
resolved" (unit, injected resolver): issuer well-known URL; explicit
endpoint instead of the issuer; SAML, `skipDiscovery`, an empty body and
no body resolve nothing; configured trust, address literals, `localhost`
and a non-public name resolve nothing; a lookup error and an all-public
answer are not refused.
- Ablation of the ordering (one-shot, nothing kept): with
`auth-manager-before-hook.ts` restored to `32d1f053b45` (check after the
sign-out check), the test file went 2 failed, 42 passed (44): both
switch-on cases, field `signOutOfIdp` instead of `issuer`. Restored to
`HEAD` (blob `5ec97d7362`, `git diff HEAD` empty).
- Ablation of the check (one-shot, nothing kept, on `32d1f053b45`): with
`auth-manager-before-hook.ts` restored to the merge base (on-disk blob
`990a149fe2` equal to the merge-base blob, 0 occurrences of the check),
the test file went 7 failed, 35 passed (42): the six refusal cases and
the public control's resolved-name assertion. Restored to `HEAD` (blob
`62eb4d262d`, `git diff HEAD` empty).
## Acceptance notes
- **Fixture triage.** The sign-out update case (its update's discovery
read keeps the configured trust) used to register while the issuer's
host resolved to a private address, which registration now refuses. Its
setup now registers under a public answer and switches to the private
answer before the update; what it pins is unchanged.
- **Helper reuse.** `@objectstack/core/egress` is not reused: it is the
connect-time guard of the outbound HTTP surfaces with its own allow-list
(`OS_EGRESS_ALLOWED_TARGETS`). Registration judges with the vendor's own
predicate so that registration and sign-in apply one rule with one way
out (`OS_TRUSTED_ORIGINS`).
- **Resolution failure** is left to the read, as the vendor's own check
leaves it; the refusal names the host, the member, the rule and the
remedy, not the resolved address.
- **NOT MEASURED locally** (CI's Lint & Repo Gates owns each):
- `check:type-check-debt`: it starts a whole-workspace closure build;
stopped (exit 143) to free the shared lock.
- `check:dual-build-cjs-loads` and `@objectstack/spec
check:skill-examples`: exit 3, PREREQUISITE NOT MET (built output
outside this closure).
- `test:repo` (the vitest `repo` project) not run locally: the diff
touches none of its tests and the derivation does not name it; CI's Test
Core runs it.
## Verification
<details><summary>Derived gate families on ba221aa (106)</summary>
`node scripts/pm/dispatch-gates.mjs --commands` named 106 families for
this diff. On the final head: 103 exit 0, 2 exit 3 (PREREQUISITE NOT
MET), 1 NOT-MEASURED (`check:type-check-debt`; CI `Type Check · debt
ledger` success).
`--ran` reconciliation: `✓ dispatch-gates --ran: 106 derived famil(ies)
accounted for — 103 run, 3 NOT-MEASURED (2 DERIVED from a recorded exit
3, 1 claimed).`
Outside the derivation: `pnpm check:error-code-casing` exit 0 — `✓ no
unlisted lowercase error codes in 12955 scanned file(s) (ADR-0112).`
ADR-0087: `✓ check-adr-0087-registration: 1 declared-breaking
changeset(s), each carrying an ADR-0087 disposition.`
(`[BREAKING+bang+clause-②-narrowing] not-required
(no-migration-prescription)`)
</details>
<details><summary>Package and dogfood runs on ba221aa</summary>
```
closure build exit 0
plugin-auth build exit 0
plugin-auth typecheck exit 0 check:test-typecheck: OK
plugin-auth test exit 0 Test Files 287 passed (287) · Tests 6066 passed | 10 skipped (6076)
dogfood closure build exit 0
dogfood test exit 0 Test Files 482 passed | 3 skipped (485) · Tests 4093 passed | 68 skipped (4161)
tree clean after the run; HEAD at the end ba221aa
```
</details>
<details><summary>Ablation legs</summary>
```
AFTER leg (HEAD 9377c64): Tests 1 failed | 41 passed (42) -- the sign-out update fixture, fixed in 9991011
ABLATION leg: before-hook from the merge base, blob 990a149 == merge-base blob, check occurrences 0
Tests 7 failed | 35 passed (42)
RESTORED: blob 62eb4d2 == HEAD; git diff HEAD empty
ORDER ABLATION (HEAD ba221aa): before-hook from 32d1f05, blob 62eb4d2, order signout@613 publichost@620
Tests 2 failed | 42 passed (44)
RESTORED: blob 5ec97d7 == HEAD; order publichost@621 signout@635; git diff HEAD empty
```
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL)_
<!-- signed: security#2 · os-elon-musk ·
session_016WV4czt69hUUaG5XcgFNYL -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 5ed945b commit 1e692d1
6 files changed
Lines changed: 471 additions & 23 deletions
File tree
- .changeset
- content/docs/permissions
- packages/plugins/plugin-auth/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
181 | 195 | | |
182 | 196 | | |
183 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
595 | 599 | | |
596 | 600 | | |
597 | 601 | | |
| |||
605 | 609 | | |
606 | 610 | | |
607 | 611 | | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
608 | 634 | | |
609 | 635 | | |
| 636 | + | |
610 | 637 | | |
611 | 638 | | |
612 | 639 | | |
613 | 640 | | |
614 | 641 | | |
615 | 642 | | |
616 | 643 | | |
617 | | - | |
| 644 | + | |
618 | 645 | | |
619 | 646 | | |
620 | 647 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6188 | 6188 | | |
6189 | 6189 | | |
6190 | 6190 | | |
6191 | | - | |
6192 | | - | |
| 6191 | + | |
| 6192 | + | |
| 6193 | + | |
| 6194 | + | |
| 6195 | + | |
6193 | 6196 | | |
6194 | 6197 | | |
6195 | 6198 | | |
| |||
0 commit comments