Skip to content
RCE Write-up Advanced

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.

watchTowr Follow

Published on labs.watchtowr.com

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.

watchTowr (@watchtowrcyber), on labs.watchtowr.com

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

  1. Upload a PHP file containing malicious code using the unauthenticated do_upload function.
  2. Upload a second file containing a php.ini configuration with an auto_prepend_file directive pointing to the first file.
  3. 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.

More by watchTowr

View all

3 more disclosed reports, best first.

More from Juniper

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.