CVE-2020-5529
Description
HtmlUnit prior to 2.37.0 contains code execution vulnerabilities. HtmlUnit initializes Rhino engine improperly, hence a malicious JavScript code can execute arbitrary Java code on the application. Moreover, when embedded in Android application, Android-specific initialization of Rhino engine is done in an improper way, hence a malicious JavaScript code can execute arbitrary Java code on the application.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
HtmlUnit before 2.37.0 improperly initializes the Rhino engine, allowing arbitrary Java code execution via malicious JavaScript.
Vulnerability
Analysis
CVE-2020-5529 is an improper initialization vulnerability in HtmlUnit, a Java library that simulates a web browser. The issue resides in the way HtmlUnit initializes the Mozilla Rhino JavaScript engine. By default, Rhino provides a feature to expose Java objects to JavaScript code. HtmlUnit's flawed initialization fails to restrict this access, allowing a malicious JavaScript snippet to call arbitrary Java methods [1][2].
Exploitation
An attacker can exploit this vulnerability by leading a target application to evaluate attacker-controlled JavaScript. This could be achieved via a man-in-the-middle attack, by tricking the application into loading a malicious webpage, or by injecting script into a trusted context. No authentication is required, but the attacker must be able to inject or intercept script execution. For applications running on Android, the Android-specific Rhino initialization is similarly misconfigured, enabling the same attack vector [2].
Impact
Successful exploitation allows the attacker to execute arbitrary Java code within the context of the host application. This can lead to full compromise of the application's runtime environment, including data theft, denial of service, or further lateral movement within the host system. The CVSS v3 base score is 5.6 (Medium), with a vector of AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L [2].
Mitigation
The vulnerability is fixed in HtmlUnit version 2.37.0. The fix explicitly prevents Rhino from accessing Java resources, as demonstrated by a commit that blocks calls like java.lang.Math.PI from JavaScript [4]. Users should upgrade to HtmlUnit 2.37.0 or later. For Android deployments, updating the library is also the recommended solution [2].
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
net.sourceforge.htmlunit:htmlunitMaven | < 2.37.0 | 2.37.0 |
Affected products
3- HtmlUnit Project/HtmlUnitv5Range: prior to 2.37.0
Patches
1bc1f58d483ccSecurity: prevent Rhinos access to Java resources; e.g. call java methods
2 files changed · +53 −0
src/changes/changes.xml+3 −0 modified@@ -8,6 +8,9 @@ <body> <release version="2.37.0" date="xxxx, 2020" description="Bugfixes, CHROME 79, FF52 removed, FF68 added"> + <action type="fix" dev="rbri"> + Security: prevent Rhinos access to Java resources; e.g. call java methods. + </action> <action type="update" dev="rbri"> Upgrade Apache HttpComponents to 4.5.11. </action>
src/test/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine2Test.java+50 −0 modified@@ -16,6 +16,8 @@ import static org.junit.Assert.fail; +import java.net.URL; + import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.By; @@ -891,4 +893,52 @@ public void ctorBooleanDocumentAll() throws Exception { loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("exception") + public void javaNotAccessable() throws Exception { + final String html = "<html><head>\n" + + "<script>\n" + + "function test() {\n" + + " try {\n" + + " alert(java.lang.Math.PI);\n" + + " } catch (e) { alert('exception'); }\n" + + "}\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("Received: from worker - exception") + public void javaNotAccessableFromWorker() throws Exception { + final String html = "<html><body>\n" + + "<script async>\n" + + "try {\n" + + " var myWorker = new Worker('worker.js');\n" + + " myWorker.onmessage = function(e) {\n" + + " alert('Received: ' + e.data);\n" + + " };\n" + + "} catch(e) { alert('exception' + e); }\n" + + "</script></body></html>\n"; + + final String workerJs = "var pi = 'from worker';\n" + + "try {\n" + + " pi = pi + ' - ' + java.lang.Math.PI\n" + + "} catch (e) { pi = pi + ' - ' + 'exception'; }\n" + + "postMessage(pi);\n"; + + getMockWebConnection().setResponse(new URL(URL_FIRST, "worker.js"), workerJs); + + loadPageWithAlerts2(html, 2000); + } }
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
11- github.com/advisories/GHSA-5mh9-r3rr-9597ghsaADVISORY
- jvn.jp/en/jp/JVN34535327/mitrethird-party-advisoryx_refsource_JVN
- nvd.nist.gov/vuln/detail/CVE-2020-5529ghsaADVISORY
- usn.ubuntu.com/4584-1/mitrevendor-advisoryx_refsource_UBUNTU
- github.com/HtmlUnit/htmlunit/commit/bc1f58d483cc8854a9c4c1739abd5e04a2eb0367ghsaWEB
- github.com/HtmlUnit/htmlunit/releases/tag/2.37.0ghsax_refsource_CONFIRMWEB
- jvn.jp/en/jp/JVN34535327ghsaWEB
- lists.apache.org/thread.html/ra2cd7f8e61dc6b8a2d9065094cd1f46aa63ad10f237ee363e26e8563%40%3Ccommits.camel.apache.org%3Eghsamailing-listx_refsource_MLISTWEB
- lists.apache.org/thread.html/ra2cd7f8e61dc6b8a2d9065094cd1f46aa63ad10f237ee363e26e8563@%3Ccommits.camel.apache.org%3EghsaWEB
- lists.debian.org/debian-lts-announce/2020/08/msg00023.htmlghsamailing-listx_refsource_MLISTWEB
- usn.ubuntu.com/4584-1ghsaWEB
News mentions
0No linked articles in our index yet.