Skip to content

Commit

Permalink
Fix a possible ReDoS
Browse files Browse the repository at this point in the history
  • Loading branch information
cronvel committed Oct 12, 2021
1 parent 6e529a5 commit a2e446c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

v2.1.8
------

Fix a possible ReDoS


v2.1.7
------

Expand Down
10 changes: 10 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

## Reporting a Vulnerability

If you think you have found a vulnerability, _please report responsibly_.
Don't create GitHub issues for security issues.
Instead, send an email to cedric dot ronvel at gmail dot com and I will look into it as soon as possible.

**A note for bounty hunters:** I should mention that I *usually* prefer to fix security issues by myself,
because it could involve rethinking API or fixing it / working around it in a way only an official maintainer can do it.
I want to avoid people getting frustrated: **don't work on a fix before getting in touch with me**.
6 changes: 4 additions & 2 deletions browser/termkit.js
Original file line number Diff line number Diff line change
Expand Up @@ -19123,9 +19123,11 @@ misc.truncateString = ( str , maxWidth ) => {



// width of a string with a markup, without control chars
// Width of a string with a markup, without control chars
misc.markupWidth = str => {
return string.unicode.width( str.replace( /\^\[[^\]]*]|\^(.)/g , ( match , second ) => {
// Fix a possible ReDoS, the regex: /\^\[[^\]]*]|\^(.)/g was replaced by: /\^\[[^^[\]]*]|\^(.)/g
// The exploit was possible with a string like: '^['.repeat(bigNumber)
return string.unicode.width( str.replace( /\^\[[^^[\]]*]|\^(.)/g , ( match , second ) => {
if ( second === ' ' || second === '^' ) {
return second ;
}
Expand Down
2 changes: 1 addition & 1 deletion browser/termkit.min.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions lib/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,11 @@ misc.truncateString = ( str , maxWidth ) => {



// width of a string with a markup, without control chars
// Width of a string with a markup, without control chars
misc.markupWidth = str => {
return string.unicode.width( str.replace( /\^\[[^\]]*]|\^(.)/g , ( match , second ) => {
// Fix a possible ReDoS, the regex: /\^\[[^\]]*]|\^(.)/g was replaced by: /\^\[[^^[\]]*]|\^(.)/g
// The exploit was possible with a string like: '^['.repeat(bigNumber)
return string.unicode.width( str.replace( /\^\[[^^[\]]*]|\^(.)/g , ( match , second ) => {
if ( second === ' ' || second === '^' ) {
return second ;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "terminal-kit",
"version": "2.1.7",
"version": "2.1.8",
"description": "256 colors, keys and mouse, input field, progress bars, screen buffer (including 32-bit composition and image loading), text buffer, and many more... Whether you just need colors and styles, build a simple interactive command line tool or a complexe terminal app: this is the absolute terminal lib for Node.js!",
"main": "lib/termkit.js",
"directories": {
Expand Down

0 comments on commit a2e446c

Please sign in to comment.