Incorrect handling of CORS preflight request headers in hapi
Published 7 Jun 2018 · Updated 8 Nov 2023
Affected package
- Affected
- <11.0.0
- Fixed in
- 11.0.0
npm install hapi@11.0.0Details
Versions of hapi prior to 11.0.0 implement CORS incorrectly, allowing for configurations that at best return inconsistent headers, and at worst allow cross-origin activities that are expected to be forbidden.
If the connection has CORS enabled but one route has it off, and the route is not GET, the OPTIONS prefetch request will return the default CORS headers and then the actual request will go through and return no CORS headers. This defeats the purpose of turning CORS on the route.
Recommendation
Update to version 11.0.0 or later.
Is GHSA-vwrf-r5r4-7775 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected hapi, and gives you the command that fixes it.
References
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.