SEVERITY NOT PROVIDED

HSEC-2026-0014: Arbitrary file write via path traversal in unpackToDir

Published 2026-11-13 · Updated 2026-11-13

Summary

Hackage libarchive versions from 0.1.0.0 before 3.0.6.0 contain a path traversal flaw in Codec.Archive.unpackToDir and unpackToDirLazy that allows arbitrary file writes via entry names starting with '..'. Engineering teams using these APIs to extract untrusted archives should upgrade to libarchive 3.0.6.0 or later.

Who is affected

Applications and services using Hackage libarchive versions 0.1.0.0 up to 3.0.6.0 that call unpackToDir or unpackToDirLazy on attacker-supplied archives are affected across tar and any other supported format whose entry names are reported verbatim. Exploitation requires supplying a crafted archive containing entry paths beginning with '..', as unpackEntriesFp joins entry names without validation and calls archive_read_extract without ARCHIVE_EXTRACT_SECURE_* flags while also discarding extraction result codes. This grants an attacker arbitrary file write with the privileges of the extracting process, which was demonstrated to escalate to code execution by planting a shell script in /etc/profile.d/ that executes on subsequent user logins.

Exploitability

A CVSS vector and base score have not been provided or computed for this vulnerability, and an EPSS score is not yet available. The record lists CISA Known Exploited Vulnerabilities status as no, so active exploitation is not indicated by KEV. Quantitative exploitability ratings are therefore not documented.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-11-19. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
Hackage libarchive >= 0.1.0.0, < 3.0.6.0 3.0.6.0 -

FAQ

Which versions of Hackage libarchive are affected and fixed?

The vulnerability was introduced in version 0.1.0.0 and is fixed in version 3.0.6.0.

Does this path traversal issue only impact tar archives?

No. Any archive format supported by the libarchive C library whose entry names are reported verbatim is affected when extracted with unpackToDir or unpackToDirLazy.

What mitigations are available if we cannot immediately upgrade to libarchive 3.0.6.0?

If pinned to an older version, you should validate entry names before extraction to reject absolute paths and any path containing a '..' component, or perform extraction inside a sandboxed directory.

Original advisory description
# Arbitrary file write via path traversal in unpackToDir `Codec.Archive.unpackToDir` extracts a tar (or other archive supported by the libarchive C library) from a `ByteString` into a directory. `unpackToDirLazy` is the streaming variant; both funnel through the same internal `unpackEntriesFp` routine. `unpackEntriesFp` joined each entry's name onto the destination directory with `System.FilePath.(</>)` without validating the name. Entry names starting with `..` sequences therefore escape the destination: `fp </> "../../../../etc/x"` resolves outside the extraction root. The joined path is written back into the archive entry (`archiveEntrySetPathname`) and handed to libarchive's `archive_read_extract` with no `ARCHIVE_EXTRACT_SECURE_*` flags, so neither the Haskell layer nor the C library rejects the traversal. The `..` check is not limited to tar archives: any format whose entry names libarchive reports verbatim is affected. Extraction result codes were also discarded, so write failures could pass unnoticed. An attacker who can supply an archive to a service that extracts it with these APIs gains an arbitrary file write with the privileges of the extracting process. A demonstrated escalation (verified in a container): an archive with member `../../../../etc/profile.d/zz-poc-zipslip.sh` plants a shell script sourced by every subsequent login shell, converting the file write into code execution when any user logs in. The reported traversal is fixed in libarchive-3.0.6.0, which fails with `ArchiveFatal` when an entry path begins with `..` (commit `325a2296379905557de1fa21b28d86f34bab2441`). Users should upgrade to libarchive-3.0.6.0 or later. If pinned to an older version, validate entry names before extraction (reject absolute paths and any path containing a `..` component) or extract inside a sandboxed directory. External vulnerability reported by Akash Sebastian (justabughunter).

References

Source records: HSEC-2026-0014 (OSV.dev).