Skip to main content
Vulnerability Database/CVE-2016-20102

CVE-2016-20102: JavaMelody XSS Vulnerability

CVE-2016-20102 is a reflected cross-site scripting flaw in JavaMelody before 1.60.0 that allows attackers to inject malicious scripts through the graph parameter. This post covers technical details, affected versions, and mitigation.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2016-20102 Overview

CVE-2016-20102 is a reflected cross-site scripting (XSS) vulnerability in JavaMelody versions before 1.60.0. The flaw resides in the /monitoring?part=graph endpoint, where the graph parameter is only JavaScript-escaped inside HtmlCounterReport. Attackers can supply a crafted value containing a closing </script> tag to break out of the script context and execute arbitrary JavaScript in a victim's browser. Exploitation requires no authentication but does require user interaction, such as clicking a crafted link. The Shadowserver Foundation first observed exploitation evidence on 2023-10-18. The weakness is classified under CWE-79: Improper Neutralization of Input During Web Page Generation.

Critical Impact

Unauthenticated attackers can execute arbitrary JavaScript in the context of any user who visits a crafted JavaMelody monitoring URL, enabling session theft and administrative action hijacking.

Affected Products

  • JavaMelody versions prior to 1.60.0
  • Java web applications embedding the vulnerable javamelody-core library
  • Deployments exposing the /monitoring endpoint to untrusted networks

Discovery Timeline

  • 2023-10-18 - Exploitation activity first observed by the Shadowserver Foundation
  • 2026-10-20 - CVE-2016-20102 published to NVD
  • 2026-10-22 - Last updated in NVD database

Technical Details for CVE-2016-20102

Vulnerability Analysis

JavaMelody is a monitoring library for Java EE applications. The library exposes a /monitoring servlet that renders HTML reports, including graph views generated by HtmlCounterReport. When a request reaches /monitoring?part=graph, the graph query parameter is embedded into inline JavaScript inside the response. The embedding routine applies JavaScript string escaping but does not neutralize HTML-level sequences, so a value containing </script> prematurely terminates the surrounding <script> block. Any markup that follows is parsed by the browser as HTML, allowing arbitrary JavaScript execution in the authenticated monitoring session.

Root Cause

The root cause is incomplete output encoding in HtmlCounterReport.java. The code JavaScript-escapes the parameter but omits HTML entity encoding before writing into a <script> element. The upstream fix wraps the value with I18N.htmlEncode(urlEncode(graphName), false), ensuring that angle brackets and other reserved HTML characters are encoded before reaching the DOM.

Attack Vector

Exploitation is network-based and requires a victim to load a crafted URL. An attacker constructs a request such as /monitoring?part=graph&graph=</script><script>alert(1)</script> and delivers it through phishing, forum posts, or embedded iframes. When an authenticated administrator visits the link, the injected script runs with their session cookies and can perform actions available to the monitoring interface or pivot to additional application endpoints.

java
// Patch from HtmlCounterReport.java
// Source: https://github.com/javamelody/javamelody/commit/de7b648eebc3254fcb82fcda60de83a212271def
			writeln("  height = Math.round(width * initialHeight / initialWidth) - 48;");
			// reload the images
			// rq : on utilise des caractères unicode pour éviter des warnings
-			writeln("  document.getElementById('img').src = '?graph=" + urlEncode(graphName)
+			writeln("  document.getElementById('img').src = '?graph=" + I18N.htmlEncode(urlEncode(graphName), false)
					+ "\\\u0026width=' + width + '\\\u0026height=' + height;");
			writeln("  document.getElementById('img').style.width = '';");
			writeln("}");

Source: GitHub Commit de7b648. The patch adds I18N.htmlEncode(...) so the parameter is HTML-encoded before it is embedded into the inline script.

Detection Methods for CVE-2016-20102

Indicators of Compromise

  • HTTP requests to /monitoring?part=graph containing URL-encoded </script> sequences or <script> tags in the graph parameter
  • Referrer logs showing external domains linking directly to /monitoring endpoints on internal applications
  • Web application firewall alerts citing XSS payloads targeting the graph query parameter
  • Outbound requests from administrator browsers to attacker-controlled hosts shortly after visiting monitoring URLs

Detection Strategies

  • Deploy the public Nuclei template for JavaMelody XSS against internal application inventories to identify exposed vulnerable instances
  • Inventory running Java applications for javamelody-core versions earlier than 1.60.0 using software composition analysis tooling
  • Create signatures that flag any graph= parameter value containing angle brackets, script, on-event handlers, or javascript: schemes

Monitoring Recommendations

  • Log and alert on all requests to /monitoring paths from source IPs outside expected administrative ranges
  • Track browser-side errors and Content Security Policy violation reports originating from the monitoring interface
  • Correlate successful XSS indicators with subsequent administrative actions to identify session hijack attempts

How to Mitigate CVE-2016-20102

Immediate Actions Required

  • Upgrade javamelody-core to version 1.60.0 or later across all deployed Java applications
  • Restrict access to the /monitoring endpoint using network ACLs, authentication filters, or reverse-proxy rules
  • Review web server logs since 2023-10-18 for exploitation attempts and investigate matching administrator sessions

Patch Information

The fix is delivered in JavaMelody 1.60.0 through commit de7b648eebc3254fcb82fcda60de83a212271def, merged via Pull Request #555. The patch applies I18N.htmlEncode to the graphName value before it is written into the inline script in HtmlCounterReport. Additional context is available in the VulnCheck advisory.

Workarounds

  • Block external access to any URL path containing /monitoring at the web application firewall or load balancer
  • Enforce a strict Content Security Policy that disallows inline script execution on the monitoring interface
  • Require authentication and multi-factor verification before any /monitoring route can be reached
  • Filter inbound query strings to reject graph parameter values containing <, >, or script
bash
# Example nginx rule to block exploitation attempts
location /monitoring {
    if ($arg_graph ~* "(<|>|script|javascript:|onerror=)") {
        return 403;
    }
    allow 10.0.0.0/8;
    deny all;
}

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.