CVE-2021-31385 Overview
CVE-2021-31385 is a Path Traversal vulnerability (CWE-22) affecting the J-Web management interface in Juniper Networks Junos OS. This vulnerability enables any low-privileged authenticated attacker to escalate their privileges to root on affected devices. The J-Web interface is the web-based management GUI for Junos OS devices, commonly used by network administrators for device configuration and monitoring.
The vulnerability stems from an Improper Limitation of a Pathname to a Restricted Directory condition within J-Web, which fails to properly sanitize user-supplied input in file path operations. When exploited, an attacker with minimal access to the web interface can traverse directory structures and access or manipulate files outside the intended restricted directory, ultimately achieving root-level access to the underlying system.
Critical Impact
Low-privileged authenticated attackers can escalate to root privileges on Juniper network devices, potentially gaining complete control over critical network infrastructure.
Affected Products
- Juniper Networks Junos OS 12.3 versions prior to 12.3R12-S19
- Juniper Networks Junos OS 15.1 versions prior to 15.1R7-S10
- Juniper Networks Junos OS 18.3 versions prior to 18.3R3-S5
- Juniper Networks Junos OS 18.4 versions prior to 18.4R3-S9
- Juniper Networks Junos OS 19.1 versions prior to 19.1R3-S6
- Juniper Networks Junos OS 19.2 versions prior to 19.2R1-S7 or 19.2R3-S3
- Juniper Networks Junos OS 19.3 versions prior to 19.3R3-S3
- Juniper Networks Junos OS 19.4 versions prior to 19.4R3-S5
- Juniper Networks Junos OS 20.1 versions prior to 20.1R2-S2 or 20.1R3-S1
- Juniper Networks Junos OS 20.2 versions prior to 20.2R3-S2
- Juniper Networks Junos OS 20.3 versions prior to 20.3R3
- Juniper Networks Junos OS 20.4 versions prior to 20.4R2-S1 or 20.4R3
- Juniper Networks Junos OS 21.1 versions prior to 21.1R1-S1 or 21.1R2
Discovery Timeline
- October 19, 2021 - CVE-2021-31385 published to NVD
- November 21, 2024 - Last updated in NVD database
Technical Details for CVE-2021-31385
Vulnerability Analysis
This path traversal vulnerability exists within the J-Web management interface, which is the web-based GUI provided by Junos OS for device administration. The vulnerability allows authenticated users, even those with minimal privileges, to bypass intended access restrictions by manipulating file path parameters in HTTP requests to the J-Web interface.
Path traversal attacks exploit insufficient input validation when the application processes file paths. By inserting directory traversal sequences (such as ../) into file path parameters, an attacker can navigate outside the application's intended directory scope and access sensitive system files or execute privileged operations.
The privilege escalation aspect of this vulnerability is particularly severe because network devices running Junos OS typically serve critical infrastructure functions—routing, firewall enforcement, and network segmentation. Root access to such devices could enable an attacker to intercept or modify network traffic, disable security controls, pivot to other network segments, or cause widespread network outages.
Root Cause
The root cause of CVE-2021-31385 is improper input validation and sanitization of pathname parameters within the J-Web application. The J-Web interface fails to adequately restrict user-supplied input when constructing file paths, allowing directory traversal sequences to escape the intended restricted directory structure. This lack of canonicalization and path validation enables attackers to reference files and directories outside the web application's designated scope, ultimately reaching system-level files that can be leveraged for privilege escalation.
Attack Vector
The attack is network-accessible and requires authentication, though only low-privilege credentials are necessary. An attacker would:
- Authenticate to the J-Web management interface using any valid low-privileged account
- Craft malicious HTTP requests containing path traversal sequences in vulnerable parameters
- Use the traversal capability to access or manipulate sensitive system files
- Leverage file access to escalate privileges to root
The attack does not require user interaction beyond the initial authentication. Given that J-Web interfaces are often exposed to management networks and sometimes inadvertently to the internet, the attack surface can be significant. The path traversal vulnerability allows the attacker to escape the web application's sandbox and interact with the underlying Junos OS at the file system level, enabling root-level privilege escalation.
Detection Methods for CVE-2021-31385
Indicators of Compromise
- Anomalous HTTP requests to J-Web containing path traversal sequences such as ../, ..%2f, or URL-encoded variants
- Unexpected file access patterns in J-Web server logs, particularly requests targeting paths outside /var/www/ or expected web directories
- Authentication events from J-Web followed by suspicious privilege changes or root-level operations
- Log entries indicating access to sensitive system files like /etc/passwd, /etc/shadow, or configuration files from J-Web context
Detection Strategies
- Implement web application firewall (WAF) rules to detect and block path traversal patterns in HTTP requests to J-Web interfaces
- Monitor J-Web access logs for requests containing sequences like ../, ..%2f, %2e%2e/, and similar encoding variants
- Deploy network intrusion detection systems (IDS) with signatures for path traversal attacks targeting Juniper devices
- Correlate authentication logs with privilege escalation events to identify potential exploitation attempts
Monitoring Recommendations
- Enable detailed logging for all J-Web authentication and authorization events
- Configure SIEM alerts for path traversal indicators in HTTP request URLs and parameters targeting Juniper management interfaces
- Regularly audit user accounts with J-Web access and review for suspicious privilege changes
- Monitor for unexpected root-level process execution following J-Web sessions
How to Mitigate CVE-2021-31385
Immediate Actions Required
- Upgrade to patched Junos OS versions as specified by Juniper Networks Security Advisory JSA11253
- If immediate patching is not possible, disable J-Web interface access until patches can be applied
- Restrict J-Web access to trusted management networks only using ACLs and firewall rules
- Audit all user accounts with J-Web access and remove unnecessary privileges
- Review logs for any signs of prior exploitation attempts
Patch Information
Juniper Networks has released security patches addressing this vulnerability across all affected Junos OS versions. Organizations should upgrade to the following minimum versions:
- Junos OS 12.3R12-S19 or later
- Junos OS 15.1R7-S10 or later
- Junos OS 18.3R3-S5 or later
- Junos OS 18.4R3-S9 or later
- Junos OS 19.1R3-S6 or later
- Junos OS 19.2R1-S7, 19.2R3-S3, or later
- Junos OS 19.3R3-S3 or later
- Junos OS 19.4R3-S5 or later
- Junos OS 20.1R2-S2, 20.1R3-S1, or later
- Junos OS 20.2R3-S2 or later
- Junos OS 20.3R3 or later
- Junos OS 20.4R2-S1, 20.4R3, or later
- Junos OS 21.1R1-S1, 21.1R2, or later
Refer to the Juniper Security Advisory JSA11253 for complete details on patched versions and upgrade instructions.
Workarounds
- Disable J-Web entirely if web-based management is not required: use CLI management via SSH instead
- Implement strict access control lists (ACLs) limiting J-Web access to specific trusted IP addresses or management subnets
- Deploy a reverse proxy with path traversal filtering in front of J-Web interfaces
- Use firewall rules to block external access to J-Web management ports (typically TCP/80 and TCP/443 on the management interface)
# Disable J-Web on Junos OS
configure
delete system services web-management
commit
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


