Skip to content

Fix CWE-22 path traversal (Tar Slip) in dataset archive extraction#709

Merged
qtuantruong merged 2 commits into
PreferredAI:masterfrom
rahulreddykarne:fix/cve-2026-43637
Jul 14, 2026
Merged

Fix CWE-22 path traversal (Tar Slip) in dataset archive extraction#709
qtuantruong merged 2 commits into
PreferredAI:masterfrom
rahulreddykarne:fix/cve-2026-43637

Conversation

@bharathjanumpally

Copy link
Copy Markdown
Contributor

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:

  • I have added tests.
  • I have updated the documentation accordingly.
  • I have updated README.md (if you are adding a new model).
  • I have updated examples/README.md (if you are adding a new example).
  • I have updated datasets/README.md (if you are adding a new dataset).

rahulreddykarne and others added 2 commits June 24, 2026 12:41
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>

@qtuantruong qtuantruong left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@bharathjanumpally

bharathjanumpally commented Jul 14, 2026 via email

Copy link
Copy Markdown
Contributor Author

@qtuantruong qtuantruong merged commit 8a50be7 into PreferredAI:master Jul 14, 2026
18 of 19 checks passed
@qtuantruong

Copy link
Copy Markdown
Member

@hieuddo when should we release the next version?

@hieuddo

hieuddo commented Jul 14, 2026

Copy link
Copy Markdown
Member

@hieuddo when should we release the next version?

We're good to release v2.6.0, or v2.5.1, whichever it is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants