CVE-2020-5529 Overview
CVE-2020-5529 is a code execution vulnerability affecting HtmlUnit prior to version 2.37.0. The vulnerability stems from improper initialization of the Rhino JavaScript engine, which allows malicious JavaScript code to execute arbitrary Java code on the application. Additionally, when HtmlUnit is embedded in Android applications, the Android-specific initialization of the Rhino engine is also performed improperly, creating another attack path for malicious JavaScript to execute arbitrary Java code.
Critical Impact
Attackers can leverage malicious JavaScript to execute arbitrary Java code on vulnerable applications using HtmlUnit, potentially leading to complete system compromise, data exfiltration, or further lateral movement within affected environments.
Affected Products
- HtmlUnit versions prior to 2.37.0
- Debian Linux 9.0
- Canonical Ubuntu Linux 16.04 (ESM)
- Apache Camel (when using HtmlUnit dependency)
Discovery Timeline
- 2020-02-11 - CVE-2020-5529 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2020-5529
Vulnerability Analysis
This vulnerability is classified under CWE-665 (Improper Initialization) and CWE-94 (Code Injection). The core issue lies in how HtmlUnit initializes the Mozilla Rhino JavaScript engine, which is used to interpret and execute JavaScript within headless browser simulations. Due to improper initialization, the Rhino engine does not properly sandbox JavaScript execution, allowing malicious scripts to break out of the JavaScript context and invoke arbitrary Java classes and methods.
The vulnerability is exploitable over the network without requiring any user interaction or privileges. However, the attack complexity is considered high because successful exploitation requires specific conditions to be met, including the ability to inject or control JavaScript content processed by HtmlUnit.
When HtmlUnit is used in Android applications, the vulnerability is compounded by additional improper Android-specific Rhino initialization, creating a dual attack surface on mobile platforms.
Root Cause
The root cause is improper initialization of the Rhino JavaScript engine (CWE-665). HtmlUnit failed to properly configure security restrictions and sandboxing for the Rhino engine, allowing JavaScript code to access Java reflection APIs and invoke arbitrary Java code. This improper initialization effectively bridges the JavaScript execution environment with the underlying Java runtime, violating the expected security boundary between interpreted JavaScript and the host application.
Attack Vector
The attack vector is network-based, targeting applications that process untrusted or attacker-controlled JavaScript content through HtmlUnit. An attacker can craft malicious JavaScript that, when processed by a vulnerable HtmlUnit instance, escapes the JavaScript sandbox and executes arbitrary Java code. This could occur in scenarios such as:
- Web scraping applications processing malicious web pages
- Automated testing frameworks executing tests against compromised sites
- Any application using HtmlUnit to render or analyze untrusted HTML/JavaScript content
The malicious JavaScript leverages the improperly initialized Rhino engine to access Java classes through reflection, enabling arbitrary Java code execution with the privileges of the running application.
Detection Methods for CVE-2020-5529
Indicators of Compromise
- Unexpected Java process behavior or system calls originating from HtmlUnit-based applications
- JavaScript content containing Java class references such as java.lang.Runtime or java.lang.ProcessBuilder
- Anomalous network connections or file system access from web scraping or testing applications
- Log entries showing JavaScript errors related to Java class access attempts
Detection Strategies
- Monitor application dependencies for HtmlUnit versions prior to 2.37.0 using software composition analysis (SCA) tools
- Implement runtime application self-protection (RASP) to detect JavaScript attempting to invoke Java reflection APIs
- Review application logs for suspicious JavaScript execution patterns or unexpected Java method invocations
- Deploy network intrusion detection to identify responses containing potentially malicious JavaScript targeting Rhino vulnerabilities
Monitoring Recommendations
- Enable verbose logging for HtmlUnit-based applications to capture JavaScript execution details
- Monitor system call activity from Java processes running HtmlUnit for signs of code execution
- Implement file integrity monitoring on systems hosting vulnerable applications
- Track outbound network connections from HtmlUnit-based services for potential data exfiltration
How to Mitigate CVE-2020-5529
Immediate Actions Required
- Upgrade HtmlUnit to version 2.37.0 or later immediately
- Audit all applications and dependencies that may include HtmlUnit as a transitive dependency
- Apply operating system security patches for Debian and Ubuntu as referenced in vendor advisories
- Review and restrict network access to applications using HtmlUnit to limit exposure to untrusted content
Patch Information
The vulnerability has been addressed in HtmlUnit version 2.37.0. The fix includes proper initialization and sandboxing of the Rhino JavaScript engine to prevent JavaScript from accessing arbitrary Java classes and methods. Users should upgrade to 2.37.0 or later.
For detailed information about the fix, see the HtmlUnit 2.37.0 Release Notes.
Additional security advisories are available from:
Workarounds
- Restrict HtmlUnit-based applications to process only trusted content sources until patching is complete
- Implement network segmentation to isolate applications using vulnerable HtmlUnit versions
- Consider disabling JavaScript processing in HtmlUnit if not required for application functionality
- Deploy web application firewalls (WAF) to filter potentially malicious JavaScript content before it reaches vulnerable applications
# Maven dependency update example
# Update pom.xml to use patched HtmlUnit version
# Replace:
# <dependency>
# <groupId>net.sourceforge.htmlunit</groupId>
# <artifactId>htmlunit</artifactId>
# <version>2.36.0</version>
# </dependency>
# With:
# <dependency>
# <groupId>net.sourceforge.htmlunit</groupId>
# <artifactId>htmlunit</artifactId>
# <version>2.37.0</version>
# </dependency>
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

