The analysis of the security advisory and the associated commit c140c0e1de5853a08efb84c9f91dfeb015882442 reveals a stored cross-site scripting (XSS) vulnerability in multiple PMD report renderers. The root cause is the failure to properly escape user-controllable content before embedding it into the generated HTML reports.
The investigation of the patch identified three key vulnerable functions:
net.sourceforge.pmd.renderers.VBHTMLRenderer.renderFileViolations: This function was found to be appending raw rule violation descriptions directly into the HTML for the vbhtml report format.
net.sourceforge.pmd.renderers.YAHTMLRenderer.renderViolationRow: Similarly, this function was used to build table rows in the yahtml report and directly included the violation description without escaping.
net.sourceforge.pmd.renderers.HTMLRenderer.glomSuppressions: Even the default html renderer was vulnerable, but in a different context. It failed to escape the user-provided message associated with a suppressed violation.
In all cases, the fix involved introducing and applying an escape method, which utilizes StringEscapeUtils.escapeHtml4, to sanitize the data before it is written to the HTML output. An attacker could exploit this by crafting malicious code (e.g., a Java string literal) that, when processed by PMD, would result in a report containing executable JavaScript.