# GHSA-6xv5-86q9-7xr8: SecureJoin: on windows, paths outside of the rootfs could be inadvertently produced

> A path traversal vulnerability in the Go filepath-securejoin library allows attackers to access files outside the intended root directory on Windows systems.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Not stated
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 7 Sep 2023
- **Also known as:** GO-2023-2048

## What is GHSA-6xv5-86q9-7xr8?

GHSA-6xv5-86q9-7xr8 is a path traversal vulnerability in github.com/cyphar/filepath-securejoin, published on 7 Sep 2023. 

### Official description

### Impact
For Windows users of `github.com/cyphar/filepath-securejoin`, until v0.2.4 it was possible for certain rootfs and path combinations (in particular, where a malicious Unix-style `/`-separated unsafe path was used with a Windows-style rootfs path) to result in generated paths that were outside of the provided rootfs.

It is unclear to what extent this has a practical impact on real users, but given the possible severity of the issue we have released an emergency patch release that resolves this issue.

Thanks to  @pjbgf for discovering, debugging, and fixing this issue (as well as writing some tests for it).

### Patches
c121231e1276e11049547bee5ce68d5a2cfe2d9b is the patch fixing this issue. v0.2.4 contains the fix.

### Workarounds
Users could use `filepath.FromSlash()` on all unsafe paths before passing them to `filepath-securejoin`.

### References
See #9.

## Which versions are affected by GHSA-6xv5-86q9-7xr8?

3 open source packages ship an affected version, including github.com/cyphar/filepath-securejoin.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/cyphar/filepath-securejoin` | Go | All versions | 0.2.4 |
| `github.com/cyphar/filepath-securejoin` | Go | All versions | 0.2.4 |
| `github.com/cyphar/filepath-securejoin` | Go | All versions | 0.2.4 |

## How do I fix GHSA-6xv5-86q9-7xr8?

Upgrade github.com/cyphar/filepath-securejoin to 0.2.4 or later.

## Is GHSA-6xv5-86q9-7xr8 being exploited?

There is no known exploitation of GHSA-6xv5-86q9-7xr8 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-6xv5-86q9-7xr8 and fix it if it is affected.

What it is: GHSA-6xv5-86q9-7xr8 is a path traversal vulnerability in github.com/cyphar/filepath-securejoin, published on 7 Sep 2023. 
Exploitation: There is no known exploitation of GHSA-6xv5-86q9-7xr8 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/cyphar/filepath-securejoin (Go): affected all versions; fixed in 0.2.4
- github.com/cyphar/filepath-securejoin (Go): affected all versions; fixed in 0.2.4
- github.com/cyphar/filepath-securejoin (Go): affected all versions; fixed in 0.2.4

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/GHSA-6xv5-86q9-7xr8/ (Markdown: https://insights.sbomify.com/GHSA-6xv5-86q9-7xr8/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-6xv5-86q9-7xr8

---
From sbomify Insights: https://insights.sbomify.com/GHSA-6xv5-86q9-7xr8/
Summaries are generated and may contain mistakes; the official description above is the record.
