Skip to content

fix: validate schemeful action origins - #15419

Merged
brophdawg11 merged 1 commit into
mainfrom
brophdawg11/codex-validate-schemeful-action-origins
Aug 20, 2026
Merged

brophdawg11 merged 1 commit into
mainfrom
brophdawg11/codex-validate-schemeful-action-origins

Conversation

@brophdawg11

Copy link
Copy Markdown
Contributor

What does this change?

Improves validation of action request origins by considering the complete URL context.

Explicit allowedActionOrigins hostname and wildcard behavior remains unchanged.

Testing

  • Action origin validation tests
  • react-router typecheck

Assisted-By: devx/597728f0-1b3f-4153-b929-18dbff6cd683
@github-actions

Copy link
Copy Markdown
Contributor

Preview Build Available

Preview builds have been created for this PR. You can install react-router using:

pnpm install "remix-run/react-router#preview/pr-15419&path:packages/react-router"

And/or install other packages via:

pnpm install "remix-run/react-router#preview/pr-15419&path:packages/react-router-dev"
pnpm install "remix-run/react-router#preview/pr-15419&path:packages/react-router-express"
pnpm install "remix-run/react-router#preview/pr-15419&path:packages/react-router-node"
pnpm install "remix-run/react-router#preview/pr-15419&path:packages/react-router-serve"

These preview builds will be updated automatically as you push new commits.

@github-actions

Copy link
Copy Markdown
Contributor

✅ CLA Signed

Thanks for signing the Contributor License Agreement.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Change File Found

One or more change files found.

Type Change
patch Improve validation of action request origins

@brophdawg11
brophdawg11 merged commit c091832 into main Aug 20, 2026
17 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

The preview branch preview/pr-15419 has been deleted now that this PR is merged/closed.

@brophdawg11
brophdawg11 deleted the brophdawg11/codex-validate-schemeful-action-origins branch August 20, 2026 19:48
@ryanflorence ryanflorence mentioned this pull request Aug 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hello there,

We recently published version 8.3.1 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

mattdjenkinson added a commit to datum-cloud/cloud-portal that referenced this pull request Sep 9, 2026
…1513)

## Summary

Every project page on staging fails with "Unexpected Server Error" since
#1512 rolled out. react-router 8.3.1 (upstream
remix-run/react-router#15419) tightened its CSRF guard to compare the
browser's `Origin` header against `request.url` including the scheme.
The gateway terminates TLS, so the pod sees
`http://cloud.staging.env.datum.net/...` while the browser sends
`Origin: https://cloud.staging.env.datum.net`, and the guard rejects
every action POST, starting with the project layout's session-cookie
action that fires on entering a project.

Two commits, released together:

1. **Allowlist the public hostnames** through `allowedActionOrigins`,
React Router's documented escape hatch for reverse proxies. The guard
stays active for any other origin.
2. **Honour `X-Forwarded-Proto`** with a small Hono middleware, first in
the global chain, that rebuilds the request React Router receives with
an `https://` URL whenever the header is exactly `https`. Method,
headers, body and abort signal carry over, and Sentry spans, session
cookies and redirects all see the corrected URL. A missing header or any
other value leaves the request untouched, so local dev and E2E are
unaffected. `X-Forwarded-Host` is deliberately not honoured because the
HTTPRoute never rewrites `Host`.

Verified against the production build: with the allowlist, POSTs with an
Origin of `cloud.staging.env.datum.net`, `cloud.datum.net` or
`cloud.prod.env.datum.net` return 204 while `evil.example.com` still
returns 400; with the middleware, the failing POST returns 204 once
`X-Forwarded-Proto: https` is present and 400 without it. Four unit
tests cover the middleware.

## Notes for reviewers

Production is still on v0.8.19 and unaffected until the next tag. The
one thing not verifiable locally is the gateway actually sending
`X-Forwarded-Proto: https`; Envoy does by default, and the allowlist
covers staging regardless. Supersedes #1514.

Refs #1512
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant