fastcore untar_dir Arbitrary File Write (CVE-2026-65320)
fastcore through 2.2.46 extracts tar archives without a path check, so a crafted archive writes files outside the destination; no fixed release exists.
TL;DR
fastcore.xtras.untar_dir()passes a tar archive toshutil.unpack_archive()without an extraction filter, so a member named../startup_hook.pyis written outside the extraction directory. VulnCheck published CVE-2026-65320 on 2026-11-24.- The CVE record names releases through 2.2.44. The same
_unpack()function is unchanged in 2.2.46, released on 2026-11-22, so no fastcore release fixes it. - The record rates CVE-2026-65320 at CVSS v4.0 9.2 Critical and CVSS v3.1 8.1 High. The researcher published an end-to-end proof of concept, no exploitation is known, and the CVE is not in CISA KEV as of 2026-11-24.
- There is no fixed release. Run extraction on Python 3.14 or later, or replace
untar_dir()withtarfile.extractall(..., filter="data"). See "How do I fix it?".
Am I affected?
An application is exposed when all of these conditions hold:
- It installs
fastcoreat a version from 0 through 2.2.46, including the current 2.2.46. - It calls
fastcore.xtras.untar_dir(), directly or through a wrapper, on a tar archive. - The archive's contents are influenced by an attacker, for example an upload, a download from a partner, or a CI artifact.
- The process runs on Python before 3.14, where the default tar extraction filter does not reject escaping members.
- For code execution, the process later imports or loads a file at a path the archive can overwrite.
The flaw is in a library helper, not in the Python runtime. untar_dir() is documented as a function that untars a file into a destination, so callers reasonably expect the extraction to stay inside that destination. The advisory's proof of concept wraps the call in a simulated upload handler and confirms that files land outside the intended root.
The version table is short because no release fixes the bug:
| Branch | Affected versions | Fixed version |
|---|---|---|
| fastcore | All releases through 2.2.46 | No fixed release |
Version 2.2.45 shipped on 2026-11-18 and 2.2.46 shipped on 2026-11-22, after the report and the proposed fix. Both still call shutil.unpack_archive() without a filter. PyPI recorded 5,120,213 downloads of fastcore in the week to 2026-11-23 (pypistats), so many Python environments install it.
Check the installed version:
pip show fastcore
python -c "import importlib.metadata as m; print(m.version('fastcore'))"
Print the installed _unpack() source to confirm it has no filter:
python - <<'PY'
import inspect
import fastcore.xtras as x
print(inspect.getsource(x._unpack))
PY
Find the call sites in an application:
grep -rn "untar_dir(" --include="*.py" .
An install is exposed when the printout shows shutil.unpack_archive(str(fname), str(out)) with no filter argument and a call site extracts an archive the application did not create.
How do I fix it?
No fastcore release fixes CVE-2026-65320. The proposed patch in pull request #973 was opened on 2026-11-16 and remains unmerged, with no comments on the issue or the pull request. Treat every fastcore release, including 2.2.46, as affected.
Choose one of these paths, in order of preference:
- Run the extraction on Python 3.14 or later.
shutil.unpack_archive()added afilterargument in 3.12, and the tar default becamedatain 3.14. Thedatafilter rejects absolute paths,..members and escaping links. - Replace the
untar_dir()call with an explicit extraction that passes the filter:
import tarfile
with tarfile.open(archive) as tf:
tf.extractall(dest, filter="data")
- On Python 3.11.4 through 3.13, the same call works with an explicit filter; on older interpreters, validate every member path before extraction.
- If none of these is possible, do not pass untrusted archives to
untar_dir(). Extract them in a disposable container whose filesystem the attacker cannot use to persist code.
The filter changes behaviour for archives that rely on ownership, permissions or special files. The Python documentation recommends data for untrusted archives and fully_trusted only for archives the application created. A caller that needs the old behaviour should keep it for trusted archives only.
What is the root cause?
untar_dir() creates a temporary directory, calls _unpack() to extract the archive there, and then moves the result to the caller's destination. _unpack() gives the archive to shutil.unpack_archive() without a filter, so the tar layer uses its default extraction behaviour, which on Python before 3.14 honours traversal members.
This is the code at tag 2.2.46:
def _unpack(fname, out):
import shutil
shutil.unpack_archive(str(fname), str(out))
ls = out.ls()
return ls[0] if len(ls) == 1 else out
def untar_dir(fname, dest, rename=False, overwrite=False, uid=-1, gid=-1):
"untar `file` into `dest`, creating a directory if the root contains more than one item; recursively chown if `uid`/`gid` set"
import tempfile,shutil
dest = Path(dest)
with tempfile.TemporaryDirectory() as d:
out = Path(d)/remove_suffix(Path(fname).stem, '.tar')
out.mkdir()
if rename: dest = dest/out.name
else:
src = _unpack(fname, out)
dest = dest/src.name
if dest.exists():
if overwrite: shutil.rmtree(dest) if dest.is_dir() else dest.unlink()
else: return dest
if rename: src = _unpack(fname, out)
shutil.move(str(src), dest)
The vulnerable call is the single shutil.unpack_archive() line. Python's own documentation warns that extracting an untrusted archive can create files outside the target directory, and it recommends an extraction filter for tar archives. unpack_archive() accepts a keyword-only filter argument from Python 3.12, and fastcore does not pass one.
The temporary directory does not contain the traversal. A member name is resolved relative to the extraction directory, so ../ climbs one level, ../../ climbs two, and enough segments leave the temporary directory entirely. An absolute member name can also be honoured on an interpreter without the safe filter. After _unpack() returns, untar_dir() moves the extracted tree to the destination, but the escaping files were already written.
How is it exploited?
An attacker needs to get a crafted tar archive to a caller of untar_dir(). The advisory's proof of concept models an upload handler and uses a harmless demo root, so the whole chain runs inside one directory.
- The attacker builds a tar archive whose members include a traversal path to a location the application loads. A plugin directory or a Python module path works.
- The victim application receives the archive through an upload, a download or a build artifact and calls
untar_dir(archive, dest). _unpack()extracts the archive into its temporary directory. A member such as../../../app/plugins/startup_hook.pyresolves outside that directory.- The file is written at the resolved path with the permissions of the application process.
- When the application next imports the module or loads the plugin, the attacker's code runs.
The proof of concept published with the report shows the full write, import and execution chain, and it keeps every file inside a demo directory. The report also describes a variant that serves the archive from an attacker-controlled HTTP endpoint, which models a download path rather than an upload.
How does the attack flow?
The chain is one archive: a traversal member escapes the temporary extraction directory and is written where the application later loads it.
What can an attacker do?
An attacker can write files anywhere the application process can write, with that process's permissions. That is an arbitrary file write. It becomes code execution when the application imports or loads a file the attacker can overwrite, and the published proof of concept demonstrates that step.
The conditions for each impact are:
- Arbitrary write needs a caller that extracts an attacker-influenced archive on an affected Python version.
- Data or configuration tampering needs a writable target file that the application trusts.
- Code execution needs a writable file that the application later imports, loads as a plugin or executes as a hook.
- Denial of service needs a target whose corruption stops the application.
The CVE record scores confidentiality, integrity and availability as High under CVSS v4.0. The write primitive does not by itself grant code execution, so the attacker still needs a loadable path. The proof of concept shows one such path; it does not show every deployment is exploitable.
Why does the fix work?
No released fix exists, so the patch to examine is the one proposed in pull request #973. It detects a tar archive, extracts it with filter="data" when the interpreter supports the filter, and falls back to a manual containment check on older interpreters.
def _unpack(fname, out):
- import shutil
- shutil.unpack_archive(str(fname), str(out))
+ "Unpack `fname` into `out`, rejecting members that escape `out` (tar path traversal / 'tar slip')."
+ import shutil,tarfile
+ fname,out = str(fname),Path(out)
+ if not tarfile.is_tarfile(fname):
+ shutil.unpack_archive(fname, str(out)) # zip/etc: stdlib already strips '..'
+ else:
+ with tarfile.open(fname) as tf:
+ try: tf.extractall(out, filter='data') # py3.12+/3.11.4+: blocks '..', abs paths, links
+ except TypeError: # older interpreters: validate members manually
+ base = out.resolve()
+ for m in tf.getmembers():
+ if m.issym() or m.islnk(): raise ValueError(f'unsafe link member in archive: {m.name!r}')
+ dest = (out/m.name).resolve()
+ if dest!=base and base not in dest.parents:
+ raise ValueError(f'archive member escapes extraction dir: {m.name!r}')
+ tf.extractall(out)
ls = out.ls()
return ls[0] if len(ls) == 1 else out
The data filter is the standard-library mechanism for exactly this problem. It rejects members whose resolved path leaves the destination, rejects absolute paths, and refuses links that point outside the archive. The manual branch does the same check for interpreters that do not accept the keyword.
The proposed patch is not merged, so it is not a shipped fix. Read it as the change to make in a fork, and test it against archives the application accepts before relying on it.
How do I check if I was compromised?
No indicators of compromise are published for this issue. A successful write can look like a file the application created, and the archive itself may be deleted after extraction.
Look for the conditions rather than a published signature:
- Files that appeared outside an extraction directory but inside a writable application path, especially Python modules, plugin files and startup hooks.
- Upload or download records for tar archives that the application processed with
untar_dir(). - Import errors or unexpected code paths in files whose modification time is close to an archive upload.
If the deployment cannot show which archives reached untar_dir(), treat the write as unobservable from application logs alone. The absence of a matching file is not proof that no write happened.
Timeline
- 2026-11-16: The report is filed as issue 974 and the fix is proposed in pull request 973.
- 2026-11-18: fastcore 2.2.45 is released without the fix.
- 2026-11-22: fastcore 2.2.46 is released without the fix.
- 2026-11-24: VulnCheck publishes CVE-2026-65320.
The CVE arrived eight days after the report, and both releases published in between still carry the vulnerable call.
FAQ
Is fastai affected through fastcore?
fastai depends on fastcore and inherits the library, but the flaw is reachable only where code calls untar_dir(). Check the application's own call sites before treating a fastai deployment as exposed.
Does upgrading to fastcore 2.2.46 fix it?
No. Version 2.2.46 still contains the unfiltered _unpack() shown in "What is the root cause?". No fastcore release fixes CVE-2026-65320 as of 2026-11-24.
Does Python 3.14 fix it?
Python 3.14 makes the data filter the default for tar extraction, so untar_dir() no longer honours escaping members there. On Python 3.12 and 3.13 the filter exists but is not the default, so the caller must pass it.
Is the vulnerability only in tar archives?
The CVE and the advisory cover tar extraction, which is the format untar_dir() names. _unpack() also handles other formats through shutil, and those formats have their own extraction rules. Apply the same containment check to any archive format an application accepts.
Was CVE-2026-65320 exploited in the wild?
No exploitation is known, and the CVE is not in CISA KEV as of 2026-11-24. The published proof of concept demonstrates the write and code-execution chain inside a demo directory.
Find vulnerable fastcore versions with Ostorlab
Ostorlab's software composition analysis and SBOM inventory the libraries and versions an application ships. The team can then find every deployment that still carries fastcore and prioritize the extraction paths that need a fix.
References
- CVE-2026-65320 record, VulnCheck, published 2026-11-24 (checked November 24, 2026)
- GitHub advisory GHSA-f27m-m9m6-cf77 (checked November 24, 2026)
- fastcore issue 974, "Security: path traversal (tar slip) in untar_dir()" (checked November 24, 2026)
- fastcore pull request 973, proposed fix (checked November 24, 2026)
fastcore/xtras.pyat tag 2.2.46 (checked November 24, 2026)- fastcore release history on PyPI (checked November 24, 2026)
- Proof of concept repository for CVE-2026-65320 (checked November 24, 2026)
- Python documentation,
shutil.unpack_archive(checked November 24, 2026) - PyPI download statistics for fastcore (checked November 24, 2026)
Keep reading
