CVE-2026-28338: Pmd core Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-8rr6-2qw5-pc7r
CVSS 6.8
CWE-79
Published
Advisory Summary

CVE-2026-28338 is a MODERATE (CVSS 6.8) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Pmd core libraries in the Maven ecosystem. The issue involves pmd designer has stored xss in vbhtmlrenderer and yahtmlrenderer via unescaped violation messages. Remediation is available by upgrading affected packages to version 7.22.0.

CVE-2026-28338 at a Glance

CVE Identifier CVE-2026-28338
GHSA Identifier GHSA-8rr6-2qw5-pc7r
Severity MODERATE
CVSS v3.1 Base Score 6.8
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Pmd core
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 6.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-28338

To remediate this vulnerability, upgrade all affected Pmd core dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

net.sourceforge.pmd:pmd-core fixed: 7.22.0
<dependency>
    <groupId>net.sourceforge.pmd</groupId>
    <artifactId>pmd-core</artifactId>
    <version>7.22.0</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=net.sourceforge.pmd

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2026-28338, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=net.sourceforge.pmd

Analyze the terminal output to locate any version of Pmd core in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 7.22.0), your application is affected.

Note: The mvn dependency:tree -Dincludes=net.sourceforge.pmd command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Pmd core, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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: ```java sb.append("<td><font class=body>").append(rv.getDescription()).append("</font></td>"); ``` `YAHTMLRenderer.java` lines 196–203 does the same via `renderViolationRow()`: ```java private String renderViolationRow(String name, String value) { return "<tr><td><b>" + name + "</b></td>" + "<td>" + value + "</td></tr>"; } ``` Called at line 172: ```java 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: ```java String d = StringEscapeUtils.escapeHtml4(rv.getDescription()); ``` ### PoC 1. Create a Java file with 4+ duplicate string literals containing an HTML payload: ```java 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: ```bash 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: ```html <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](https://github.com/pmd/pmd/issues/6475): \[core] Fix stored XSS in VBHTMLRenderer and YAHTMLRenderer

CVE-2026-28338 Affected Pmd core Versions

1 component(s)
Fixed Versions:
7.22.0
Product / Package Ecosystem Affected Versions Fixed Version
net.sourceforge.pmd:pmd-core
Maven
< 7.22.0
7.22.0

References

Frequently Asked Questions

What is CVE-2026-28338?
CVE-2026-28338 is a security vulnerability in Pmd core involving PMD Designer has Stored XSS in VBHTMLRenderer and YAHTMLRenderer via unescaped violation messages under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Pmd core versions are affected?
Affected versions include releases prior to 7.22.0 across affected packages: net.sourceforge.pmd:pmd-core.
What version fixes CVE-2026-28338?
Upgrading to 7.22.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pmd-core affected?
Yes, net.sourceforge.pmd:pmd-core is affected in releases prior to 7.22.0. Upgrade your dependency to 7.22.0 or later.
What is the CVSS score of CVE-2026-28338?
CVE-2026-28338 has a CVSS v3.1 base score of 6.8 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2026-28338?
CVE-2026-28338 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check Maven dependencies for CVE-2026-28338?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=net.sourceforge.pmd'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8rr6-2qw5-pc7r",
  "modified" : "2026-02-28T02:49:29Z",
  "published" : "2026-02-28T02:49:29Z",
  "aliases" : [ "CVE-2026-28338" ],
  "summary" : "PMD Designer has Stored XSS in VBHTMLRenderer and YAHTMLRenderer via unescaped violation messages",
  "details" : "### Summary\nPMD'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.\n\nWhile 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.\n\n### Details\n`VBHTMLRenderer.java` line 71 appends `rv.getDescription()` directly into HTML:\n\n```java\nsb.append(\"<td><font class=body>\").append(rv.getDescription()).append(\"</font></td>\");\n```\n\n`YAHTMLRenderer.java` lines 196–203 does the same via `renderViolationRow()`:\n\n```java\nprivate String renderViolationRow(String name, String value) {\n    return \"<tr><td><b>\" + name + \"</b></td>\" + \"<td>\" + value + \"</td></tr>\";\n}\n```\n\nCalled at line 172:\n\n```java\nout.print(renderViolationRow(\"Description:\", violation.getDescription()));\n```\n\nThe 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).\n\nBy contrast, `HTMLRenderer.java` line 143 properly escapes:\n\n```java\nString d = StringEscapeUtils.escapeHtml4(rv.getDescription());\n```\n### PoC\n\n1. Create a Java file with 4+ duplicate string literals containing an HTML payload:\n\n```java\npublic class Exploit {\n    String a = \"<img src=x onerror=alert(document.domain)>\";\n    String b = \"<img src=x onerror=alert(document.domain)>\";\n    String c = \"<img src=x onerror=alert(document.domain)>\";\n    String d = \"<img src=x onerror=alert(document.domain)>\";\n}\n```\n\n2. Run PMD with the `vbhtml` format:\n\n```bash\npmd check -R category/java/errorprone.xml -f vbhtml -d Exploit.java -r report.html\n```\n\n3. Open `report.html` in a browser. A JavaScript alert executes showing `document.domain`.\n\nThe generated HTML contains the unescaped tag:\n\n```html\n<td><font class=body>The String literal \"<img src=x onerror=alert(document.domain)>\" appears 4 times in this file</font></td>\n```\n\nTested and confirmed on PMD 7.22.0-SNAPSHOT (commit bcc646c53d).\n\n### Impact\nStored 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.\n\nPractical 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.\n\n### Fixes\n* See [#6475](https://github.com/pmd/pmd/issues/6475): \\[core] Fix stored XSS in VBHTMLRenderer and YAHTMLRenderer",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "net.sourceforge.pmd:pmd-core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.22.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 7.21.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pmd/pmd/security/advisories/GHSA-8rr6-2qw5-pc7r"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-28338"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pmd/pmd/pull/6475"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pmd/pmd/commit/c140c0e1de5853a08efb84c9f91dfeb015882442"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pmd/pmd"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-02-28T02:49:29Z",
    "nvd_published_at" : "2026-02-27T21:16:19Z"
  }
}