PMD Designer has Stored XSS in VBHTMLRenderer and YAHTMLRenderer via unescaped violation messages
CVE-2026-28338 · GHSA-8rr6-2qw5-pc7r
- Affected
- Maven net.sourceforge.pmd:pmd-core <= 7.21.0
- Fixed in
- 7.22.0· Vendor fix available
- Issue
- 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: YAHTMLRenderer.java lines 196–203 does the same via renderViolationRow(): Called at line 172: 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…
Recommended action: Upgrade to 7.22.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.