Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a possible ReDoS
  • 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
@@ -1,4 +1,10 @@

v2.1.8
------

Fix a possible ReDoS


v2.1.7
------

Expand Down
10 changes: 10 additions & 0 deletions SECURITY.md
@@ -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
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
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
@@ -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.