# VMware Aria Operations for Logs RCE (CVE-2023-20864)
[CVE này](https://nvd.nist.gov/vuln/detail/cve-2023-20864) mình dựng lại từ lâu rồi, lỗi không có gì phức tạp, [bài phân tích cũng có rồi](https://www.zerodayinitiative.com/blog/2023/6/29/cve-2023-20864-remote-code-execution-in-vmware-aria-operations-for-logs), nhưng gà 🐤 nên phải nhờ có sự hỗ trợ từ [devme4f](https://twitter.com/devme4f) thì mình mới RCE thành công. Nay viết lại chính chỉ để note lại các bước mình đã thực hiện, bla bal...
## Mô tả

**[CVE-2023-20864](https://nvd.nist.gov/vuln/detail/cve-2023-20864)** là lỗ hổng insecure deserialization tồn tại trên VMware Aria Operations for Logs (VMware AOL) 8.10.2, cộng với việc Unauthen nên chỉ cần tìm được gadget chain là xong
## Setup
Sau khi tạo máy ảo thành công, login với user `root`, password trống và đổi lại mật khẩu

Truy cập trang quản trị (443/tcp) và tạo deployment mới


Mấy bước setup sau không cần thiết cứ skip thôi
## Explore
Version java

VMware AOL chạy một số service sau
* 9000/tcp và 9543/tcp (SSL) : Ingestion API, API management
* 9042/tcp : Cassandra service
* 7000/tcp 7001/tcp (SSL): Cassandra replication and query
* 59778/tcp, 16520 - 16580/tcp: Thrift service
Trong đó lỗ hổng tồn tại trong các API sau tại service API management
```
POST /api/v2/internal/cluster/applyMembership
controllers.InternalClusterController.applyMembership(request :play.mvc.Http.Request)
POST /api/v2/internal/cluster/setToken
controllers.InternalClusterController.setToken(request :play.mvc.Http.Request)
POST /api/v2/internal/cluster/approveMembership
controllers.InternalClusterController.approveMembership(request :play.mvc.Http.Request)
```
Xem process nào đang mở port 9000/tcp và 9543/tcp

=> pid=1631
Kiểm tra process thấy có classpath như sau

Tuy nhiên để tránh sót một số file jar có thể được include trong file meta, mình sẽ làm như sau

Nén lại và kéo ra ngoài đọc thôi

Sau khi giải nén sẽ có một số file trùng nên còn 249 file (tính cả jre, đáng lẽ nên exclude đống này ra 🦍)
3 API thực hiện deserialize nằm trong *api-play-service_2.13-1.0.jar!controllers/InternalClusterController.class*

Các API này đều deserialize trực tiếp body data bằng [SerializationUtils](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/SerializationUtils.html) trong [commons-lang3](https://mvnrepository.com/artifact/org.apache.commons/commons-lang3/3.1)

Check một lượt đống lib thì mình thấy có thể dùng các gadget chains sau
* CommonsBeanutils1 (commons-beanutils-1.9.4.jar)
* CVE-2022-36944 (scala-library-2.13.5.jar) [PoC](https://github.com/yarocher/lazylist-cve-poc)
## PoC
#### *CommonsBeanutils1*

RCE với quyền root
<iframe width="560" height="315" src="https://www.youtube.com/embed/-g-oA0W4iNE?si=O-cX2wN87-ka4dK8" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
Ngoài ra gadget chain từ scala library có thể được dùng để xóa nội dung file bất kỳ
## refs
* https://www.zerodayinitiative.com/blog/2023/6/29/cve-2023-20864-remote-code-execution-in-vmware-aria-operations-for-logs
* https://hackmd.io/@devme4f/r1klIM0An
* https://github.com/yarocher/lazylist-cve-poc