{"id":"CVE-2026-28338","aliases":["CVE-2026-28338","GHSA-8rr6-2qw5-pc7r"],"related":[],"kind":"vulnerability","state":"published","title":"PMD Designer has Stored XSS in VBHTMLRenderer and YAHTMLRenderer via unescaped violation messages","summary":"PMD is an extensible multilanguage static code analyzer. Prior to version 7.22.0, 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. Practical impact is limited because `vbhtml` and `yahtml` are legacy formats rarely used in practice. The default `html` format is properly escaped and not affected. Version 7.22.0 contains a fix for the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"PMD is an extensible multilanguage static code analyzer. Prior to version 7.22.0, 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. Practical impact is limited because `vbhtml` and `yahtml` are legacy formats rarely used in practice. The default `html` format is properly escaped and not affected. Version 7.22.0 contains a fix for the issue.","source":"cvelist"},{"lang":"en","text":"### 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","format":"markdown","source":"ghsa"},{"lang":"es","text":"PMD es un analizador de código estático multilenguaje extensible. Antes de la versión 7.22.0, los formatos de informe 'vbhtml' y 'yahtml' de PMD insertan mensajes de violación de reglas en la salida HTML sin escapar. Cuando PMD analiza código fuente no confiable que contiene literales de cadena manipulados, el informe HTML generado contiene JavaScript ejecutable que se ejecuta al abrirse en un navegador. El impacto práctico es limitado porque 'vbhtml' y 'yahtml' son formatos heredados rara vez utilizados en la práctica. El formato 'html' predeterminado está correctamente escapado y no se ve afectado. La versión 7.22.0 contiene una solución para el problema.","source":"nvd"}],"published":"2026-02-27T20:28:05.739Z","modified":"2026-06-17T10:28:27.310Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N","score":6.8,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N","score":6.8,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N","score":6.8,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"< 7.22.0","status":"affected"}],"vendor":"pmd","product":"pmd","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"7.22.0"}],"ecosystem":"Maven","package":"net.sourceforge.pmd:pmd-core","purl":"pkg:maven/net.sourceforge.pmd/pmd-core","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"7.22.0"}],"vendor":"pmd_project","product":"pmd","cpe":"cpe:2.3:a:pmd_project:pmd:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/pmd/pmd/security/advisories/GHSA-8rr6-2qw5-pc7r","tags":["exploit","patch","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/pmd/pmd/pull/6475","tags":["issue-tracking","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/pmd/pmd/commit/c140c0e1de5853a08efb84c9f91dfeb015882442","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-28338","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/pmd/pmd","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-03-03T20:25:54.223Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-28338","url":"https://www.cve.org/CVERecord?id=CVE-2026-28338","licence":"CVE Terms of Use","modified":"2026-03-03T20:26:01.369Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-8rr6-2qw5-pc7r","url":"https://github.com/advisories/GHSA-8rr6-2qw5-pc7r","licence":"CC-BY-4.0","modified":"2026-02-28T06:56:20.134Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-28338","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-28338","licence":"Public domain","modified":"2026-06-17T10:28:27.310Z"}],"updatedAt":"2026-11-25T22:59:15.045Z","epss":{"score":0.00341,"percentile":0.29552,"date":"2026-12-01T12:00:22.000Z"}}