{"schema":"threatline.record/2","record":{"id":"CVE-2026-12259","aliases":["CVE-2026-63310","GHSA-5wp5-5229-5g6q","GHSA-gf32-cmjh-8m9v","PYSEC-2026-3729","PYSEC-2026-4318"],"summary":"NLTK: Missing Post-Download Integrity Verification Allows Malicious Package Injection","details":"NLTK's package downloader in nltk/downloader.py does not verify file integrity after download and before extraction.\n\nThe download flow at lines 789-825:\n1. File is downloaded to a temp path via HTTP\n2. os.replace(tmp_filepath, filepath) moves it to the final location (line 799)\n3. Extraction begins via _unzip_iter() (line 825)\n\nBetween steps 2 and 3, there is no SHA-256 verification. The checksum logic exists in _pkg_status() (lines 982-1015) but it is only used BEFORE download as a status check (\"is this package already installed and up-to-date?\"). It is never called after download to verify the file that was actually received.\n\nAttack vectors:\n1. MITM during HTTP download (NLTK downloads from http:// by default on some mirrors)\n2. Race condition on shared filesystems (attacker replaces file between os.replace and _unzip_iter)\n3. DNS poisoning redirecting to attacker-controlled server\n\nPoC:\n```python\nimport nltk\nimport unittest.mock\nimport zipfile\nimport io\nimport os\n\n# Create a malicious zip that will be \"downloaded\"\nmalicious_zip = io.BytesIO()\nwith zipfile.ZipFile(malicious_zip, 'w') as zf:\n    zf.writestr('punkt_tab/tokenizers/punkt_tab/english.pickle', \n                b'MALICIOUS PAYLOAD - attacker controlled content')\n\n# Patch urllib to return our malicious zip\nwith unittest.mock.patch('urllib.request.urlopen') as mock_urlopen:\n    mock_response = unittest.mock.MagicMock()\n    mock_response.read.return_value = malicious_zip.getvalue()\n    mock_response.headers = {'Content-Length': str(len(malicious_zip.getvalue()))}\n    mock_urlopen.return_value = mock_response\n    \n    # Download proceeds, no integrity check catches the swap\n    # nltk.download('punkt_tab')  # Would install attacker payload\n```\n\nThis is distinct from CVE-2024-39705 (pickle deserialization via download) and CVE-2025-14009 (zip-slip path traversal). Those address what happens AFTER extraction. This finding addresses the gap BEFORE extraction where integrity is never verified.\n\nSuggested fix: After os.replace() and before _unzip_iter(), compute SHA-256 of the final file and compare against the expected checksum from the package index. Reject and delete the file if the hash does not match.","categories":["Libraries & packages"],"product":"nltk","vendor":"nltk","ecosystem":"pip","affected_ranges":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-5wp5-5229-5g6q","source_modified_at":"2026-10-27T07:58:08Z","fetched_at":"2026-10-27T10:24:27.527526Z","package":{"ecosystem":"pip","name":"nltk"},"range":"<= 3.9.2"},{"source":"CVE List","source_url":"https://www.cve.org/CVERecord?id=CVE-2026-12259","source_modified_at":"2026-08-03T14:59:01.815Z","fetched_at":"2026-10-27T10:24:27.527526Z","product":"nltk/nltk","vendor":"nltk","versions":[{"version":"unspecified","status":"affected","versionType":"custom","lessThanOrEqual":"latest"}],"defaultStatus":null},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-5wp5-5229-5g6q","source_modified_at":"2026-10-16T10:56:05.808390648Z","fetched_at":"2026-10-27T10:24:27.527526Z","package":{"name":"nltk","ecosystem":"PyPI","purl":"pkg:pypi/nltk"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"3.9.3"}]}],"versions":["0.8","0.9","0.9.3","0.9.4","0.9.5","0.9.6","0.9.7","0.9.8","0.9.9","2.0.1","2.0.1rc1","2.0.1rc2-git","2.0.1rc3","2.0.1rc4","2.0.2","2.0.3","2.0.4","2.0.5","2.0b4","2.0b5","2.0b6","2.0b7","2.0b8","2.0b9","3.0.0","3.0.0b1","3.0.0b2","3.0.1","3.0.2","3.0.3","3.0.4","3.0.5","3.1","3.2","3.2.1","3.2.2","3.2.3","3.2.4","3.2.5","3.3","3.4","3.4.1","3.4.2","3.4.3","3.4.4","3.4.5","3.5","3.5b1","3.6","3.6.1"]}],"fixed_versions":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-5wp5-5229-5g6q","source_modified_at":"2026-10-27T07:58:08Z","fetched_at":"2026-10-27T10:24:27.527526Z","package":{"ecosystem":"pip","name":"nltk"},"version":"3.9.3"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-5wp5-5229-5g6q","source_modified_at":"2026-10-16T10:56:05.808390648Z","fetched_at":"2026-10-27T10:24:27.527526Z","package":{"name":"nltk","ecosystem":"PyPI","purl":"pkg:pypi/nltk"},"version":"3.9.3"}],"cvss":5.3,"severity":"Medium","kev":{"listed":false},"epss":{"probability":0.00101,"percentile":0.00892,"score_date":"2026-10-26"},"published_at":"2026-08-03T07:09:35.262Z","modified_at":"2026-10-27T07:58:08Z","provenance":[{"source":"GitHub Advisory Database","url":"https://github.com/advisories/GHSA-5wp5-5229-5g6q","fetched_at":"2026-10-27T10:24:27.527526Z","source_modified_at":"2026-10-27T07:58:08Z"},{"source":"CVE List","url":"https://www.cve.org/CVERecord?id=CVE-2026-12259","fetched_at":"2026-10-27T10:24:27.527526Z","source_modified_at":"2026-08-03T14:59:01.815Z"},{"source":"OSV","url":"https://osv.dev/vulnerability/GHSA-5wp5-5229-5g6q","fetched_at":"2026-10-27T10:24:27.527526Z","source_modified_at":"2026-10-16T10:56:05.808390648Z"},{"source":"EPSS","url":"https://api.first.org/data/v1/epss?cve=CVE-2026-12259","fetched_at":"2026-10-27T10:24:27.527526Z","source_modified_at":"2026-10-26"}],"sources":["GitHub Advisory Database","CVE List","OSV","EPSS"],"references":[{"url":"https://github.com/nltk/nltk/security/advisories/GHSA-5wp5-5229-5g6q","source":"GitHub Advisory Database"},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-12259","source":"GitHub Advisory Database"},{"url":"https://github.com/nltk/nltk/pull/3449","source":"GitHub Advisory Database"},{"url":"https://github.com/nltk/nltk/commit/0e26734a61094b628d93e26dc18dd7302567ac46","source":"GitHub Advisory Database"},{"url":"https://github.com/nltk/nltk/releases/tag/3.9.3","source":"GitHub Advisory Database"},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/nltk/PYSEC-2026-3729.yaml","source":"GitHub Advisory Database"},{"source":"CVE List","url":"https://huntr.com/bounties/659ccf6d-12d4-4d4a-84c0-078633c35a5d"},{"url":"https://www.vulncheck.com/advisories/nltk-before-missing-post-download-integrity-verification","source":"GitHub Advisory Database"},{"url":"https://github.com/advisories/GHSA-5wp5-5229-5g6q","source":"GitHub Advisory Database"}],"locations":[],"motoko_assessment":{"status":"requires_architecture_review","automatic_remediation":false},"cve_state":"PUBLISHED","ssvc":{"exploitation":"none","automatable":"no","technical_impact":"partial","assessed_at":"2026-08-03T14:55:19.698104Z"},"classification":{"method":"product-first software-layer rules","rules_version":"2.1","matched_on":"ecosystem","confidence":"heuristic","reviewed":false},"change_timestamp":"2026-10-27T07:58:08Z","content_hash":"e97589d7b7a812771411bd0b292f760e0080897302d466a1c887f27a77617104"}}
