fix(dev): respect forwarded proxy headers - #15462
Conversation
kdelay
left a comment
There was a problem hiding this comment.
The dev server is not always behind a proxy, and trustProxy in 0.14.1 has no trust boundary: calling createRequest(req, res, { trustProxy: true }) directly, x-forwarded-host: evil.example.com, real.example.com yields http://evil.example.com/.
Vite's own host check reads only Host (isHostAllowed), so server.allowedHosts stops constraining the origin that throwIfPotentialCSRFAttack compares with Origin.
Could the forwarded host be validated against the resolved server.allowedHosts, or gated behind an opt-in? viteConfig is in scope at both call sites.
|
Good catch. I kept the Validated with all 10 |
|
Closing because I’m stepping back from maintaining this contribution. Thanks for your time. |
Use the forwarded protocol in the Vite development server's Node request adapter so action requests behind an HTTPS reverse proxy retain their public scheme.
Keep the original
Hostheader, which Vite validates againstserver.allowedHosts, instead of trusting a client-controlled forwarded host. Adds an HTTP-level regression test covering a valid forwarded protocol alongside a spoofedX-Forwarded-Host.Closes #15454