GHSA-8rr6-2qw5-pc7r

Suggest an improvement
Source
https://github.com/advisories/GHSA-8rr6-2qw5-pc7r
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/02/GHSA-8rr6-2qw5-pc7r/GHSA-8rr6-2qw5-pc7r.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-8rr6-2qw5-pc7r
Aliases
Published
2026-02-28T02:49:29Z
Modified
2026-02-28T06:43:32.470831Z
Severity
  • 6.8 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N CVSS Calculator
Summary
PMD Designer has Stored XSS in VBHTMLRenderer and YAHTMLRenderer via unescaped violation messages
Details

Summary

PMD's vbhtml and yahtml report formats insert rule violation messages into HTML output without escaping. When PMD analyzes untrusted source code containing crafted string literals, the generated HTML report contains executable JavaScript that runs when opened in a browser.

While the default html format is not affected via rule violation messages (it correctly uses StringEscapeUtils.escapeHtml4()), it has a similar problem when rendering suppressed violations. The user supplied message (the reason for the suppression) was not escaped.

Details

VBHTMLRenderer.java line 71 appends rv.getDescription() directly into HTML:

sb.append("<td><font class=body>").append(rv.getDescription()).append("</font></td>");

YAHTMLRenderer.java lines 196–203 does the same via renderViolationRow():

private String renderViolationRow(String name, String value) {
    return "<tr><td><b>" + name + "</b></td>" + "<td>" + value + "</td></tr>";
}

Called at line 172:

out.print(renderViolationRow("Description:", violation.getDescription()));

The violation message originates from AvoidDuplicateLiteralsRule.java line 91, which embeds raw string literal values via first.toPrintableString(). This calls StringUtil.escapeJava() (line 476–480), which is a Java source escaper — it passes <, >, and & through unchanged because they are printable ASCII (0x20–0x7e).

By contrast, HTMLRenderer.java line 143 properly escapes:

String d = StringEscapeUtils.escapeHtml4(rv.getDescription());

PoC

  1. Create a Java file with 4+ duplicate string literals containing an HTML payload:

    public class Exploit {
        String a = "<img src=x onerror=alert(document.domain)>";
        String b = "<img src=x onerror=alert(document.domain)>";
        String c = "<img src=x onerror=alert(document.domain)>";
        String d = "<img src=x onerror=alert(document.domain)>";
    }
    
  2. Run PMD with the vbhtml format:

    pmd check -R category/java/errorprone.xml -f vbhtml -d Exploit.java -r report.html
    
  3. Open report.html in a browser. A JavaScript alert executes showing document.domain.

The generated HTML contains the unescaped tag:

<td><font class=body>The String literal "<img src=x onerror=alert(document.domain)>" appears 4 times in this file</font></td>

Tested and confirmed on PMD 7.22.0-SNAPSHOT (commit bcc646c53d).

Impact

Stored cross-site scripting (XSS). Affects CI/CD pipelines that run PMD with --format vbhtml or --format yahtml on untrusted source code (e.g., pull requests from external contributors) and expose the HTML report as a build artifact. JavaScript executes in the browser context of anyone who opens the report.

Practical impact is limited because vbhtml and yahtml are legacy formats rarely used in practice. The default html format has a similar issue with user messages from suppressed violations.

Fixes

  • See #6475: [core] Fix stored XSS in VBHTMLRenderer and YAHTMLRenderer
Database specific
{
    "nvd_published_at": "2026-02-27T21:16:19Z",
    "github_reviewed_at": "2026-02-28T02:49:29Z",
    "github_reviewed": true,
    "cwe_ids": [
        "CWE-79"
    ],
    "severity": "MODERATE"
}
References

Affected packages

Maven / net.sourceforge.pmd:pmd-core

Package

Name
net.sourceforge.pmd:pmd-core
View open source insights on deps.dev
Purl
pkg:maven/net.sourceforge.pmd/pmd-core

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
7.22.0

Affected versions

5.*
5.2.0
5.2.1
5.2.2
5.2.3
5.3.0
5.3.1
5.3.2
5.3.3
5.3.4
5.3.5
5.3.6
5.3.7
5.3.8
5.4.0
5.4.1
5.4.2
5.4.3
5.4.4
5.4.5
5.4.6
5.5.0
5.5.1
5.5.2
5.5.3
5.5.4
5.5.5
5.5.6
5.5.7
5.6.0
5.6.1
5.7.0
5.8.0
5.8.1
6.*
6.0.0
6.0.1
6.1.0
6.2.0
6.3.0
6.4.0
6.5.0
6.6.0
6.7.0
6.8.0
6.9.0
6.10.0
6.11.0
6.12.0
6.13.0
6.14.0
6.15.0
6.16.0
6.17.0
6.18.0
6.19.0
6.20.0
6.21.0
6.22.0
6.23.0
6.24.0
6.25.0
6.26.0
6.27.0
6.28.0
6.29.0
6.30.0
6.31.0
6.32.0
6.33.0
6.34.0
6.35.0
6.36.0
6.37.0
6.38.0
6.39.0
6.40.0
6.41.0
6.42.0
6.43.0
6.44.0
6.45.0
6.46.0
6.47.0
6.48.0
6.49.0
6.50.0
6.51.0
6.52.0
6.53.0
6.54.0
6.55.0
7.*
7.0.0-rc1
7.0.0-rc2
7.0.0-rc3
7.0.0-rc4
7.0.0
7.1.0
7.2.0
7.3.0
7.4.0
7.5.0
7.6.0
7.7.0
7.8.0
7.9.0
7.10.0
7.11.0
7.12.0
7.13.0
7.14.0
7.15.0
7.16.0
7.17.0
7.18.0
7.19.0
7.20.0
7.21.0

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/02/GHSA-8rr6-2qw5-pc7r/GHSA-8rr6-2qw5-pc7r.json"
last_known_affected_version_range
"<= 7.21.0"