Race condition in tempfile.TemporaryDirectory cleanup allows deleting files outside the temporary directory
The cleanup of tempfile.TemporaryDirectory is vulnerable to a race condition. An attacker who can modify the tree during cleanup can replace a directory with a symbolic link, causing files outside of the temporary directory to be deleted or have their permissions and file flags reset, with the privileges of the process performing the cleanup. Note that platforms where shutil.rmtree.avoids_symlink_attacks is false, remain affected, and file flags may still be reset outside of the tree on all platforms.
- Products
- CPython
- Affected versions
- Not specified
- Fixed versions
- Not specified
- CVEs
- CVE-2026-12345
- Confirmed fixed CVEs
- Not specified
- Updated in this feed
- 29 Oct 2026, 07:24 UTC · Revision 2
Source evidence
Race condition in tempfile.TemporaryDirectory cleanup allows deleting files outside the temporary directory
core-cve · Original sourcePublished 29 Sept 2026, 17:46 UTC
The cleanup of tempfile.TemporaryDirectory is vulnerable to a race condition. An attacker who can modify the tree during cleanup can replace a directory with a symbolic link, causing files outside of the temporary directory to be deleted or have their permissions and file flags reset, with the privileges of the process performing the cleanup. Note that platforms where shutil.rmtree.avoids_symlink_attacks is false, remain affected, and file flags may still be reset outside of the tree on all platforms.
cve:CVE-2026-12345
CPython
Fixed versions: Not specified
Complete source record
{
"id": "bd3540b840fccde6cbe1746c225a5401f31776bb2c8358644ff463474b8fd208",
"url": "https://www.cve.org/CVERecord?id=CVE-2026-12345",
"method": "structured",
"payload": {
"kind": "advisory",
"title": "Race condition in tempfile.TemporaryDirectory cleanup allows deleting files outside the temporary directory",
"summary": "The cleanup of tempfile.TemporaryDirectory is vulnerable to a race condition. An attacker who can modify the tree during cleanup can replace a directory with a symbolic link, causing files outside of the temporary directory to be deleted or have their permissions and file flags reset, with the privileges of the process performing the cleanup. Note that platforms where shutil.rmtree.avoids_symlink_attacks is false, remain affected, and file flags may still be reset outside of the tree on all platforms.",
"evidence": "cve:CVE-2026-12345",
"products": [
{
"name": {
"value": "CPython",
"evidence": "/containers/cna/affected/0/product"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": []
}
],
"severity": "medium",
"structured": {
"id": "CVE-2026-12345",
"aliases": [
"CVE-2026-12345"
],
"metrics": [
{
"format": "CVSS",
"cvssV4_0": {
"Safety": "NOT_DEFINED",
"version": "4.0",
"Recovery": "NOT_DEFINED",
"baseScore": 5.9,
"Automatable": "NOT_DEFINED",
"attackVector": "LOCAL",
"baseSeverity": "MEDIUM",
"valueDensity": "NOT_DEFINED",
"vectorString": "CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N",
"exploitMaturity": "NOT_DEFINED",
"providerUrgency": "NOT_DEFINED",
"userInteraction": "NONE",
"attackComplexity": "LOW",
"attackRequirements": "PRESENT",
"privilegesRequired": "NONE",
"subIntegrityImpact": "NONE",
"vulnIntegrityImpact": "HIGH",
"subAvailabilityImpact": "NONE",
"vulnAvailabilityImpact": "HIGH",
"subConfidentialityImpact": "NONE",
"vulnConfidentialityImpact": "NONE",
"vulnerabilityResponseEffort": "NOT_DEFINED"
},
"scenarios": [
{
"lang": "en",
"value": "GENERAL"
}
]
}
],
"affected": [
{
"repo": "https://github.com/python/cpython",
"vendor": "Python Software Foundation",
"modules": [
"tempfile"
],
"product": "CPython",
"versions": [
{
"status": "affected",
"version": "0",
"lessThan": "3.12.15",
"versionType": "python"
},
{
"status": "affected",
"version": "3.13.0",
"lessThan": "3.13.18",
"versionType": "python"
},
{
"status": "affected",
"version": "3.14.0",
"lessThan": "3.14.9",
"versionType": "python"
},
{
"status": "affected",
"version": "3.15.0a1",
"lessThan": "3.15.0rc3",
"versionType": "python"
}
],
"defaultStatus": "unaffected"
}
],
"modified": "2026-10-26T00:36:23.425Z",
"provider": "cve",
"references": [
"https://github.com/python/cpython/pull/157580",
"https://github.com/python/cpython/issues/157579",
"https://github.com/python/cpython/commit/5c20517a4fc56683efe63a7751020db9573f538d",
"https://github.com/python/cpython/commit/458e7134a5af7f86aee9d21b51cf499b41aa4420",
"https://github.com/python/cpython/commit/e1f3590f155c6d66007e958c98c9d69316551993",
"https://github.com/python/cpython/commit/06ef3d43fdaf4da97af12fa694b4886092c4b970",
"https://github.com/python/cpython/commit/58ed0259cae509a19138795df302fe60b544dc74",
"https://github.com/python/cpython/commit/0478b52788117db4b831b3efd648f56b777628aa",
"https://github.com/python/cpython/commit/c39b52d00b42200aaadff679e2fe3f1006d57c58"
],
"provider_metadata": {
"adp": [
{
"title": "CISA ADP Vulnrichment",
"metrics": [
{
"other": {
"type": "ssvc",
"content": {
"id": "CVE-2026-12345",
"role": "CISA Coordinator",
"options": [
{
"Exploitation": "none"
},
{
"Automatable": "no"
},
{
"Technical Impact": "partial"
}
],
"version": "2.0.3",
"timestamp": "2026-09-29T18:38:00.590353Z"
}
}
}
],
"problemTypes": [
{
"descriptions": [
{
"lang": "en",
"type": "CWE",
"cweId": "CWE-59",
"description": "CWE-59 Improper Link Resolution Before File Access ('Link Following')"
}
]
}
],
"providerMetadata": {
"orgId": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
"shortName": "CISA-ADP",
"dateUpdated": "2026-09-29T18:38:55.324Z"
}
},
{
"title": "CVE Program Container",
"references": [
{
"url": "http://www.openwall.com/lists/oss-security/2026/09/29/40"
}
],
"providerMetadata": {
"orgId": "af854a3a-2127-422b-91ae-364da2661108",
"shortName": "CVE",
"dateUpdated": "2026-09-29T21:07:55.567Z"
}
}
],
"cna": {
"orgId": "28c92f92-d60d-412d-b760-e73465c3df22",
"shortName": "PSF",
"dateUpdated": "2026-10-26T00:36:23.425Z"
}
}
},
"related_cves": [
{
"value": "CVE-2026-12345",
"evidence": "/cveMetadata/cveId"
}
],
"security_relevant": true,
"severity_evidence": "/containers/cna/metrics"
},
"source_id": "core-cve",
"document_id": 229503,
"published_at": "2026-09-29T17:46:01.811+00:00"
}