Update dependency highlight.js to v10 [SECURITY]
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| highlight.js (source) | ^9.18.1 -> ^10.0.0 |
Test plan: CI should pass with updated dependencies. No review required: this is an automated dependency update PR.
GitHub Vulnerability Alerts
CVE-2020-26237
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
- What is Prototype Pollution?
- https://github.com/highlightjs/highlight.js/pull/2636
For more information
If you have any questions or comments about this advisory:
- Please file an issue against highlight.js
GHSA-7wwv-vh3v-89cq
Impact: Potential ReDOS vulnerabilities (exponential and polynomial RegEx backtracking)
The Regular expression Denial of Service (ReDoS) is a Denial of Service attack, that exploits the fact that most Regular Expression implementations may reach extreme situations that cause them to work very slowly (exponentially related to input size). An attacker can then cause a program using a Regular Expression to enter these extreme situations and then hang for a very long time.
If are you are using Highlight.js to highlight user-provided data you are possibly vulnerable. On the client-side (in a browser or Electron environment) risks could include lengthy freezes or crashes... On the server-side infinite freezes could occur... effectively preventing users from accessing your app or service (ie, Denial of Service).
This is an issue with grammars shipped with the parser (and potentially 3rd party grammars also), not the parser itself. If you are using Highlight.js with any of the following grammars you are vulnerable. If you are using highlightAuto to detect the language (and have any of these grammars registered) you are vulnerable. Exponential grammars (C, Perl, JavaScript) are auto-registered when using the common grammar subset/library require('highlight.js/lib/common') as of 10.4.0 - see https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.js
All versions prior to 10.4.1 are vulnerable, including version 9.18.5.
Grammars with exponential backtracking issues:
- c-like (c, cpp, arduino)
- handlebars (htmlbars)
- gams
- perl
- jboss-cli
- r
- erlang-repl
- powershell
- routeros
- livescript (10.4.0 and 9.18.5 included this fix)
- javascript & typescript (10.4.0 included partial fixes)
And of course any aliases of those languages have the same issue. ie: hpp is no safer than cpp.
Grammars with polynomial backtracking issues:
- kotlin
- gcode
- d
- aspectj
- moonscript
- coffeescript/livescript
- csharp
- scilab
- crystal
- elixir
- basic
- ebnf
- ruby
- fortran/irpf90
- livecodeserver
- yaml
- x86asm
- dsconfig
- markdown
- ruleslanguage
- xquery
- sqf
And again: any aliases of those languages have the same issue. ie: ruby and rb share the same ruby issues.
Patches
- Version 10.4.1 resolves these vulnerabilities. Please upgrade.
Workarounds / Mitigations
- Discontinue use the affected grammars. (or perhaps use only those with poly vs exponential issues)
- Attempt cherry-picking the grammar fixes into older versions...
- Attempt using newer CDN versions of any affected languages. (ie using an older CDN version of the library with newer CDN grammars). Your mileage may vary.
References
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
For more information
If you have any questions or comments about this advisory:
- Open an issue: https://github.com/highlightjs/highlight.js/issues
- Email us at [email protected]
Release Notes
highlightjs/highlight.js
v10.4.1
Security
- (fix) Exponential backtracking fixes for: Josh Goebel
- cpp
- handlebars
- gams
- perl
- jboss-cli
- r
- erlang-repl
- powershell
- routeros
- (fix) Polynomial backtracking fixes for: Josh Goebel
- asciidoc
- reasonml
- latex
- kotlin
- gcode
- d
- aspectj
- moonscript
- coffeescript/livescript
- csharp
- scilab
- crystal
- elixir
- basic
- ebnf
- ruby
- fortran/irpf90
- livecodeserver
- yaml
- x86asm
- dsconfig
- markdown
- ruleslanguage
- xquery
- sqf
Very grateful to Michael Schmidt for all the help.
v10.4.0
A largish release with many improvements and fixes from quite a few different contributors. Enjoy!
Deprecations:
- (chore)
requireLanguageis deprecated.- Prefer
getLanguage(with custom error handling) or built-time dependencies. - See Library API for more information.
- Prefer
Parser:
- enh(parser) use negative look-ahead for
beginKeywordssupport (#2813) Josh Goebel - enh(grammars) allow
classNameAliasesfor more complex grammars Josh Goebel - fix(vue): Language name now appears in CSS class (#2807) Michael Rush
- (chore) Clean up all regexs to be UTF-8 compliant/ready (#2759) Josh Goebel
- enh(grammars) allow
classNameAliasesfor more complex grammars Josh Goebel
New Languages:
- Added 3rd party Chapel grammar to SUPPORTED_LANGUAGES (#2806) Brad Chamberlain
- Added BBCode grammar to SUPPORTED_LANGUAGES (#2867) Paul Reid
- enh(javascript) Added
node-replfor Node.js REPL sessions (#2792) Marat Nagayev
Language Improvements:
- enh(shell) Recognize prompts which contain tilde
~(#2859) Guillaume Grossetie - enh(shell) Add support for multiline commands with line continuation
\(#2861) Guillaume Grossetie - enh(autodetect) Over 30+ improvements to auto-detect (#2745) Josh Goebel
- 4-5% improvement in auto-detect against large sample set
- properties, angelscript, lsl, javascript, n1ql, ocaml, ruby
- protobuf, hy, scheme, crystal, yaml, r, vbscript, groovy
- python, java, php, lisp, matlab, clojure, csharp, css
- fix(r) fixed keywords not properly spaced (#2852) Josh Goebel
- fix(javascript) fix potential catastrophic backtracking (#2852) Josh Goebel
- fix(livescript) fix potential catastrophic backtracking (#2852) Josh Goebel
- bug(xml) XML grammar was far too imprecise/fuzzy Josh Goebel
- enh(xml) Improve precision to prevent false auto-detect positives Josh Goebel
- fix(js/ts) Prevent for/while/if/switch from falsly matching as functions (#2803) Josh Goebel
- enh(julia) Update keyword lists for Julia 1.x (#2781) Fredrik Ekre
- enh(python) Match numeric literals per the language reference Richard Gibson
- enh(ruby) Match numeric literals per language documentation Richard Gibson
- enh(javascript) Match numeric literals per ECMA-262 spec Richard Gibson
- enh(java) Match numeric literals per Java Language Specification Richard Gibson
- enh(swift) Match numeric literals per language reference Richard Gibson
- enh(php) highlight variables (#2785) Taufik Nurrohman
- fix(python) Handle comments on decorators (#2804) Jonathan Sharpe
- enh(diff) improve highlighting of diff for git patches [Florian Bezdeka][]
- fix(llvm) lots of small improvements and fixes (#2830) Josh Goebel
- enh(mathematica) Rework entire implementation Patrick Scheibe
- Correct matching of the many variations of Mathematica's numbers
- Matching of named-characters aka special symbols like
\[Gamma] - Updated list of version 12.1 built-in symbols
- Matching of patterns, slots, message-names and braces
- fix(swift) Handle keywords that start with
#Marcus Ortiz - enh(swift) Match
somekeyword Marcus Ortiz - enh(swift) Match
@mainattribute Marcus Ortiz
Dev Improvements:
- chore(dev) add theme picker to the tools/developer tool (#2770) Josh Goebel
- fix(dev) the Vue.js plugin no longer throws an exception when hljs is not in the global namespace Kyle Brown
New themes:
- StackOverflow Dark by Jan Pilzer
- StackOverflow Light by Jan Pilzer
v10.3.2
Tiny tiny release, just to fix the website incorrectly not listing Javascript in the list of languages you could choose for a custom build. NPM and CDN build should not have been affected so 10.3.1 is effectively the same as 10.3.2 for those builds.
If you made a custom build from the website with 10.3 or 10.3.1 you may want to check and make sure it includes Javascript, and if not, build it again.
v10.3.1
Prior version let some look-behind regex sneak in, which does not work yet on Safari. This release removes those incompatible regexes.
Fix:
- fix(Safari) Remove currently unsupported look-behind regex (fix) Josh Goebel
v10.3.0
Language Improvements:
- enh(latex) Complete ground up rewrite of LaTex grammar schtandard
- fix(cpp) implement backslash line continuation in comments (#2757) Konrad Rudolph
- fix(cpp) improve parsing issues with templates (#2752) [Josh Goebel][]
- enh(cpp) add support for
enum (struct|class)andunion(#2752) [Josh Goebel][] - fix(js/ts) Fix nesting of
{}inside template literals SUBST expression (#2748) [Josh Goebel][] - enh(js/ts) Highlight class methods as functions (#2727) [Josh Goebel][]
- fix(js/ts)
constructoris now highlighted as a function title (not keyword) (#2727) [Josh Goebel][] - fix(c-like) preprocessor directives not detected after else (#2738) [Josh Goebel][]
- enh(javascript) allow
#for private class fields (#2701) Chris Krycho - fix(js) prevent runaway regex (#2746) [Josh Goebel][]
- fix(bash) enh(bash) allow nested params (#2731) [Josh Goebel][]
- fix(python) Fix highlighting of keywords and strings (#2713, #2715) Konrad Rudolph
- fix(fsharp) Prevent
(*)from being detected as a multi-line comment [Josh Goebel][] - enh(bash) add support for heredocs (#2684) [Josh Goebel][]
- enh(r) major overhaul of the R language grammar (and fix a few bugs) (#2680) Konrad Rudolph
- enh(csharp) Add all C# 9 keywords, and other missing keywords (#2679) David Pine
- enh(objectivec) Add
objective-c++andobj-c++aliases for Objective-C [Josh Goebel][] - enh(java) Add support for
record(#2685) [Josh Goebel][] - fix(csharp) prevent modifier keywords wrongly flagged as
title(#2683) [Josh Goebel][] - enh(axapta) Update keyword list for Axapta (X++) (#2686) Ryan Jonasson
- fix(fortran) FORTRAN 77-style comments (#2677) Philipp Engel
- fix(javascript) Comments inside params should be highlighted (#2702) [Josh Goebel][]
- fix(scala) Comments inside class header should be highlighted (#1559) [Josh Goebel][]
- fix(c-like) Correctly highlight modifiers (
final) in class declaration (#2696) [Josh Goebel][] - enh(angelscript) Improve heredocs, numbers, metadata blocks (#2724) Melissa Geels
- enh(javascript) Implement Numeric Separators (#2617) Antoine du Hamel
- enh(typescript) TypeScript also gains support for numeric separators (#2617) Antoine du Hamel
- enh(php) Add support for PHP 8
matchkeyword and addphp8as an alias (#2733) Ayesh Karunaratne - fix(handlebars) Support if else keyboards (#2659) Tom Wallace
Deprecations:
-
useBRoption deprecated and will be removed in v11.0. (#2559) [Josh Goebel][]
v10.2.1
Parser Engine:
- fix(parser) complete fix for resuming matches from same index (#2678) Josh Goebel
v10.2.0
Parser Engine:
- (fix) When ignoring a potential match highlighting can terminate early (#2649) Josh Goebel
New themes:
- Gradient Light by Samia Ali
Deprecations:
-
fixMarkupis now deprecated and will be removed in v11.0. (#2534) Josh Goebel
Big picture:
- Add simple Vue plugin for basic use cases (#2544) Josh Goebel
Language Improvements:
- fix(bash) Fewer false positives for keywords in arguments (#2669) sirosen
- fix(js) Prevent long series of /////// from causing freezes (#2656) Josh Goebel
- enh(csharp) Add
initandrecordkeywords for C# 9.0 (#2660) Youssef Victor - enh(matlab) Add new R2019b
argumentskeyword and fixenumerationkeyword (#2619) Andrew Janke - fix(kotlin) Remove very old keywords and update example code (#2623) kageru
- fix(night) Prevent object prototypes method values from being returned in
getLanguage(#2636) night - enh(java) Add support for
enum, which will identify as aclassnow (#2643) ezksd - enh(nsis) Add support for NSIS 3.06 commands (#2653) idleberg
- enh(php) detect newer more flexible HEREdoc syntax (#2658) eytienne
v10.1.2
Fixes:
v10.1.1
Fixes:
- Resolve issue on Node 6 due to dangling comma (#2608) Edwin Hoogerbeets
- Resolve
index.d.ts is not a moduleerror (#2603) Josh Goebel
v10.1.0
New themes:
Parser Engine:
- (parser) Now escapes quotes in text content when escaping HTML (#2564) Josh Goebel
- (parser) Adds
keywords.$patternkey to grammar definitions (#2519) Josh Goebel - (parser) Adds SHEBANG utility mode Josh Goebel
- (parser) Adds
registerAliasesmethod (#2540) [Taufik Nurrohman][] - (enh) Added
on:begincallback for modes (#2261) Josh Goebel - (enh) Added
on:endcallback for modes (#2261) Josh Goebel - (enh) Added ability to programatically ignore begin and end matches (#2261) Josh Goebel
- (enh) Added
END_SAME_AS_BEGINmode to replaceendSameAsBeginparser attribute (#2261) Josh Goebel - (fix)
fixMarkupwould rarely destroy markup whenuseBRwas enabled (#2532) Josh Goebel
Deprecations:
-
htmlbarsgrammar is now deprecated. Usehandlebarsinstead. (#2344) Nils Knappmeier - when using
highlightBlockresult.redeprecated. Useresult.relevanceinstead. (#2552) Josh Goebel - ditto for
result.second_best.re=>result.second_best.relevance(#2552) -
lexemesis now deprecated in favor ofkeywords.$patternkey (#2519) Josh Goebel -
endSameAsBeginis now deprecated. (#2261) Josh Goebel
Language Improvements:
- fix(groovy) strings are not allowed inside ternary clauses (#2217) Josh Goebel
- fix(typescript) add
readonlykeyword (#2562) Martin (Lhoerion) - fix(javascript) fix regex inside parens after a non-regex (#2530) Josh Goebel
- enh(typescript) use identifier to match potential keywords, preventing false positivites (#2519) Josh Goebel
- enh(javascript) use identifier to match potential keywords, preventing false positivites (#2519) Josh Goebel
- [enh] Add
OPTIMIZE:andHACK:to the labels highlighted inside comments Josh Goebel - enh(typescript/javascript/coffeescript/livescript) derive ECMAscript keywords from a common foudation (#2518) Josh Goebel
- enh(typescript) add setInterval, setTimeout, clearInterval, clearTimeout (#2514) Josh Goebel
- enh(javascript) add setInterval, setTimeout, clearInterval, clearTimeout (#2514) Vania Kucher
- enh(cpp) add
pair,make_pair,priority_queueas built-ins (#2538) Hankun Lin - enh(cpp) recognize
priority_queuepairas cpp containers (#2541) Hankun Lin - fix(javascript) prevent
setkeyword conflicting with setTimeout, etc. (#2514) Vania Kucher - fix(cpp) Fix highlighting of unterminated raw strings (#2261) David Benjamin
- fix(javascript)
=>function with nested()in params now works (#2502) Josh Goebel - fix(typescript)
=>function with nested()in params now works (#2502) Josh Goebel - fix(yaml) Fix tags to include non-word characters (#2486) Peter Plantinga
- fix(swift)
@objcMemberswas being partially highlighted (#2543) Nick Randall - enh(dart) Add
lateandrequiredkeywords, theNeverbuilt-in type, and nullable built-in types (#2550) Sam Rawlins - enh(erlang) Add underscore separators to numeric literals (#2554) Sergey Prokhorov
- enh(handlebars) Support for sub-expressions, path-expressions, hashes, block-parameters and literals (#2344) Nils Knappmeier
- enh(protobuf) Support multiline comments (#2597) Pavel Evstigneev
- fix(toml) Improve key parsing (#2595) Antoine du Hamel
v10.0.3
v10.0.2
Brower build:
- Issue (bug) Fix: Version 10 fails to load as CommonJS module. (#2511) Josh Goebel
- Issue (removal) AMD module loading support has been removed. (#2511) Josh Goebel
Parser Engine Changes:
- Issue fix(parser) Fix freez issue with illegal 0 width matches (#2524) Josh Goebel
v10.0.1
Parser Engine Changes:
- (bug) Fix sublanguage with no relevance score (#2506) Josh Goebel
v10.0.0
New languages:
- add(php-template) Explicit language to detect PHP templates (vs xml) Josh Goebel
- enh(python) Added
python-replfor Python REPL sessions - add(never) Added 3rd party Never language support
New themes:
- Srcery by Chen Bin
Parser Engine Changes:
- (bug) Fix
beginKeywordsto ignore . matches (#2434) Josh Goebel - (enh) add
before:highlightplugin API callback (#2395) Josh Goebel - (enh) add
after:highlightplugin API callback (#2395) Josh Goebel - (enh) split out parse tree generation and HTML rendering concerns (#2404) Josh Goebel
- (enh) every language can have a
nameattribute now (#2400) Josh Goebel - (enh) improve regular expression detect (less false-positives) (#2380) Josh Goebel
- (enh) make
noHighlightReandlanguagePrefixReconfigurable (#2374) Josh Goebel
Language Improvements:
- enh(python) Exclude parens from functions params (#2490) Álvaro Mondéjar
- enh(swift) Add
compactMapto keywords as built_in (#2478) Omid Golparvar - enh(nim) adds
funckeyword (#2468) Adnan Yaqoob - enh(xml) deprecate ActionScript inside script tags (#2444) Josh Goebel
- fix(javascript) prevent get/set variables conflicting with keywords (#2440) Josh Goebel
- bug(clojure) Now highlights
defn-properly (#2438) Josh Goebel - enh(bash) default value is another variable (#2439) Josh Goebel
- enh(bash) string nested within string (#2439) Josh Goebel
- enh(bash) Add arithmetic expression support (#2439) Josh Goebel
- enh(clojure) Add support for global definitions name (#2347) Alexandre Grison
- enh(fortran) Support Fortran 77 style comments (#2416) Josh Goebel
- (csharp) add support for
@identifierstyle identifiers (#2414) Josh Goebel - fix(elixir) Support function names with a slash (#2406) Josh Goebel
- fix(javascript) comma is allowed in a "value container" (#2403) Josh Goebel
- enh(apache) add
denyandallowkeywords Josh Goebel - enh(apache) highlight numeric attributes values Josh Goebel
- enh(apache) highlight IP addresses, ports, and strings in sections Josh Goebel
- enh(php) added more keywords and include
<?=syntax to meta Taufik Nurrohman - fix(protobuf) Fix
rpcwhen followed by a block (#) Josh Goebel - enh(zephir) almost complete rework of the zephir grammar (#2387) Josh Goebel
- (markdown) much improved code block support (#2382) Josh Goebel
- (markdown) improve bold/italic nesting (#2382) Josh Goebel
- enh(csharp) Support
wherekeyword as class constraint (#2378) Josh Goebel - enh(csharp) Allow reference path in class inheritance lists (#2378) Josh Goebel
- enh(csharp) Add generic modifiers (in, out) (#2378) Josh Goebel
- (fortran) enh(fortran) support intrinsic data types (#2379) Josh Goebel
- enh(java) annotations can include numbers (#2377) Josh Goebel
- enh(java) annotations can take params (#2377) Josh Goebel
- enh(java) allow annotations inside function call params (#2377) Josh Goebel
- enh(parser) pre/post-highlightBlock callbacks via plugin (#2285) Josh Goebel
- (fortran) Add Fortran 2018 keywords and coarray intrinsics (#2361) Sam Miller
- (delphi) highlight hexadecimal, octal, and binary numbers (#2370) Robert Riebisch
- enh(plaintext) added
textandtxtas alias (#2360) Taufik Nurrohman - enh(powershell) added PowerShell v5.1/v7 default aliases as "built_in"s (#2423) Sean Williams
- enh(yaml) added support for timestamps (#2475) [Peter Plantinga][]
Developer Tools:
- added Dockerfile for optionally developing with a container
Configuration
📅 Schedule: Branch creation - "" in timezone America/Los_Angeles, Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
- [ ] If you want to rebase/retry this PR, click this checkbox.
This PR has been generated by Mend Renovate. View repository job log here.