# CVE-2018-1002202: Improper Limitation of a Pathname to a Restricted Directory in Zip4j

> Attackers can write arbitrary files via malicious Zip entries, potentially leading to code execution or data modification in applications using zip4j.

- **Severity:** Medium 6.5 (`CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 25 Jul 2018
- **Updated:** 5 Aug 2024
- **Also known as:** GHSA-2rpm-4x8c-pvqg

## What is CVE-2018-1002202?

CVE-2018-1002202 is a medium-severity path traversal vulnerability in zip4j, published on 25 Jul 2018. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

zip4j before 1.3.3 is vulnerable to directory traversal, allowing attackers to write to arbitrary files via a ../ (dot dot slash) in a Zip archive entry that is mishandled during extraction. This vulnerability is also known as 'Zip-Slip'.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)

## Which versions are affected by CVE-2018-1002202?

2 open source packages ship an affected version, including net.lingala.zip4j:zip4j. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `net.lingala.zip4j:zip4j` | Maven | All versions | 1.3.3 |
| `net.lingala.zip4j:zip4j` | Maven | All versions | 1.3.3 |

Products: Zip4j Project Zip4j.

## How do I fix CVE-2018-1002202?

Upgrade net.lingala.zip4j:zip4j to 1.3.3 or later.

## Is CVE-2018-1002202 being exploited?

There is no known exploitation of CVE-2018-1002202 in the wild and no public exploit code.

Public exploit code:

- CWE-Bench-Java CVE-2018-1002202 versions 1.3.2, 1.3.3 (github_poc): https://github.com/iris-sast/zip4j
- https://github.com/shoucheng3/srikanth-lingala__zip4j_CVE-2018-1002202_1-3-2 (github_poc): https://github.com/shoucheng3/srikanth-lingala__zip4j_CVE-2018-1002202_1-3-2

## Other vulnerabilities in zip4j

- [CVE-2023-22899](https://insights.sbomify.com/CVE-2023-22899/): Zip4j Origin Validation Error (medium 5.9)
- [CVE-2022-24615](https://insights.sbomify.com/CVE-2022-24615/): Uncaught Exception in zip4j (medium 5.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2018-1002202 and fix it if it is affected.

What it is: CVE-2018-1002202 is a medium-severity path traversal vulnerability in zip4j, published on 25 Jul 2018. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2018-1002202 in the wild and no public exploit code.

Affected packages and fixed versions:
- net.lingala.zip4j:zip4j (Maven): affected all versions; fixed in 1.3.3
- net.lingala.zip4j:zip4j (Maven): affected all versions; fixed in 1.3.3

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-2018-1002202/ (Markdown: https://insights.sbomify.com/CVE-2018-1002202/index.md)
```

## Sources

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

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