unearth is vulnerable to Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
75
CVE Score
High
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
unearth's _untar_archive function in src/unearth/preparer.py extracts tar archives downloaded by its package-link preparer, using is_within_directory to confirm that each extracted member stays within the target location. Before 0.18.3, this containment check compared raw, non-resolved paths and performed no explicit validation of symlink member targets before calling tar._extract_member, so a crafted archive member (via ../ path segments or a symlink entry) could resolve outside the extraction directory. The default configuration supplies the archive filename and destination location as determined by unearth's own download/preparer flow when processing a resolved package distribution. The fix in 0.18.3 resolves both the member path and the target directory with os.path.realpath() before the relative_to() check, computes and validates each symlink member's absolute/relative link target against the extraction location, skipping (with a warning) any symlink that would escape it, and replaces os.makedirs with safe_makedirs so created directories stay under the extraction location.
Upgrade the unearth package to version 0.18.3 or later.
You are affected if you are using a version that falls within the vulnerable range and your tooling uses unearth to download and extract tar-format source distributions from untrusted or externally hosted package indexes.
0.2.0 - 0.18.2
Fixed in 0.18.3unearth is vulnerable to Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in versions 0.2.0 - 0.18.2.
Secure your code, cloud, and runtime in one central system. Connect a repo to discover what the reasoning agents find in your codebase.
No credit card required | Scan results in 32 seconds.
I consent to receiving marketing communications based on Aikido’s Privacy Policy.
SOC 2Compliant
ISO 27001Compliant
ISO 42001Compliant© All Intel data is openly available and commercially licensed.