Path Traversal in tar (CVE-2021-32804)
Summary
Path traversal in tar (CVE-2021-32804). Confidential information can be exposed externally. Exploitable via preservePaths. Mitigation: upgrade to 3.2.2 or later.
Original description
The description as published by the source.
Impact
Arbitrary File Creation, Arbitrary File Overwrite, Arbitrary Code Execution
node-tar aims to prevent extraction of absolute file paths by turning absolute paths into relative paths when the preservePaths flag is not set to true. This is achieved by stripping the absolute path root from any absolute file paths contained in a tar file. For example /home/user/.bashrc would turn into home/user/.bashrc.
This logic was insufficient when file paths contained repeated path roots such as ////home/user/.bashrc. node-tar would only strip a single path root from such paths. When given an absolute file path with repeating path roots, the resulting path (e.g. ///home/user/.bashrc) would still resolve to an absolute path, thus allowing arbitrary file creation and overwrite.
Patches
3.2.2 || 4.4.14 || 5.0.6 || 6.1.1
NOTE: an adjacent issue CVE-2021-32803 affects this release level. Please ensure you update to the latest patch levels that address CVE-2021-32803 as well if this adjacent issue affects your node-tar use case.
Workarounds
Users may work around this vulnerability without upgrading by creating a custom onentry method which sanitizes the entry.path or a filter method which removes entries with absolute paths.
const path = require('path')
const tar = require('tar')
tar.x({
file: 'archive.tgz',
// either add this function...
onentry: (entry) =>…
Source: OSV.dev (Open Source Vulnerabilities) NVD GitHub Advisory OSV
Auto-generated summary
Assembled by SecPulse from the source data (CVSS, CWE, affected versions) using templates — no AI involved. Check the original description and references below for exact details.
A vulnerability tracked as CVE-2021-32804 has been found in tar.
Attackers can target a specific entry point like preservePaths over the network to misuse the product.
Confidential information can be exposed externally.
What to do: upgrade tar to 3.2.2 or later.
If unsure, ask your IT team or search "tar CVE-2021-32804" on the vendor's site.
CVE-2021-32804 (tar) — CWE-22
Attack vector: local / unauthenticated
Attack surface: preservePaths / true / onentry / entry.path
Patched: 3.2.2 — apply immediately
Plan: 1) Audit SBOM/dependencies, 2) Stage→prod upgrade, 3) Add WAF/proxy monitoring on affected endpoints, 4) Hunt IOCs in logs.
Refs: see the GHSA / vendor advisory / patched release linked on this page.
Path traversal (CWE-22) exists in tar. Attackers reach the vulnerable code path via preservePaths without authentication.
Check the vendor advisory for the affected versions of tar. Attack surface: preservePaths / true / onentry / entry.path.
Severity: ?. Confidential information can be exposed externally.
Update to 3.2.2.
Until the patch is applied: disable the affected feature, apply WAF rules, or restrict access via network ACLs.
Search webserver/proxy logs for unusual request patterns matching this CVE's known IOCs. Run grep -r 'tar' . against your dependency files (package-lock.json, requirements.txt, go.sum) to find affected services.
Response actions
Concrete steps and command examples for SOC/SRE teams to execute in order
-
1Identify exposure identify
grep -r 'tar' . | grep -v node_modulesリポジトリと本番環境の依存ファイル (package-lock.json / requirements.txt / go.sum / Gemfile.lock 等) で
tarを grep し、稼働しているサービス・バージョンを把握する。 -
2Apply patch patch
Upgrade tar to 3.2.2ステージング環境で 3.2.2 に上げて回帰テスト → 本番反映。回帰テストはアプリの主要ハッピーパスを含めること。
-
3Post-deployment verification verify
Confirm patched version is live in productionパッチ適用後、ステージングで PoC または同等の悪用パターンを再現して脆弱性が閉じたことを確認。本番ではアクセスログ・WAF でアラート再発が無いか継続監視。
Affected packages
Fix status by distribution
Fixed packages published by each distribution for this CVE
- Alpine Linux ALPINE-CVE-2021-32804 tar
- Debian DEBIAN-CVE-2021-32804 node-tar Fixed in: 6.1.7+~cs11.3.10-1
- Ubuntu UBUNTU-CVE-2021-32804 node-tar
References
- advisory nvd.nist.gov
- package github.com
- web github.com
- web github.com
- web cert-portal.siemens.com
- web npmjs.com
- web npmjs.com
- web oracle.com