fix(middleware): authenticate hybrid context bridge#1943
Conversation
commit: |
|
|
/bigbonk review for issues |
/bigbonk review — fix(middleware): authenticate hybrid context bridgeReviewed the full diff, traced the data flow across dev/prod/worker paths, and ran the cited tests. This is a correct, well-targeted security fix. Summary below, plus a few minor observations (none blocking). What I verified ✅
Minor observations (non-blocking)
VerdictLGTM. The approach matches Next.js's model of stripping client-supplied middleware control headers, the secret-based authentication is the right mechanism for the legitimate hybrid bridge, and the ordering of the secret check relative to context mutation is correct. The minor items above are polish, not blockers. |
|
Review posted to PR #1943. SummaryVerdict: LGTM — correct, well-targeted security fix. The PR fixes a real vulnerability: before it, What I verified:
Minor non-blocking notes I flagged: the prod RSC path re-attaches the raw |
Impact
Externally reachable non-production App Router servers accepted a client-supplied
x-vinext-mw-ctxheader as trusted hybrid middleware state. An attacker could send{}to suppress real middleware execution, or provide an external rewrite URL to turn the dev server into an SSRF proxy, including forwarding POST bodies and attacker-provided credentials.Normal
NODE_ENV=productionhandling did not consume this bridge, but exposed development, preview, and shared internal servers were affected.Reproduction before this fix
Middleware bypass:
curl -i -H 'x-vinext-mw-ctx: {}' http://TARGET:3000/adminAttacker-controlled POST rewrite / SSRF:
Fix
x-vinext-mw-ctxas a vinext internal header and strip it at inbound request boundaries.Symbol.forkey on the Node process object.This follows Next.js's model of stripping client-supplied middleware control headers rather than trusting public request metadata.
Security regressions
/@id/virtual:vinext-rsc-entry/@id/__x00__virtual:vinext-rsc-entry/@id/__x00__virtual%3Avinext-rsc-entry/@id/%00virtual:vinext-rsc-entry{}cannot skip middleware.x-vinext-mw-ctxremains covered by vinext internal-header filtering.Validation
All targeted tests and checks pass.