# CVE-2024-47877: Extract has insufficient checks allowing attacker to create symlinks outside the extraction directory.

> A malicious archive can create symlinks outside the extraction directory, potentially leading to arbitrary file writes or code execution.

- **Severity:** Medium 6.9 (`CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 11 Oct 2024
- **Updated:** 11 Oct 2024
- **Also known as:** GHSA-8rm2-93mq-jqhc, GO-2024-3196

## What is CVE-2024-47877?

CVE-2024-47877 is a medium-severity path traversal vulnerability in codeclysm extract, published on 11 Oct 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Extract is aA Go library to extract archives in zip, tar.gz or tar.bz2 formats. A maliciously crafted archive may allow an attacker to create a symlink outside the extraction target directory. This vulnerability is fixed in 4.0.0. If you're using the Extractor.FS interface, then upgrading to /v4 will require to implement the new methods that have been added.

Weakness: CWE-61 (UNIX Symbolic Link (Symlink) Following), CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)

## Which versions are affected by CVE-2024-47877?

9 open source packages ship an affected version, including github.com/codeclysm/extract, github.com/codeclysm/extract/v3 and github.com/codeclysm/extract/v4. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/codeclysm/extract` | Go | All versions | None |
| `github.com/codeclysm/extract` | Go | All versions to 2.2.0 | None |
| `github.com/codeclysm/extract` | Go | All versions to 2.2.0 | None |
| `github.com/codeclysm/extract/v3` | Go | All versions | None |
| `github.com/codeclysm/extract/v3` | Go | All versions to 3.1.1 | None |
| `github.com/codeclysm/extract/v3` | Go | All versions to 3.1.1 | None |
| `github.com/codeclysm/extract/v4` | Go | All versions | 4.0.0 |
| `github.com/codeclysm/extract/v4` | Go | All versions | 4.0.0 |
| `github.com/codeclysm/extract/v4` | Go | All versions | 4.0.0 |

Products: Codeclysm Extract.

## How do I fix CVE-2024-47877?

Upgrade to a fixed version.

## Is CVE-2024-47877 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-47877 and fix it if it is affected.

What it is: CVE-2024-47877 is a medium-severity path traversal vulnerability in codeclysm extract, published on 11 Oct 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2024-47877 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/codeclysm/extract (Go): affected all versions; no fix listed
- github.com/codeclysm/extract (Go): affected all versions up to 2.2.0; no fix listed
- github.com/codeclysm/extract (Go): affected all versions up to 2.2.0; no fix listed
- github.com/codeclysm/extract/v3 (Go): affected all versions; no fix listed
- github.com/codeclysm/extract/v3 (Go): affected all versions up to 3.1.1; no fix listed
- github.com/codeclysm/extract/v3 (Go): affected all versions up to 3.1.1; no fix listed
- github.com/codeclysm/extract/v4 (Go): affected all versions; fixed in 4.0.0
- github.com/codeclysm/extract/v4 (Go): affected all versions; fixed in 4.0.0
- github.com/codeclysm/extract/v4 (Go): affected all versions; fixed in 4.0.0

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

## Sources

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

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