# CVE-2020-5284: Directory Traversal in Next.js versions below 9.3.2

> Attackers can access files in the dist directory via crafted requests, potentially exposing build assets or sensitive data stored there.

- **Severity:** Medium 4.4 (`CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 30 Mar 2020
- **Updated:** 4 Aug 2024
- **Also known as:** GHSA-fq77-7p7r-83rj

## What is CVE-2020-5284?

CVE-2020-5284 is a medium-severity path traversal vulnerability in zeit next.js, published on 30 Mar 2020. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

Next.js versions before 9.3.2 have a directory traversal vulnerability. Attackers could craft special requests to access files in the dist directory (.next). This does not affect files outside of the dist directory (.next). In general, the dist directory only holds build assets unless your application intentionally stores other assets under this directory. This issue is fixed in version 9.3.2.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory), CWE-23 (Relative Path Traversal)

## Which versions are affected by CVE-2020-5284?

2 open source packages ship an affected version, including next. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `next` | npm | From 0.9.9 | 9.3.2 |
| `next` | npm | From 0.9.9 | 9.3.2 |

Products: Zeit Next.js.

## How do I fix CVE-2020-5284?

Upgrade next to 9.3.2 or later.

## Is CVE-2020-5284 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2020-5284 exists.

Public exploit code:

- Next.js <9.3.2 - Local File Inclusion (nuclei): http/cves/2020/CVE-2020-5284.yaml

## Other vulnerabilities in zeit next.js

- [CVE-2018-6184](https://insights.sbomify.com/CVE-2018-6184/): Directory traversal vulnerability in Next.js (high 7.5)
- [CVE-2017-16877](https://insights.sbomify.com/CVE-2017-16877/): Next.js Directory Traversal Vulnerability (high 7.5)
- [CVE-2018-18282](https://insights.sbomify.com/CVE-2018-18282/): Next.js has cross site scripting (XSS) vulnerability via the 404 or 500 /_error page (medium 6.1)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2020-5284 and fix it if it is affected.

What it is: CVE-2020-5284 is a medium-severity path traversal vulnerability in zeit next.js, published on 30 Mar 2020. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2020-5284 exists.

Affected packages and fixed versions:
- next (npm): affected from 0.9.9; fixed in 9.3.2
- next (npm): affected from 0.9.9; fixed in 9.3.2

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2020-5284/ (Markdown: https://insights.sbomify.com/CVE-2020-5284/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2020-5284
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2020-5284
- OSV: https://osv.dev/vulnerability/CVE-2020-5284

---
From sbomify Insights: https://insights.sbomify.com/CVE-2020-5284/
Summaries are generated and may contain mistakes; the official description above is the record.
