CVE-2016-4437 Apache Shiro <= 1.2.4 默认密钥致命令执行漏洞
漏洞简述
Apache Shiro是美国阿帕奇(Apache)软件基金会的一套用于执行认证、授权、加密和会话管理的Java安全框架。 Apache Shiro 1.0.0版本至1.2.4版本中将密钥硬编码在代码中,攻击者可使用默认密钥发送带有特制参数的请求利用该漏洞执行任意代码或访问受限制内容。
Apache Shiro框架提供了记住我(RememberMe)的功能,关闭了浏览器下次访问时无需再登录即可访问。
shiro默认使用了CookieRememberMeManager,其处理cookie的流程是: 得到rememberMe的cookie值-->Base64解码-->AES解密-->反序列化
攻击者构造一个恶意的对象,并且对其序列化,AES加密,base64编码后,作为cookie的rememberMe字段发送。Shiro将rememberMe进行解密并且反序列化,最终造成反序列化漏洞。
漏洞影响版本
Apache Shiro < 1.2.4
Shodan 搜索语法
rememberMe

漏洞exp
https://github.com/feihong-cs/ShiroExploit-Deprecated.git
漏洞环境搭建
使用vulhub复现。
cd vulhub/shiro/CVE-2016-4437 docker-compose up -d

漏洞复现
在1.2.4 版本前,是默认ASE秘钥Key: kPH+bIxk5D2deZiIxcaaaA== ,可以直接反序列化执行恶意代码。而在1.2.4之后,ASE秘钥就不为默认了,需要获取到Key才可以进行渗透。
使用上面的exp。

执行反弹shell。

在服务端监听端口,反弹shell成功。

溯源排查
排查日志对rememberMe进行解密。
恶意 Cookie rememberMe值构造:前16字节的密钥 -> 后面加入序列化参数 -> AES加密 -> base64编码 -> 发送cookie
Apache Shiro处理cookie的流程:得到rememberMe的cookie值 -> Base64解码 -> AES-128-CBC解密-> 反序列化(readobject)。
rememberMe管理器代码中写到cookie加密密钥默认为AES算法,可以将黑客常用的攻击密钥做一个keylist进行解密。
https://github.com/Wh0ale/SHIRO_Rememberme_decode
WEB-shiro_rememberMe_encode_decode 在线加解密工具
修复方式
目前厂商已经发布了升级补丁以修复此安全问题,补丁获取链接: http://shiro.apache.org/download.html
赞赏微信赞赏
支付宝赞赏
发表评论