GHSA-5793-x2q3-c3q7
Highcharts: `javascript:` URL in credits.href runs script on click
Packages
| Ecosystem | Package | Affected | Fixed in |
|---|---|---|---|
| npm | highcharts | < 11.4.9 | 11.4.9 |
| npm | highcharts | >= 12.0.0, < 12.6.1 | 12.6.1 |
| npm | highcharts | >= 13.0.0, < 13.1.0 | 13.1.0 |
Details
As written in the advisory (Markdown source, shown as plain text).
### Impact
A `credits.href` value beginning with `javascript:` is assigned to the window location when the credits label is clicked, without being checked against an allowed-scheme list. An attacker who controls the chart configuration can therefore run script in the origin of the page hosting the chart. Exploitation requires that untrusted data reach the chart configuration and that a user click the credits label. Charts built with Highcharts Stock, Maps and Gantt are included, since those ship from the same package as Core.
### Workarounds
Drop-in fix - for any versions affected (5.0.0-13.0.2).
Add the below IIFE to run after Highcharts is loaded, but before a chart is created.
```js
!function(t){if(t&&t.Chart&&!t.Chart.prototype.creditsHrefPatched){var r=t.Chart.prototype,e=r.addCredits;r.addCredits=function(n){var o=t.merge(!0,this.options.credits,n);return o&&o.href&&!c(o.href)&&delete o.href,e.call(this,o)},r.creditsHrefPatched=!0}function c(r){var e=t.AST&&t.AST.allowedReferences||["https://","http://","mailto:","/","../","./","#"];return"string"==typeof r&&e.some(function(t){return 0===r.indexOf(t)})}}(Highcharts);
```
[Live demo & testing](https://jsfiddle.net/BlackLabel/6a09ws1f/)
### Obtaining the patched version
The patched releases are available from all the usual distribution channels. With npm, upgrade the affected package to the patched version listed above, for example `npm install highcharts@ 13.1.0`. If you load Highcharts from the CDN, use the versioned URLs on code.highcharts.com, for example `https://code.highcharts.com/13.1.0/highcharts.js`. For more on each installation method, see the [installation guide](https://www.highcharts.com/docs/getting-started/installation).
References
External links from the advisory. They lead to third-party sites.
- https://github.com/highcharts/highcharts/security/advisories/GHSA-5793-x2q3-c3q7
- https://github.com/highcharts/highcharts/pull/25315
- https://github.com/highcharts/highcharts/commit/9534773d0f41400aac0945bf8aaebc38dfc72aff
- https://github.com/highcharts/highcharts
- https://github.com/highcharts/highcharts/releases/tag/v13.1.0