
Cloud Vulnerability DB
A community-led vulnerabilities database
When application code sets cookies with NextResponse#cookies, the cookies written to that NextResponse, HttpOnly ones included, are also copied into the internal x-middleware-set-cookie header. The header only exists so that cookies() can see cookies set by the middleware during the same request. It must be forwarded on the request only and never sent to the client.
OpenNext could send this header to the client in several response paths. The HttpOnly cookie values then appear in a regular response header. Unlike the Set-Cookie header, it can be read with fetch() / XMLHttpRequest by scripts running in the page. This defeats the HttpOnly protection.
NextResponse sets the header in next/dist/server/web/spec-extension/response.js whenever response.cookies.set() / delete() is called. OpenNext is expected to keep it internal:
cookies().get() sees the new values;NextResponse.json(), NextResponse.redirect(), new NextResponse(...)). core/routing/middleware.ts copied the header into the response returned to the client. This path does not require cache interception or a custom asset resolver.next() / rewrite(). The header was kept in the middleware response headers, and routingHandler applies those to the final result. The guard in core/requestHandler.ts covers rendered responses, so these are not affected. The header was exposed when the result was served directly by OpenNext's routing layer instead of being rendered:dangerous.enableCacheInterception is enabled and the requested SSG/ISR page is a cache hit;maybeGetAssetResult. The default AWS resolver does not.dangerous.enableCacheInterception enabled, core/routing/cacheInterceptor.ts returned every header stored in the cache entry. A cached route handler that sets response.cookies stores the header in the cache, and it was sent on every hit. Without cache interception, these hits are not affected.adapters/edge-adapter.ts copied every response header.Affected OpenNext versions can expose HttpOnly cookie values written through NextResponse#cookies when the response passes through one of the affected, unsanitized paths. Typical examples are session or authentication cookies.
HttpOnly was meant to protect.NextResponse.next() / rewrite() are exposed with cache interception enabled, when the requested SSG/ISR page is a cache hit, or with a custom asset resolver implementing maybeGetAssetResult.Until you upgrade:
HttpOnly cookies through NextResponse#cookies in middleware, cached route handlers or edge route handlers. Set them with response.headers.append("Set-Cookie", ...) instead, which does not populate x-middleware-set-cookie. Do not call response.cookies.set() / delete() on the same response, as it rewrites the Set-Cookie headers and drops the appended cookies. Cookies set this way on NextResponse.next() are not visible to cookies() during the same request.dangerous.enableCacheInterception mitigates the cache-interceptor vectors. It does not mitigate direct middleware responses, the asset-resolver vector, or affected edge-handler responses.x-middleware-set-cookie response header at the CDN or proxy in front of OpenNext, for example with a CloudFront response headers policy or a Cloudflare Transform Rule. Apply it to all client-facing responses, including cached and redirect responses, and only remove x-middleware-set-cookie, keeping the Set-Cookie headers. Make sure OpenNext cannot be reached through an endpoint that bypasses that rule, for example a Lambda Function URL or the default API Gateway endpoint.Source: NVD
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."