The vulnerability is a cross-site scripting (XSS) issue in billboard.js caused by improper input sanitization. The root cause was a weak sanitize function in src/module/util.ts. This function used a simple blacklist approach that was easily bypassed with encoded characters, nested tags, and other obfuscation techniques.
The vulnerability could be triggered by passing malicious strings in various chart configuration options. The provided patch highlights the point_pattern option as a key attack vector. The functions getGeneratePoint (in src/ChartInternal/shape/point.common.ts) and updateLegend (in src/ChartInternal/internals/legend.ts) directly used this user-controllable option to generate SVG and HTML for the chart, trusting the weak sanitize function to prevent XSS.
The fix was two-fold:
- The
sanitize function was completely rewritten to be much more robust. It now handles encoded payloads, control characters, and various attack patterns by decoding the input before applying filters in a loop.
- The functions that consume potentially malicious options, like
getGeneratePoint and updateLegend, were modified to use a new getValidPointPattern helper function. This adds a layer of defense by validating the point_pattern before it is used, rather than relying solely on the global sanitize function.