Skip to content
RCE Write-up Advanced

CVE-2022-22241: Juniper SSLVPN / JunOS RCE and Multiple Vulnerabilities

Multiple vulnerabilities in Juniper JunOS J-Web, including a pre-authenticated PHP phar deserialization that can lead to remote code execution, a reflected XSS, XPath injection, path traversal in file upload, and local file inclusion. An unauthenticated attacker could exploit the phar deserialization to write arbitrary files and potentially execute code, while other flaws require authentication or chaining.

Paulos Yibelo Follow

Published on octagon.net

The following software releases have been updated to resolve these specific issues: Junos OS 19.1R3-S9, 19.2R3-S6, 19.3R3-S7, 19.4R3-S9, 20.1R3-S5, 20.2R3-S5, 20.3R3-S5, 20.4R3-S4, 21.1R3-S2, 21.2R3-S1, 21.3R2-S2, 21.3R3, 21.4R1-S2, 21.4R3, 22.1R1-S1, 22.1R2, 22.2R1, and all subsequent releases. The Juniper advisory…

PWNAI Research, on octagon.net

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 root cause is missing authentication checks and improper input validation in multiple PHP scripts, allowing user-controlled input to reach dangerous functions like deserialization, XPath queries, file operations, and file inclusion.

What the attacker needed

Network access to J-Web; For some bugs, a low-privileged account; Victim interaction for XSS

The fix

The vulnerabilities were fixed in the listed Junos OS releases; as a workaround, disable J-Web or limit access to trusted hosts.

How it was found

  1. Send a POST request to /jsdm/ajax/logging_browse.php with the filepath parameter pointing to a phar file.
  2. The phar file can be a local image uploaded through the image upload portal, a cache file, or a remote file uploaded via the unauthenticated upload page.
  3. For the XSS, access /error.php with a crafted SERVER_NAME parameter.
  4. For XPath injection, send a request to /jsdm/ajax/wizards/setup/setup.php with a cmd parameter.
  5. For path traversal, upload a file with a filename containing backslashes to bypass check_filename and write to an arbitrary location.
  6. For local file inclusion, send a request to /jrest.php with a crafted query string to include an arbitrary PHP file.

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.

This report describes several security holes in Juniper's JunOS web interface. The most serious one lets an attacker who has not logged in trick the server into running harmful code by sending a specially crafted file path. Other bugs let logged-in users do things like inject commands or upload files to unintended places.

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 Paulos Yibelo

View all

6 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.