Repository navigation
Accept the authorization-request POST from any site (nemar-cli#2020) - #503
Merged
Merged
Conversation
Deploying nemar-website with
|
| Latest commit: |
b155866
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://88e76bc5.nemar-website.pages.dev |
| Branch Preview URL: | https://feature-issue-2020-authorize.nemar-website.pages.dev |
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Owner decision W1 of nemar-cli#2020 (phase B6, slice S6): OpenID Connect Core 3.1.2.1 requires
/oauth/authorizeto accept a form POST, and the conformance moduleoidcc-ensure-post-request-succeedssends it cross-site. Astro 6.3.3's built-incheckOriginanswers 403 to that before page code runs and has no exemption.security.checkOriginis nowfalse(astro.config.mjs).src/lib/origin-check.tsis the site's own check, run first inonRequest. It is Astro's rule line for line (a test sends 504 combinations of method, content type and Origin through both and compares), plus one exemption: methodPOST, path exactly/oauth/authorize, media type exactlyapplication/x-www-form-urlencoded. Origin is not consulted for the exemption.readAuthorizeInput(request, origin)answersforbidden(the built-in's 403, same body, before any API call) for any POST whose body namesnemar_consent_token,nemar_requestornemar_decision, unlessOriginequals the site's origin exactly andSec-Fetch-Site, when sent, issame-origin.check(sent to the API's check route, as the same string in a GET),invalidorforbidden; it can never reach the consent route.Commits: page refusal first (inert until the middleware exemption exists), then the middleware and config together, then ADR 0031 (0030 is taken on the epic branch), changelog and handoff.
Allow / deny (real
onRequest, then the page's input reader)/oauth/authorize, authorization bodycheckSec-Fetch-Site: cross-site/same-site/none)Sec-Fetch-Site: same-origin)consent/oauth/authorize/,//oauth/authorize,/OAUTH/authorize,/oauth/authorize%2f,/oauth/%61uthorize,/oauth/authorize.json,;x=1suffix, cross-siteastro devthe first Content-Type wins, with no security impact because the check and the page read the same header), no content type, cross-site, to/oauth/authorize/oauth/authorize, cross-sitesrc/pages(globbed, so new endpoints are covered), cross-site urlencoded / multipart / text-plain, null or missing Origin/oauth/authorize+ urlencodedThreat analysis
Sec-Fetch-Site, if present, issame-origin:null, a missing header, a sibling*.nemar.organd a forged Origin on a browser that says cross-site all fail. Any body naming any consent field counts, in any number, so a consent cannot be smuggled as an "authorization request" with a straynemar_decision. Behind that, the API's consent token is an HMAC bound to the session and the request, which a forging page cannot know. The consent screen sendsReferrer-Policy: same-originso its own form keeps its Origin (unchanged)./login?next=/oauth/authorize?<request>, wherenextpassessafeRedirectPath; the sign-in forms themselves (/api/auth/code/*) keep the cross-site refusal (swept by the route test).astro dev: the page's responses (503 panel, and the 403) carryX-Frame-Options: DENY,Content-Security-Policy: ... frame-ancestors 'none' ...,Cache-Control: no-store,Referrer-Policy: no-referrer. The consent screen's own headers were not observed in a browser (it needs a live API); itsframe-ancestors 'none'is pinned by the existingsrc/middleware.test.tscases. Nothing was missing, nothing was added.parseClientAndRedirect, nemar-cliservices/oidc-authorize.ts) exact-matchesredirect_uriagainst the client's registered list before any redirect (errors before that render a panel), and the page only follows alocationthat is absolutehttps(or loopbackhttp) with no credentials (usableLocation). The POST path feeds the same code.request, exactly as it forwards the GET query string; the API parses both with the sameURLSearchParams, so duplicates (client_id,redirect_uri, the single-valued list), order and precedence are identical, and a test asserts the POST body reads as the same string a GET would. A POST reads only its body; the URL's query is ignored (tested). The sign-in return trip uses the API's canonicalparams.toString(), a GET, andnemar_auth_afteris an API-signed marker bound to the client and a ten-minute window, so a body cannot forge one. The body is bounded at 32 KiB streamed; the API enforces its own 8192-character request limit.SameSite=Lax; __Host-(nemar-cliweb-session.ts), so a cross-site POST carries none and lands on sign-in (tested: POST -> 303 login -> GET with the same parameters). A same-site POST (sibling*.nemar.org) does carry it; that request is still only an authorization request, which a top-level GET from the same page would be too, and its consent is refused. Not changed.Gates
bun run lint: clean.bun run typecheck: 0 errors.bun run test: 168 files passed, 4628 passed, 14 skipped (3 files skipped, as before).bunx astro build: complete.src/lib/origin-check.test.ts(30),test/origin-check-middleware.test.ts(43, includes the config assertion and thesrc/pagessweep), additions tosrc/lib/oidc-authorize.test.tsandtest/oidc-authorize-ui.test.ts;src/middleware.test.tsPOST shims now carry their own Origin (the built-in used to refuse them beforeonRequest).startsWith("/oauth"),startsWith(path), strip trailing slash, lower-case, decode) killed 15/10/5/4/3 tests; drop content-type check 12; drop consent discrimination 8; page ignoresforbidden1 (the page-wiring source test); only the token names consent 2; same-origin test always true 6; drop Sec-Fetch-Site 3; exempt any method 7; config back on 1; middleware call removed 18; refuse all content types 4. Every one failed at least one test.astro devwith the API unreachable: cross-site authorization POST 503 (reached the page), cross-site consent POST 403, same-origin consent 503 (reached the API call),/oauth/authorize/,//oauth/authorize,/OAUTH/authorize,%2f,%61uthorize, multipart and/api/auth/logoutcross-site all 403. Same-origin//oauth/authorize,/OAUTH/authorizeand%2fare 404 (Astro does not route them);%61uthorizeroutes to the page, which is why that spelling is not exempt.Review round 1 (Opus)
crossSiteInputGate); the field list is one exported constant (OIDC_CONSENT_FORM_FIELDS) held to the parser's source by a test. Chosen over refusing everynemar_-prefixed key becausenemar_auth_afteris a legitimate authorization parameter.test/astro-origin-check-upgrade.test.tsfails when any Astro dist file other than the known five mentionscheckOrigin, or anything butcore/base-pipeline.jsreadsmanifest.checkOrigin; ADR 0031 has the upgrade checklist line.%2esegments and a tab normalize to the exact path and are exempt (tested); every spelling that reaches the page but is not exempt fails closed.Merge note
When
feature/issue-493-epic-compute-webmerges tostaging, both branches add a line after 0029 in.context/decisions/README.md(0030 there, 0031 here) and both edit.context/handoff.md. Resolution: keep both index lines in numeric order and both handoff sections.Not verified
The conformance suite itself, a browser run through a live API (S7), and the real consent screen's response headers.
Manual check added to
.context/handoff.md.