CVE-2023-36844 And Friends: RCE In Juniper Devices
Two vulnerabilities in Juniper SRX devices: an unauthenticated file upload and an environment variable injection in the web server. An attacker could chain them to achieve remote code execution by uploading a PHP configuration file and a PHP payload, then setting the PHPRC environment variable to load the configuration.
This research is a glimpse into the capability powering the watchTowr Platform, a Preemptive Exposure Management solution. We enable organizations to autonomously validate and mitigate their exposure to emerging threats, ahead of in-the-wild exploitation.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the web interface's authentication check was missing in one file, and the web server passed user-supplied form field names as environment variables to CGI scripts.
What the attacker needed
Network access to the J-Web interface; no authentication required
How it was found
- Upload a PHP file containing malicious code using the unauthenticated do_upload function.
- Upload a second file containing a php.ini configuration with an auto_prepend_file directive pointing to the first file.
- Send a request with a form field named PHPRC set to the path of the uploaded php.ini file, causing PHP to load it and execute the payload.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The Juniper firewall's web interface had two flaws. One let anyone upload files without logging in, and the other let an attacker set environment variables that control how programs run. By combining them, an attacker could make the device run their own code.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.