# HSEC-2025-0004: Broken Path Sanitization in spacecookie Library

> Broken path sanitization in the spacecookie library allows attackers to bypass traversal protections and access or modify arbitrary files.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 14 Nov 2025

## What is HSEC-2025-0004?

HSEC-2025-0004 is a path traversal vulnerability in spacecookie, published on 14 Nov 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

# Broken Path Sanitization in spacecookie Library

The spacecookie library exposes the functions `sanitizePath` and `sanitizeIfNotUrl` intended to
remove `..` components from paths which can be used to prevent path traversal attacks. Due to
erroneous comparison code, this elimination is not actually performed which has been remedied
in version 1.0.0.3 by properly comparing using `equalFilePath`.

Any user of those respective functions of any version of spacecookie should upgrade to 1.0.0.3
or later. Note that the spacecookie server executable included in the same package is not affected
by the problem since a separate check would reject any malicious path that gets by `sanitizePath`.

## Which versions are affected by HSEC-2025-0004?

1 open source package ship an affected version, including spacecookie.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `spacecookie` | Hackage | From 0.2.0.0 | 1.0.0.3 |

## How do I fix HSEC-2025-0004?

Upgrade spacecookie to 1.0.0.3 or later.

## Is HSEC-2025-0004 being exploited?

There is no known exploitation of HSEC-2025-0004 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for HSEC-2025-0004 and fix it if it is affected.

What it is: HSEC-2025-0004 is a path traversal vulnerability in spacecookie, published on 14 Nov 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of HSEC-2025-0004 in the wild and no public exploit code.

Affected packages and fixed versions:
- spacecookie (Hackage): affected from 0.2.0.0; fixed in 1.0.0.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/HSEC-2025-0004/ (Markdown: https://insights.sbomify.com/HSEC-2025-0004/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/HSEC-2025-0004

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