NodeJS/highlight.js/1.0.1


Syntax highlighting with language autodetection.

https://www.npmjs.com/package/highlight.js
BSD-3-Clause

1 Security Vulnerabilities

Prototype Pollution in highlight.js

Published date: 2020-11-24T22:58:41Z
CVE: CVE-2020-26237
Links:

Impact

Affected versions of this package are vulnerable to Prototype Pollution. A malicious HTML code block can be crafted that will result in prototype pollution of the base object's prototype during highlighting. If you allow users to insert custom HTML code blocks into your page/app via parsing Markdown code blocks (or similar) and do not filter the language names the user can provide you may be vulnerable.

The pollution should just be harmless data but this can cause problems for applications not expecting these properties to exist and can result in strange behavior or application crashes, i.e. a potential DOS vector.

If your website or application does not render user provided data it should be unaffected.

Patches

Versions 9.18.2 and 10.1.2 and newer include fixes for this vulnerability. If you are using version 7 or 8 you are encouraged to upgrade to a newer release.

Workarounds

Patch your library

Manually patch your library to create null objects for both languages and aliases:

const HLJS = function(hljs) {
  // ...
  var languages = Object.create(null);
  var aliases = Object.create(null);

Filter out bad data from end users:

Filter the language names that users are allowed to inject into your HTML to guarantee they are valid.

References

For more information

If you have any questions or comments about this advisory:

Affected versions: ["10.0.0", "10.0.1", "10.0.2", "10.0.3", "10.1.0", "10.1.1", "1.0.0", "1.0.1", "1.0.2", "1.0.3", "1.0.4", "1.1.0", "1.1.1", "1.2.0", "7.0.1", "7.1.0", "7.2.0", "7.3.0", "7.4.0", "7.5.0", "8.0.0", "8.1.0", "8.2.0", "8.3.0", "8.4.0", "8.5.0", "8.6.0", "8.7.0", "8.8.0", "8.9.0", "8.9.1", "9.0.0", "9.1.0", "9.2.0", "9.3.0", "9.4.0", "9.5.0", "9.6.0", "9.7.0", "9.8.0", "9.9.0", "9.10.0", "9.11.0", "9.12.0", "9.13.0", "9.13.1", "9.14.1", "9.14.2", "9.15.1", "9.15.2", "9.15.5", "9.15.6", "9.15.7", "9.15.8", "9.15.9", "9.15.10", "9.16.1", "9.16.2", "9.17.0", "9.17.1", "9.18.0", "9.18.1"]
Secure versions: [10.4.1, 10.5.0, 10.6.0, 10.7.0, 10.7.1, 10.7.2, 11.0.0-alpha0, 11.0.0-alpha1, 11.0.0-beta0, 11.0.0-beta1, 11.0.0, 10.7.3, 11.0.1, 11.1.0, 11.2.0, 11.3.0, 11.3.1, 11.4.0, 11.5.0, 11.5.1, 11.6.0, 11.7.0, 11.8.0, 11.9.0]
Recommendation: Update to version 11.9.0.

100 Other Versions

Version License Security Released
11.9.0 BSD-3-Clause 2023-10-09 - 03:53 7 months
11.8.0 BSD-3-Clause 2023-04-29 - 13:37 about 1 year
11.7.0 BSD-3-Clause 2022-11-23 - 22:09 over 1 year
11.6.0 BSD-3-Clause 2022-07-13 - 15:11 almost 2 years
11.5.1 BSD-3-Clause 2022-04-11 - 01:16 about 2 years
11.5.0 BSD-3-Clause 2022-03-12 - 00:35 about 2 years
11.4.0 BSD-3-Clause 2022-01-06 - 14:57 over 2 years
11.3.1 BSD-3-Clause 2021-10-17 - 20:19 over 2 years
11.3.0 BSD-3-Clause 2021-10-17 - 13:32 over 2 years
11.2.0 BSD-3-Clause 2021-08-02 - 01:43 over 2 years
11.1.0 BSD-3-Clause 2021-07-08 - 14:58 almost 3 years
11.0.1 BSD-3-Clause 2021-06-04 - 01:47 almost 3 years
11.0.0 BSD-3-Clause 2021-05-30 - 08:06 almost 3 years
11.0.0-beta1 BSD-3-Clause 2021-05-16 - 16:36 almost 3 years
11.0.0-beta0 BSD-3-Clause 2021-05-04 - 12:35 almost 3 years
11.0.0-alpha1 BSD-3-Clause 2021-04-22 - 16:58 about 3 years
11.0.0-alpha0 BSD-3-Clause 2021-04-13 - 11:46 about 3 years
10.7.3 BSD-3-Clause 2021-06-04 - 01:40 almost 3 years
10.7.2 BSD-3-Clause 2021-04-04 - 19:32 about 3 years
10.7.1 BSD-3-Clause 2021-03-21 - 08:22 about 3 years
10.7.0 BSD-3-Clause 2021-03-20 - 13:16 about 3 years
10.6.0 BSD-3-Clause 2021-02-08 - 13:25 about 3 years
10.5.0 BSD-3-Clause 2020-12-23 - 20:40 over 3 years
10.4.1 BSD-3-Clause 2020-12-03 - 17:22 over 3 years
10.4.0 BSD-3-Clause 1 2020-11-18 - 19:11 over 3 years
10.4.0-beta1 BSD-3-Clause 1 2020-11-15 - 04:18 over 3 years
10.4.0-beta0 BSD-3-Clause 1 2020-11-13 - 20:31 over 3 years
10.3.2 BSD-3-Clause 1 2020-10-29 - 13:08 over 3 years
10.3.1 BSD-3-Clause 1 2020-10-17 - 23:37 over 3 years
10.3.0 BSD-3-Clause 1 2020-10-17 - 17:32 over 3 years
10.2.1 BSD-3-Clause 1 2020-10-01 - 14:37 over 3 years
10.2.0 BSD-3-Clause 1 2020-09-07 - 20:21 over 3 years
10.1.2 BSD-3-Clause 1 2020-07-23 - 21:06 almost 4 years
10.1.1 BSD-3-Clause 2 2020-06-16 - 16:23 almost 4 years
10.1.0 BSD-3-Clause 2 2020-06-11 - 23:28 almost 4 years
10.0.3 BSD-3-Clause 2 2020-05-12 - 01:02 almost 4 years
10.0.2 BSD-3-Clause 2 2020-05-03 - 18:14 almost 4 years
10.0.1 BSD-3-Clause 2 2020-04-26 - 22:39 about 4 years
10.0.0 BSD-3-Clause 2 2020-04-21 - 22:54 about 4 years
10.0.0-beta.0 BSD-3-Clause 1 2020-03-10 - 02:02 about 4 years
9.18.5 BSD-3-Clause 1 2020-11-19 - 17:45 over 3 years
9.18.4 BSD-3-Clause 1 2020-11-18 - 20:13 over 3 years
9.18.3 BSD-3-Clause 1 2020-07-29 - 00:31 almost 4 years
9.18.2 BSD-3-Clause 1 2020-07-28 - 14:47 almost 4 years
9.18.1 BSD-3-Clause 2 2020-02-01 - 17:45 about 4 years
9.18.0 BSD-3-Clause 2 2020-01-20 - 14:01 over 4 years
9.17.1 BSD-3-Clause 2 2019-12-12 - 14:11 over 4 years
9.17.0 BSD-3-Clause 2 2019-12-11 - 01:58 over 4 years
9.16.2 BSD-3-Clause 2 2019-11-01 - 14:37 over 4 years
9.16.1 BSD-3-Clause 2 2019-10-31 - 15:35 over 4 years
9.15.10 BSD-3-Clause 2 2019-08-20 - 03:21 over 4 years
9.15.9 BSD-3-Clause 2 2019-07-31 - 02:51 almost 5 years
9.15.8 BSD-3-Clause 2 2019-05-29 - 07:33 almost 5 years
9.15.7 BSD-3-Clause 2 2019-05-29 - 03:37 almost 5 years
9.15.6 BSD-3-Clause 2 2019-02-26 - 21:56 about 5 years
9.15.5 BSD-3-Clause 2 2019-02-25 - 23:22 about 5 years
9.15.2 BSD-3-Clause 2 2019-02-25 - 09:20 about 5 years
9.15.1 BSD-3-Clause 2 2019-02-25 - 05:35 about 5 years
9.14.2 BSD-3-Clause 2 2019-02-01 - 04:27 about 5 years
9.14.1 BSD-3-Clause 2 2019-01-30 - 07:43 over 5 years
9.13.1 BSD-3-Clause 2 2018-10-17 - 02:30 over 5 years
9.13.0 BSD-3-Clause 2 2018-10-13 - 03:08 over 5 years
9.12.0 BSD-3-Clause 2 2017-05-31 - 02:47 almost 7 years
9.11.0 BSD-3-Clause 2 2017-04-19 - 07:20 about 7 years
9.10.0 BSD-3-Clause 2 2017-03-08 - 07:36 about 7 years
9.9.0 BSD-3-Clause 2 2016-12-14 - 07:12 over 7 years
9.8.0 BSD-3-Clause 2 2016-11-02 - 05:54 over 7 years
9.7.0 BSD-3-Clause 2 2016-09-21 - 05:44 over 7 years
9.6.0 BSD-3-Clause 2 2016-08-10 - 05:14 over 7 years
9.5.0 BSD-3-Clause 2 2016-06-28 - 21:46 almost 8 years
9.4.0 BSD-3-Clause 2 2016-05-17 - 19:16 almost 8 years
9.3.0 BSD-3-Clause 2 2016-04-05 - 19:11 about 8 years
9.2.0 BSD-3-Clause 2 2016-02-23 - 22:36 about 8 years
9.1.0 BSD-3-Clause 2 2016-01-06 - 15:00 over 8 years
9.0.0 BSD-3-Clause 2 2015-12-02 - 03:13 over 8 years
8.9.1 BSD-3-Clause 1 2015-10-19 - 22:55 over 8 years
8.9.0 BSD-3-Clause 1 2015-10-19 - 22:21 over 8 years
8.8.0 BSD-3-Clause 1 2015-09-06 - 15:25 over 8 years
8.7.0 BSD-3-Clause 1 2015-07-28 - 21:29 almost 9 years
8.6.0 BSD-3-Clause 1 2015-05-20 - 07:25 almost 9 years
8.5.0 BSD 1 2015-04-03 - 05:50 about 9 years
8.4.0 BSD 1 2014-11-18 - 19:38 over 9 years
8.3.0 BSD 1 2014-10-09 - 20:21 over 9 years
8.2.0 BSD 1 2014-08-20 - 21:56 over 9 years
8.1.0 BSD 1 2014-07-08 - 21:21 almost 10 years
8.0.0 BSD 1 2014-01-09 - 00:30 over 10 years
7.5.0 BSD 1 2013-11-20 - 07:54 over 10 years
7.4.0 BSD 1 2013-10-30 - 22:14 over 10 years
7.3.0 BSD 1 2012-10-13 - 04:11 over 11 years
7.2.0 BSD 1 2012-08-28 - 01:19 over 11 years
7.1.0 BSD 1 2012-08-11 - 22:01 over 11 years
7.0.1 BSD 1 2012-06-04 - 20:16 almost 12 years
1.2.0 BSD-3-Clause 1 2012-04-24 - 15:41 about 12 years
1.1.1 BSD-3-Clause 1 2012-02-26 - 00:39 about 12 years
1.1.0 BSD-3-Clause 1 2012-01-30 - 20:23 about 12 years
1.0.4 BSD-3-Clause 1 2012-01-26 - 19:38 over 12 years
1.0.3 BSD-3-Clause 1 2012-01-26 - 15:55 over 12 years
1.0.2 BSD-3-Clause 1 2011-09-24 - 20:22 over 12 years
1.0.1 BSD-3-Clause 1 2011-09-18 - 20:33 over 12 years
1.0.0 BSD-3-Clause 1 2011-07-15 - 00:49 almost 13 years