Fix CWE-22 path traversal (Tar Slip) in dataset archive extraction#709
Open
bharathjanumpally wants to merge 2 commits into
Open
Fix CWE-22 path traversal (Tar Slip) in dataset archive extraction#709bharathjanumpally wants to merge 2 commits into
bharathjanumpally wants to merge 2 commits into
Conversation
Replace insecure HTTP URLs with HTTPS to prevent man-in-the-middle interception of requests on these four lines. CVE-2026-43635 Co-authored-by: Bharath Kumar Reddy Janumpally <bharathreddy.janumpally@gmail.com>
Co-authored-by: rahulreddykarne <krc7169@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a path traversal ("Tar Slip") vulnerability in dataset archive extraction.
• CVE: CVE-2026-43637
• CWE: CWE-22 - Improper Limitation of a Pathname to a Restricted Directory
Description
_extract_archive() in cornac/utils/download.py called archive.extractall()
on TAR archives without validating member paths. A TAR archive containing
members with ../ sequences (or symlink/hardlink entries) could write files
outside the intended cache directory, allowing arbitrary file write on the
filesystem accessible to the running process.
This is reachable through the built-in dataset loaders, which download and
extract archives automatically when a loader function is called.
Fix
Replaced the unchecked extractall() with a hardened, per-member extraction
( _safe_extract ) that:
• resolves each member's destination and rejects any path that escapes the
extraction directory (blocks ../ , absolute, and prefix-collision paths);
• allows only regular files and directories - blocks symlinks, hardlinks,
FIFOs, and device files;
• extracts one member at a time so each write is validated against the live
filesystem (closing the check/extract race);
• cleans up only the files written during a failed/blocked extraction, without
touching the rest of the cache;
• applies the data extraction filter on Python 3.12+ as defense-in-depth.
Public API ( cache , get_cache_path ) is unchanged, so this is a drop-in fix.
Additional hardening
Switched the MovieLens dataset URLs in cornac/datasets/movielens.py from
http:// to https:// to prevent a man-in-the-middle from substituting a
malicious archive over cleartext (CWE-319).
Files changed
• cornac/utils/download.py - path-traversal fix
• cornac/datasets/movielens.py - HTTP to HTTPS for dataset downloads
Related Issues
Checklist:
README.md(if you are adding a new model).examples/README.md(if you are adding a new example).datasets/README.md(if you are adding a new dataset).