{"id":"HSEC-2026-0014","aliases":["HSEC-2026-0014"],"related":[],"kind":"vulnerability","state":"published","title":"Arbitrary file write via path traversal in unpackToDir","summary":"# Arbitrary file write via path traversal in unpackToDir\n\n`Codec.Archive.unpackToDir` extracts a tar (or other archive supported by the\nlibarchive C library) from a `ByteString` into a directory. `unpackToDirLazy`\nis the streaming variant; both funnel through the same internal\n`unpackEntriesFp` routine.\n\n`unpackEntriesFp` joined each entry's name onto the destination directory with\n`System.FilePath.(</>)` without validating the name. Entry names starting with\n`..` sequences therefore escape the destination: `fp </> \"../../../../etc/x\"`\nresolves outside the extraction root. The joined path is written back into the\narchive entry (`archiveEntrySetPathname`) and handed to libarchive's\n`archive_read_extract` with no `ARCHIVE_EXTRACT_SECURE_*` flags, so neither the\nHaskell layer nor the C library rejects the traversal. The `..` check is not\nlimited to tar archives: any format whose entry names libarchive reports\nverbatim is affected. Extraction result codes were also discarded, so write\nfailures could pass unnoticed.\n\nAn attacker who can supply an archive to a service that extracts it with these\nAPIs gains an arbitrary file write with the privileges of the extracting\nprocess. A demonstrated escalation (verified in a container): an archive with\nmember `../../../../etc/profile.d/zz-poc-zipslip.sh` plants a shell script\nsourced by every subsequent login shell, converting the file write into code\nexecution when any user logs in.\n\nThe reported traversal is fixed in libarchive-3.0.6.0, which fails with\n`ArchiveFatal` when an entry path begins with `..`\n(commit `325a2296379905557de1fa21b28d86f34bab2441`).\n\nUsers should upgrade to libarchive-3.0.6.0 or later. If pinned to an older\nversion, validate entry names before extraction (reject absolute paths and any\npath containing a `..` component) or extract inside a sandboxed directory.\n\nExternal vulnerability reported by Akash Sebastian (justabughunter).","summaryFormat":"markdown","summarySource":"hsec","descriptions":[{"lang":"en","text":"# Arbitrary file write via path traversal in unpackToDir\n\n`Codec.Archive.unpackToDir` extracts a tar (or other archive supported by the\nlibarchive C library) from a `ByteString` into a directory. `unpackToDirLazy`\nis the streaming variant; both funnel through the same internal\n`unpackEntriesFp` routine.\n\n`unpackEntriesFp` joined each entry's name onto the destination directory with\n`System.FilePath.(</>)` without validating the name. Entry names starting with\n`..` sequences therefore escape the destination: `fp </> \"../../../../etc/x\"`\nresolves outside the extraction root. The joined path is written back into the\narchive entry (`archiveEntrySetPathname`) and handed to libarchive's\n`archive_read_extract` with no `ARCHIVE_EXTRACT_SECURE_*` flags, so neither the\nHaskell layer nor the C library rejects the traversal. The `..` check is not\nlimited to tar archives: any format whose entry names libarchive reports\nverbatim is affected. Extraction result codes were also discarded, so write\nfailures could pass unnoticed.\n\nAn attacker who can supply an archive to a service that extracts it with these\nAPIs gains an arbitrary file write with the privileges of the extracting\nprocess. A demonstrated escalation (verified in a container): an archive with\nmember `../../../../etc/profile.d/zz-poc-zipslip.sh` plants a shell script\nsourced by every subsequent login shell, converting the file write into code\nexecution when any user logs in.\n\nThe reported traversal is fixed in libarchive-3.0.6.0, which fails with\n`ArchiveFatal` when an entry path begins with `..`\n(commit `325a2296379905557de1fa21b28d86f34bab2441`).\n\nUsers should upgrade to libarchive-3.0.6.0 or later. If pinned to an older\nversion, validate entry names before extraction (reject absolute paths and any\npath containing a `..` component) or extract inside a sandboxed directory.\n\nExternal vulnerability reported by Akash Sebastian (justabughunter).","format":"markdown","source":"hsec"}],"published":"2026-11-13T11:01:54.000Z","modified":"2026-11-13T11:15:03.323Z","severities":[],"cwes":[],"affected":[{"ranges":[{"type":"ecosystem","introduced":"0.1.0.0","status":"affected","fixed":"3.0.6.0"}],"ecosystem":"Hackage","package":"libarchive","purl":"pkg:hackage/libarchive","source":"hsec"}],"references":[{"url":"https://hackage.haskell.org/package/libarchive","tags":["package"],"sources":["hsec"]},{"url":"https://github.com/vmchale/libarchive/commit/325a2296379905557de1fa21b28d86f34bab2441","tags":["fix"],"sources":["hsec"]}],"credits":[],"sources":[{"source":"hsec","name":"Haskell Security Advisories","id":"HSEC-2026-0014","url":"https://osv.dev/vulnerability/HSEC-2026-0014","licence":"CC0-1.0","modified":"2026-11-13T11:15:03.323Z"}],"updatedAt":"2026-11-25T22:56:25.656Z"}