# CVE-2024-24579: Tar path traversal in stereoscope when processing OCI tar archives

> Attackers can write files outside the intended directory by crafting malicious OCI tar archives processed by the stereoscope Go library.

- **Severity:** Medium 5.3 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 31 Jan 2024
- **Updated:** 23 Aug 2024
- **Also known as:** GHSA-hpxr-w9w7-g4gv, GO-2024-2490, MINI-3rf8-prxq-hcfv, MINI-4598-v2p2-mw76, MINI-4m3g-8fch-6g2m, MINI-8qj4-cg4m-x5jw, MINI-cvqc-gm78-q2gw, MINI-v29w-hpp9-8fh9

## What is CVE-2024-24579?

CVE-2024-24579 is a medium-severity path traversal vulnerability in anchore stereoscope, published on 31 Jan 2024. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

stereoscope is a go library for processing container images and simulating a squash filesystem.  Prior to version 0.0.1, it is possible to craft an OCI tar archive that, when stereoscope attempts to unarchive the contents, will result in writing to paths outside of the unarchive temporary directory. Specifically, use of `github.com/anchore/stereoscope/pkg/file.UntarToDirectory()` function, the  `github.com/anchore/stereoscope/pkg/image/oci.TarballImageProvider` struct, or the higher level `github.com/anchore/stereoscope/pkg/image.Image.Read()` function express this vulnerability. As a workaround, if you are using the OCI archive as input into stereoscope then you can switch to using an OCI layout by unarchiving the tar archive and provide the unarchived directory to stereoscope.

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

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

3 open source packages ship an affected version, including github.com/anchore/stereoscope. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/anchore/stereoscope` | Go | All versions | 0.0.1 |
| `github.com/anchore/stereoscope` | Go | All versions | 0.0.1 |
| `github.com/anchore/stereoscope` | Go | All versions | 0.0.1 |

Products: Anchore Stereoscope.

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

Upgrade github.com/anchore/stereoscope to 0.0.1 or later.

## Is CVE-2024-24579 being exploited?

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

## Fix prompt for AI coding agents

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

What it is: CVE-2024-24579 is a medium-severity path traversal vulnerability in anchore stereoscope, published on 31 Jan 2024. It can only be exploited from the same machine or local 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-2024-24579 exists.

Affected packages and fixed versions:
- github.com/anchore/stereoscope (Go): affected all versions; fixed in 0.0.1
- github.com/anchore/stereoscope (Go): affected all versions; fixed in 0.0.1
- github.com/anchore/stereoscope (Go): affected all versions; fixed in 0.0.1

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

## Sources

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

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