Skip to content

fix(plugin-auth)!: SSO discovery fetches only hosts that resolve to public addresses - #35697

Merged
os-zhuang merged 6 commits into
mainfrom
claude/sec2-r67h-sso-discovery-public-hosts
Nov 20, 2026
Merged

os-zhuang merged 6 commits into
mainfrom
claude/sec2-r67h-sso-discovery-public-hosts

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

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

Derived gate families on ba221aa (106)

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))

Package and dogfood runs on ba221aa
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 ba221aaa508
Ablation legs
AFTER leg (HEAD 9377c648212): Tests 1 failed | 41 passed (42)   -- the sign-out update fixture, fixed in 99910115f1d
ABLATION leg: before-hook from the merge base, blob 990a149fe2 == merge-base blob, check occurrences 0
  Tests 7 failed | 35 passed (42)
RESTORED: blob 62eb4d262d == HEAD; git diff HEAD empty
ORDER ABLATION (HEAD ba221aaa508): before-hook from 32d1f053b45, blob 62eb4d262d, order signout@613 publichost@620
  Tests 2 failed | 42 passed (44)
RESTORED: blob 5ec97d7362 == HEAD; order publichost@621 signout@635; git diff HEAD empty

Generated by Claude Code

…ublic addresses

The host a registration's discovery document is read from is resolved
before the vendor's register endpoint runs, and every address must be
public, unless the deployment's configured trusted origins list it. The
origins a registration names stay trusted for that registration's
discovery checks, handed on only for an admitted actor and only after
this check.

Claude-Session: https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL
Co-authored-by: Claude <noreply@anthropic.com>
…ne host resolved

Claude-Session: https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL
Co-authored-by: Claude <noreply@anthropic.com>
…ly in the sign-out update case

The registration step reads its discovery document only from a host that
resolves to public addresses, so the case registers under that resolution
and moves the issuer's host to a private address for the update it judges.

Claude-Session: https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-auth, touching 9 documentable anchor(s).

3 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/kernel/contracts/auth-service.mdx (via AuthManager (symbol, a top-level class))
  • content/docs/kernel/services-checklist.mdx (via AuthManager (symbol, a top-level class))
  • content/docs/permissions/authentication.mdx (via AuthManager (symbol, a top-level class))

⛔ 3 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v18/18-2.mdx (via AuthManager (symbol, a top-level class))
  • content/docs/releases/v18/18-3.mdx (via AuthManager (symbol, a top-level class))
  • content/docs/releases/v18/18-4.mdx (via AuthManager (symbol, a top-level class))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 anchor(s) matched too much of the corpus to be a work list: VALIDATION_FAILED (literal, 50 pages)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json d44b5e3daa828f7402c182770d0c025e537ed726 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 2a913715ffb494d1361fab5b027bcc17b2c94603 — the merge of head ba221aaa508ff6e65051119bf91fb1447f8a65b9 into base d44b5e3daa828f7402c182770d0c025e537ed726, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 2a913715ffb494d1361fab5b027bcc17b2c94603 && git checkout 2a913715ffb494d1361fab5b027bcc17b2c94603
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin d44b5e3daa828f7402c182770d0c025e537ed726 ba221aaa508ff6e65051119bf91fb1447f8a65b9 && git checkout -B drift-repro d44b5e3daa828f7402c182770d0c025e537ed726 && git merge --no-ff ba221aaa508ff6e65051119bf91fb1447f8a65b9

node scripts/docs-audit/affected-docs.mjs --json d44b5e3daa828f7402c182770d0c025e537ed726

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs d44b5e3daa828f7402c182770d0c025e537ed726 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · os-elon-musk · session_016WV4czt69hUUaG5XcgFNYL

Contract-review-claim: session_016WV4czt69hUUaG5XcgFNYL · head 32d1f05 · 2026-11-20T00:19Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · os-elon-musk · session_016WV4czt69hUUaG5XcgFNYL

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 32d1f053b45c73a56452d3e2cb04547412acf69f
Local-runs: none
Scope: .changeset/sso-discovery-public-hosts.md (declaration lines), packages/plugins/plugin-auth/src/auth-manager-before-hook.ts, packages/plugins/plugin-auth/src/auth-manager.ts, packages/plugins/plugin-auth/src/sso-discovery-companion-origins.ts, packages/plugins/plugin-auth/src/sso-discovery-companion-origins.test.ts + packages/plugins/plugin-auth/src/sso-sign-out-of-idp.ts and @better-auth/sso 1.7.12 (discoverOIDCConfig, validateDiscoveryUrl, fetchOIDCEndpoint, assertEndpointResolvesPublic, the /sso/register handler) and @better-auth/core/utils/host (cited code outside the diff: read, never reviewed). content/docs/permissions/sso.mdx is a prose face, left to the seat's ACCEPT.
Security-touching: yes

Inputs: no card (a no-card order); the PR body, file list and net diff against merge base 986a0f208c8; the check-runs on this head; the dev evidence on this head. Narrowing face: no hits, the whole diff outside the prose face is the floor.

Check-runs on this head, read once: every completed run is success or skipped, none failed. Test Core shards 1/10 to 10/10, TypeScript Type Check, Lint & Repo Gates, Dogfood Regression Gate, Build Core, Build Docs, Check Changeset, Governed Surface Queue Guard and the PR-body guards are success. The Test Core aggregate still read in_progress at the time of the read; the seat confirms it before any merge.

① Derived judgments

  • Accept set of POST /sso/register, narrowed — right. An OIDC registration that reads a discovery document (no skipDiscovery), whose discovery URL is an http(s) URL on a public-looking name that the configured trusted origins do not list, and whose name resolves to at least one address isPublicRoutableHost refuses, was admitted to the vendor endpoint and is now refused 400 VALIDATION_FAILED before it. Every other registration is answered as before. The narrowing makes real, at registration, the refusal the vendor already applies to the endpoints it reads at sign-in; it takes no declared capability away, because OS_TRUSTED_ORIGINS stays the declared way to register a provider on an internal network and the check returns before resolving for a configured origin.
  • The host resolved is the host the vendor reads — right. ssoRegisterDiscoveryRead picks oidcConfig.discoveryEndpoint, else computeDiscoveryUrl(issuer); the vendor's discoverOIDCConfig picks existingConfig.discoveryEndpoint || computeDiscoveryUrl(issuer) with the same function. The hook reads the body before the vendor's schema parse, and each divergence falls on the stricter side: a skipDiscovery that is not literally true, or a non-string discoveryEndpoint, is still resolved here and then refused by the vendor's schema. The vendor's register handler makes no other server-side read (SAML registration fetches nothing; redirects are refused, redirect: "manual").
  • Why the check is not redundant — right. The vendor fetches discovery only from a trusted origin (validateDiscoveryUrl) and skips its own resolution for a trusted origin (assertEndpointResolvesPublic), so once the body-named origins join the endpoint's trusted origins the vendor resolves nothing for that host. The diff resolves it first, against the configured predicate alone, and hands the body-named origins on only afterwards.
  • Body-named origins handed on only for an admitted actor — right, and a second narrowing. At the merge base ssoDiscoveryTrustedOrigins(body) reached the context change for every request; now it stays [] unless the actor resolved, is not held and is a platform admin. A request with no resolved actor reaches the vendor with the configured trust plus the fixed companion table only, so its discovery URL is read only when the deployment lists it. No session still answers the vendor's 401, and no name is resolved for it or for a refused non-admin (403 is thrown first).
  • Early returns — right as a mirror of the vendor. An address literal and a non-public name are not resolved: neither enters ssoDiscoveryTrustedOrigins (same predicate), so the vendor refuses them unless configured. A name that fails to resolve, an empty answer, and a runtime without node:dns/promises are left to the read, as assertEndpointResolvesPublic leaves them. Resolved addresses are judged by the same predicate, which unmaps IPv4-mapped IPv6 before classifying.
  • Public surface — right. No package export moves (sso-discovery-companion-origins.ts is not re-exported from the package entry); no schema key, error code or stored row changes. VALIDATION_FAILED is plugin-auth's registered code. The bridge relays 400 SSO_REGISTER_FAILED, pinned by a case.
  • The member the refusal names — wrong in one case, see S1. The changeset and the PR body publish "refused on issuer (or oidcConfig.discoveryEndpoint)" without qualification.

② Semver level

@objectstack/plugin-auth: patch, with the bang, the BREAKING banner, Clause-②: no (narrowing), Metadata-protocol: none and an ADR-0087 not-required (no-migration-prescription) disposition. This matches what the diff publishes: one runtime answer of an HTTP door is narrowed, no metadata author writes an SSO registration, so the kind is none and AGENTS.md Post-Task Checklist step 3 sends a non-protocol breaking change to patch with its banner and disposition kept. The banner names the affected caller and the one-line fix (list the origin in OS_TRUSTED_ORIGINS). The Clause-②: line is the same on the PR body and the changeset, and (narrowing) is the correct arm. Check Changeset is success on this head.

③ Boundary flags

  • Dev flag, ordering against the sign-out switch's own discovery read: answered in S1. The rule itself holds in either order.
  • Dev flag, @objectstack/core/egress not reused: accepted for this PR. The stated reason (one rule and one way out at registration and at sign-in) is coherent with the code read.
  • Dev flag, three gate families NOT MEASURED locally: Lint & Repo Gates, Type Check · debt ledger and the Test Core shards are success on this head, so CI measured them.
  • Fixture triage (the sign-out update case re-seeded under a public answer): read; what the case pins is unchanged.
  • SQL push-down: not applicable. The diff adds no query, no id materialisation and no in-app join.
  • Private residuals held by the security seat: R1–R5 — graded in the seat's private notes. None is graded must-fix for this PR.

④ Design judgment

  • sso-discovery-companion-origins.ts — holds. refuseSsoDiscoveryHostNotPublic reads body only, takes the configured predicate and an injectable resolver, and agrees clause by clause with the vendor's assertEndpointResolvesPublic (configured trust first, FQDN only, lookup(all), every address judged). The refusal names the host, the member, the rule and the remedy. Tried and not broken: userinfo in the URL, numeric and bracketed literals (normalised to literals by URL parsing, left to the vendor's synchronous refusal), trailing-dot and metadata names (the shared predicate), a mixed public and private answer (refused), an explicit endpoint on another host than the issuer's (that host is the one resolved), a redirecting discovery host (the vendor refuses redirects).
  • auth-manager-before-hook.ts — holds on the rule; one ordering finding. The check runs inside the admitted-actor block, after the platform-admin, held-actor and domain gates, and bodyOrigins is assigned only after it.
    • S1 (should-fix) — with signOutOfIdp: true, the refusal does not come from the new check. assertSsoSignOutOfIdpSupported runs first and reads the same discovery URL through the vendor's fetchDiscoveryDocument under the configured trust; for a host that resolves to a non-public address that read is refused by the vendor's own resolution, and the hook answers 400 VALIDATION_FAILED on signOutOfIdp with the vendor's error text relayed verbatim. The rule holds (nothing is read from the host), but the member is not issuer / oidcConfig.discoveryEndpoint as the changeset and PR body publish, the message is not the one this diff wrote (which by its own acceptance note names the host and the remedy and not the resolved address), and the name is resolved by a path other than the one the new describe pins. The pre-existing case "on register, its discovery read keeps the configured trust" pins field: 'signOutOfIdp' for exactly this input, so the suite currently holds the two answers apart. Fix: call refuseSsoDiscoveryHostNotPublic before assertSsoSignOutOfIdpSupported on the register branch and add the switch-on case to the new describe, or qualify the published member in the changeset. Either is a few lines; neither changes which registrations are admitted.
  • auth-manager.ts — a jsdoc hunk only; it agrees with the code (ssoDiscoveryTrustedOrigins judges by name, the register door resolves before handing the list on).
  • sso-discovery-companion-origins.test.ts — holds. The integration describe drives the real register door and the bridge with a node:dns/promises double and a fetch recorder, and asserts all three of status and member, nothing fetched from the host, and no row; the controls (public answer registers and fetches exactly the discovery URL, configured origin registers on a private answer, no session answers 401 and asks no name) keep the refusals from being vacuous. The unit describe pins which host is resolved and every early return. The ablation evidence (7 of 42 red with the hook at the merge base) shows the cases bind to the hook change.
    • N1 (nit) — no case pins a non-admin session (403) asking no name; the code order guarantees it today.
    • N2 (nit) — the module jsdoc says the register endpoint's discovery read is "the one server-side read"; true of the vendor endpoint, while the hook's sign-out check makes a second read of the same URL when the switch is on. One clause would say so.
  • .changeset/sso-discovery-public-hosts.md declaration lines — correct, see ②; the member sentence is covered by S1.

No must-fix. One should-fix (S1), two nits.

Implemented-by: claude/sec2-r67h-sso-discovery-public-hosts
Reviewed-by: isolated sub-agent of session_016WV4czt69hUUaG5XcgFNYL

VERDICT: PASS

…the sign-out switch's check

A registration whose discovery host does not resolve to public addresses is
refused on issuer or oidcConfig.discoveryEndpoint whatever signOutOfIdp says,
and the sign-out check reads the discovery document only after the rule has
admitted its host. The SSO guide and the module notes say what is checked.

Claude-Session: https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · os-elon-musk · session_016WV4czt69hUUaG5XcgFNYL

Contract-review-claim: session_016WV4czt69hUUaG5XcgFNYL · head ba221aa · 2026-11-20T01:08Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · os-elon-musk · session_016WV4czt69hUUaG5XcgFNYL

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: ba221aaa508ff6e65051119bf91fb1447f8a65b9
Local-runs: none
Scope: .changeset/sso-discovery-public-hosts.md (declaration lines), packages/plugins/plugin-auth/src/auth-manager-before-hook.ts, packages/plugins/plugin-auth/src/auth-manager.ts, packages/plugins/plugin-auth/src/sso-discovery-companion-origins.ts, packages/plugins/plugin-auth/src/sso-discovery-companion-origins.test.ts + packages/plugins/plugin-auth/src/sso-sign-out-of-idp.ts and @better-auth/sso 1.7.12 (discoverOIDCConfig, validateDiscoveryUrl, fetchOIDCEndpoint, assertEndpointResolvesPublic, the /sso/register handler) and @better-auth/core/utils/host (cited code outside the diff: read, never reviewed). content/docs/permissions/sso.mdx is a prose face, left to the seat's ACCEPT.
Security-touching: yes

Delta review. This head is one commit over 32d1f053b45, the head of record 7026276533, whose judgments stand for everything that commit does not touch; the commit was read in full (four files: the before-hook, the module jsdoc, the test file, the docs page) and the whole-PR diff against merge base 986a0f208c8 still names the same six files. Inputs: no card (a no-card order); the PR's diff; the check-runs on this head; the dev evidence on this head.

Check-runs on this head, read twice: 40 success, 17 skipped, none failed. Two were in_progress at both reads, Check Changeset and PR-body guards (claim · duplicate · Part-of · single-writer path); the seat confirms both before any merge. Test Core, type check, lint and the Dogfood Regression Gate are success.

① Derived judgments

  • Accept set of POST /sso/register — unchanged by the delta, right. The commit moves one call. Which registrations are admitted is the same as on the prior head: both checks must pass, in either order.
  • The member a refusal names, with signOutOfIdp: true — changed, right. A registration that reads a discovery document from a host resolving to a non-public address is now refused 400 VALIDATION_FAILED on issuer (or oidcConfig.discoveryEndpoint) with this diff's own message, whatever the switch says. On the prior head it was refused on signOutOfIdp with the vendor's text. The changeset's unqualified member sentence is now true for every registration that reads a discovery document.
  • Order of the register branch, read on the tree — right. resolveActor → assertActorNotHeld → platform-admin (403 SSO_REGISTER_FORBIDDEN) → assertSsoProviderDomainFree → refuseSsoDiscoveryHostNotPublic → assertSsoSignOutOfIdpSupported → bodyOrigins = ssoDiscoveryTrustedOrigins(body). Only the last-but-one pair swapped. The identity, held-actor, platform-admin and domain gates keep their places, and bodyOrigins is still assigned last, inside the admitted-actor block.
  • One answer that moved with the order — right, and worth knowing. A registration with the switch on that fails both the public-host rule and the sign-out capability rule (for instance a document naming no logout endpoint) now gets the public-host refusal first. That is the intended precedence.
  • Side effect of the sign-out check now sits behind the rule — right. The logout endpoint that check keeps for the after-hook is recorded only for a request the public-host rule admitted.
  • Public surface — unchanged. No export, schema key, error code or stored row moves in the delta.

② Semver level

Unchanged and still correct: @objectstack/plugin-auth: patch, with the bang, the BREAKING banner, Clause-②: no (narrowing), Metadata-protocol: none and the ADR-0087 not-required (no-migration-prescription) disposition. The delta does not touch the changeset, and it removes the one case in which the changeset's member sentence was inexact. Check Changeset was still in_progress on this head at the time of the read (it was success on the prior head with the same changeset); the seat confirms it.

③ Boundary flags

  • S1 of record 7026276533 (ordering against the sign-out switch's own discovery read): answered by the reorder, see ④.
  • N1 and N2 of that record: answered, see ④.
  • SQL push-down: not applicable. The delta adds no query, no id materialisation and no in-app join.
  • Private residuals held by the security seat: R1–R5 — graded in the seat's private notes. None is graded must-fix for this PR.

④ Design judgment

  • auth-manager-before-hook.ts — S1 resolved. refuseSsoDiscoveryHostNotPublic is called before assertSsoSignOutOfIdpSupported, and the comment says why. Both functions choose the discovery URL the same way for a register body (oidcConfig.discoveryEndpoint, else the issuer's well-known URL through the vendor's computeDiscoveryUrl), so the host the sign-out check reads is the host the rule just resolved. Tried and not broken: the reorder leaves no path on which the body-named origins reach the vendor before the rule ran, and none on which the sign-out read precedes it for a registration that reads a discovery document.
  • sso-discovery-companion-origins.test.ts — holds. The pre-existing switch-on register case now pins field: 'issuer'; a new case in the rule's own describe pins the same with the name asked, nothing fetched from the host and no row; the update-provider case still pins signOutOfIdp, which is correct, since the rule is a registration rule. The ordering ablation (2 of 44 red with the old hook, both the switch-on cases) shows these two bind to the order. N1 is done: a 403 SSO_REGISTER_FORBIDDEN control asserts no name asked and nothing fetched.
  • sso-discovery-companion-origins.ts — N2 done: the jsdoc now says the vendor's endpoint makes no other read and names the sign-out check's read of the same document.
    • N3 (nit) — "only after refuseSsoDiscoveryHostNotPublic has admitted its host" is exact for a registration that reads a discovery document. With oidcConfig.skipDiscovery and the switch on, the rule resolves nothing (the registration reads none) and the sign-out check still reads the document, under the configured trust and the vendor's own resolution; that registration is refused on signOutOfIdp, as before this PR. The rule holds there; the jsdoc clause and the docs sentence "refused on the same member" are each one qualifier short. No case pins this combination.
  • auth-manager.ts and the changeset declaration lines — untouched by the delta; the prior record's judgment stands.
  • content/docs/permissions/sso.mdx — prose face, not reviewed here. Noted for the seat only: the headline now states what the registration checks before reading, which is the claim the code supports.

No must-fix, no should-fix. One nit (N3).

Implemented-by: claude/sec2-r67h-sso-discovery-public-hosts
Reviewed-by: isolated sub-agent of session_016WV4czt69hUUaG5XcgFNYL

VERDICT: PASS

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 20, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-sales · session_01L6bhgUkbQqRUUFSiu2HGob

Recorded 2026-11-20T04:48Z. Pre-landing notice for this PR's owner. PR #35610 (card #35321, Tier H, awaiting approval) adds a narrowed leg at the merge queue. Once #35610 merges, a pull that declares a narrowing, as this one does, is refused at the queue unless two things are on its head: an authorized approval (or the authorized account's own enqueue), and a standing PASS contract review at CONTRACT_REVIEW_TIER. See the Landing impact section of #35610.

@os-zhuang
os-zhuang marked this pull request as ready for review November 20, 2026 04:52
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 20, 2026
@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 20, 2026
Merged via the queue into main with commit 1e692d1 Nov 20, 2026
68 checks passed
@os-zhuang
os-zhuang deleted the claude/sec2-r67h-sso-discovery-public-hosts branch November 20, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants