Skip to content

fix: validate schemeful action origins - #15420

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

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

Conversation

@brophdawg11

Copy link
Copy Markdown
Contributor

Backport of #15419 to v7.

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 build and 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-15420&path:packages/react-router"

And/or install other packages via:

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

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

@brophdawg11 brophdawg11 changed the title Backport action origin validation to v7 fix: validate schemeful action origins Aug 20, 2026
@brophdawg11
brophdawg11 merged commit e4b70d6 into v7 Aug 20, 2026
6 checks passed
@brophdawg11
brophdawg11 deleted the brophdawg11/codex-v7-validate-schemeful-action-origins branch August 20, 2026 19:56
@github-actions

Copy link
Copy Markdown
Contributor

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

@maranomynet

Copy link
Copy Markdown

Like so many other people I'm seeing deployed servers returning 400 errors, seemingly because they're behind a TLS termination proxy (azure hosting, etc.). The origin and request hostnames match but the protocol is different.

What's the solution for us?

@maranomynet

Copy link
Copy Markdown

It seems that this change makes the default react-router-serve server all but completely unusable for normal production deployments.

An I understanding this correctly?

@brophdawg11

Copy link
Copy Markdown
Contributor Author

Can't you use allowedActionOrigins: ["whatever.com"] to permit these origins through?

0xcapp3 pushed a commit to 0xcapp3/nitrogen-template that referenced this pull request Oct 8, 2026
react-router 7.18.3 tightened action-origin validation from a host-only
comparison to a full-origin (scheme + host + port) comparison
(remix-run/react-router#15420). Under `shopify app dev` TLS terminates at
the tunnel and the CLI's reverse proxy forwards over plain HTTP without
setting X-Forwarded-Proto, so the app computes `request.url` as
`http://<host>` while the browser sends `Origin: https://<host>`. The
origins differ on scheme alone and every action POST returns 400 at
singleFetchAction. Loaders are unaffected.

The same change breaks production too: `@react-router/serve` never enables
Express `trust proxy`, so a deployed app behind any TLS terminator computes
`http:` the same way.

Pinning all five packages to 7.18.2 restores host-only checking for both
dev and production. Upstream treats the new behaviour as correct and
prescribes the `allowedActionOrigins` config option rather than a fix, so
this is not waiting on a patch release — adopting `allowedActionOrigins`
additionally needs a build-time story for `react-router-serve`, since the
value is baked into the production build.

Separately, qs 6.15.3 arrives transitively through
`@react-router/serve` -> `express@4.22.2` and is vulnerable to
CVE-2026-82562 and CVE-2026-82417, both fixed in 6.16.0. express 4 declares
`~6.15.1` and no express 4.x release takes 6.16.0, so an override is the
only route on the 7.x line. The override is declared in all three package
manager dialects because CI installs with npm, yarn and pnpm, and pnpm
ignores npm's `overrides` field.

Fixes Shopify#279

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Assisted-By: devx/db94de98-756a-4388-807e-9cb6cf39d5de
@maranomynet

Copy link
Copy Markdown

Can't you use allowedActionOrigins: ["whatever.com"] to permit these origins through?

I'd prefer the project to remain unconcerned with how/where it's deployed during testing, staging, etc.

We ended up writing a whole custom Express server only to add a single "trust proxy" setting.

It feels like the claim that the default server is "production-ready"
is mostly technically true, unless one is happy about hard-coding all possible domain names into the config file, or figures out some ENV variable injection hack in the pipelines to make it work in pretty standard deployment setups.

@brophdawg11

Copy link
Copy Markdown
Contributor Author

I would venture to guess most apps deploy to one or a small few domain names, so "all possible domain names" seems like overkill for most apps.

The other option is we add a react router server config field for enableTrustProxy, which opens up a rabbit hole for requests for enableCompression and then enableMorgan and then those explode out into requests for options to pass along to those specific configs to and then in the end all we have created is a much crappier way to configure an express server than just ... writing an express server 🙃

@brophdawg11

Copy link
Copy Markdown
Contributor Author

Also, on a slight tangent - in this agentic world, I'm starting to think that super lightweight wrappers like this aren't really even providing the same benefit any longer and apps/agents would be better off just owning the lines of code directly.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants