AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Malformed Origin Header In Next.Js Server Actions Causes Unhandled TypeError And HTTP 500

A crafted request with an invalid Origin header (e.g. 'http://' or 'null' on v15.5.x) triggers an uncaught TypeError in the Server Actions CSRF validation logic, resulting in a 500 Internal Server Error. This can be exploited for unauthenticated denial-of-service and, if improperly patched, may lead to a CSRF bypass.

highConfidence 95%Next.jsApp RouterRoute HandlersAffected V15.5.xAffected V16.2.3Affected Vnext@canary

Origin Analysis

The Server Actions handler calls `new URL(originHeader).host` without validating that `originHeader` is a parseable absolute URL, causing a TypeError for malformed values that propagates unhandled to the top-level error handler.
1. Deploy a self-hosted Next.js app with at least one Server Action. 2. Send a POST request to any page with `Content-Type: multipart/form-data; boundary=----PoC` and an invalid `Origin` header (e.g. `Origin: http://` or `Origin: null` on 15.5.x). 3. Observe the server returns HTTP 500 and logs `TypeError: Invalid URL`. 4. No valid action ID or Next-Action header is required.

Fixing Code Block

Edge Case Audit

Rollback should only occur after verifying that no CSRF bypass regression is introduced. Tests must confirm that requests with malformed Origin are rejected with a 4xx status and never execute the action. On v15.5.x, the 'null' case must be explicitly handled; using a generic catch that returns undefined would reintroduce CVE-2026-27977/27978. Multi-threaded or clustered deployments must ensure the same code path is used consistently across all workers.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state