平台
python
组件
tarfile
修复版本
3.10.18
3.11.13
3.12.11
3.13.4
3.14.0b3
CVE-2025-4138 是一个高危漏洞,影响 Python tarfile 模块。该漏洞允许攻击者通过忽略提取过滤器,将符号链接目标指向目标目录之外,从而修改文件元数据。受影响的版本包括 Python 3.10.0 到 3.14.0b3。已发布修复版本 3.14.0b3。
此漏洞的潜在影响非常严重。攻击者可以利用此漏洞在目标系统上创建恶意文件,甚至可能在目标目录之外写入文件,从而导致未经授权的访问和数据泄露。攻击者可以利用此漏洞修改文件权限、覆盖重要系统文件,甚至可能执行任意代码。如果攻击者能够控制压缩包的内容,他们可以完全控制解压后的文件系统。由于 tarfile 模块广泛应用于各种 Python 应用程序中,因此此漏洞的潜在影响范围非常广泛。
目前尚未公开发现利用此漏洞的公开 POC。该漏洞已添加到 CISA KEV 目录中,表明其具有中等概率被利用。NVD 已于 2025-06-03 公布此漏洞。
Systems using Python 3.10.0 through 3.14.0b3 that process untrusted tar archives are at risk. This includes web applications, automation scripts, and any system that relies on the tarfile module to extract archives from external sources. Shared hosting environments where multiple users can upload files are particularly vulnerable.
• python / server:
find / -name '*tar.gz' -o -name '*tar.bz2' -o -name '*tar'• python / supply-chain:
import os
import tarfile
def check_tarfile_extraction(filepath, destination):
try:
with tarfile.open(filepath, 'r') as tar:
tar.extractall(path=destination, filter='data') # Vulnerable code
return False # No vulnerability detected
except Exception as e:
return True # Vulnerability detected
# Example usage (replace with actual filepaths)
filepath = '/path/to/your/archive.tar.gz'
destination = '/tmp/extraction_test'
if check_tarfile_extraction(filepath, destination):
print(f"Potential vulnerability detected in {filepath}")
else:
print(f"No vulnerability detected in {filepath}")disclosure
漏洞利用状态
EPSS
0.10% (27% 百分位)
CISA SSVC
CVSS 向量
为了缓解 CVE-2025-4138 的风险,建议立即升级到 Python 3.14.0b3 或更高版本。如果无法立即升级,可以考虑使用更严格的提取过滤器,或者验证压缩包的内容是否可信。避免使用 filter=“data”或 filter=“tar”参数。在解压之前,可以使用第三方工具扫描压缩包,以检测潜在的恶意文件。此外,可以考虑使用更安全的压缩格式,例如 zip,它具有内置的安全机制来防止符号链接攻击。
Actualice la biblioteca CPython a la versión 3.10.18 o superior, 3.11.13 o superior, 3.12.11 o superior, 3.13.4 o superior, o 3.14.0b3 o superior. Evite usar la función `TarFile.extractall()` o `TarFile.extract()` con el parámetro `filter=` configurado en 'data' o 'tar' con archivos tar no confiables.
漏洞分析和关键警报直接发送到您的邮箱。
CVE-2025-4138 是一个高危漏洞,影响 Python tarfile 模块,允许攻击者通过忽略提取过滤器,修改文件元数据。
如果您正在使用 Python 3.10.0 到 3.14.0b3 版本,并且在应用程序中使用了 tarfile 模块来解压不受信任的 tar 压缩包,则可能受到影响。
建议立即升级到 Python 3.14.0b3 或更高版本。
目前尚未公开发现利用此漏洞的公开 POC,但已添加到 CISA KEV 目录中,表明其具有中等概率被利用。
请参考 Python 官方安全公告:https://docs.python.org/3/library/tarfile.html#tarfile-extraction-filter
上传你的 requirements.txt 文件,立即知道是否受影响。