Repository navigation
fix: validate schemeful action origins - #15420
Conversation
Assisted-By: devx/597728f0-1b3f-4153-b929-18dbff6cd683
Preview Build AvailablePreview builds have been created for this PR. You can install 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. |
|
The preview branch |
|
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? |
|
It seems that this change makes the default An I understanding this correctly? |
|
Can't you use |
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
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" |
|
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 |
|
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. |
Backport of #15419 to
v7.What does this change?
Improves validation of action request origins by considering the complete URL context.
Explicit
allowedActionOriginshostname and wildcard behavior remains unchanged.Testing
react-routerbuild and typecheck