Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

word-wrap vulnerable to Regular Expression Denial of Service #40

Closed
vianch opened this issue Jun 28, 2023 · 14 comments
Closed

word-wrap vulnerable to Regular Expression Denial of Service #40

vianch opened this issue Jun 28, 2023 · 14 comments

Comments

@vianch
Copy link

vianch commented Jun 28, 2023

All versions of the package word-wrap are vulnerable to Regular Expression Denial of Service (ReDoS) due to the usage of an insecure regular expression within the result variable.

Screenshot 2023-06-28 at 12 16 27

@magnussp
Copy link

Just encountered this as well as latest firebase-admin package is reliant on some packages that in turn is reliant on word-wrap.

@eclousersans
Copy link

Dealing with this as well. eslint depends on optionator which depends on word-wrap.

Any ETA on patch release?

@eclousersans
Copy link

Per this PR:
#33

They aren't able to merge in due to bus factor and the original repo owner getting hit by a bus.

As a hack, they've published a new version under another package name.

Par for the course in JS community...

@silverbackdan
Copy link

As seen here #33 (comment)

"overrides": {
  "word-wrap" : "npm:@aashutoshrathi/word-wrap"
}

It appears this is currently a maintained version which you can override with.

@jacquesg
Copy link

This unfortunately breaks eslint for me:

Oops! Something went wrong! :(                                                                                                                                                                            
                                                                                                                                                                                                          
ESLint: 8.43.0                                                                                                                                                                                            
                                                                                                                                                                                                          
Error: Cannot find module 'word-wrap'                                                                                                                                                                     
Require stack:                                                                                                                                                                                            
- /home/jacquesg/dev/projects/lossbook/antaeus/node_modules/optionator/lib/help.js                                                                                                                        
- /home/jacquesg/dev/projects/lossbook/antaeus/node_modules/optionator/lib/index.js                                                                                                                       
- /home/jacquesg/dev/projects/lossbook/antaeus/node_modules/eslint/lib/options.js                                                                                                                         
- /home/jacquesg/dev/projects/lossbook/antaeus/node_modules/eslint/lib/cli.js                                                                                                                             
- /home/jacquesg/dev/projects/lossbook/antaeus/node_modules/eslint/bin/eslint.js                                                                                                                          
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)                                                                                                                         
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)                                                                                                                                    
    at Module.require (node:internal/modules/cjs/loader:1005:19)                                                                                                                                          
    at require (node:internal/modules/cjs/helpers:102:18)                                                                                                                                                 
    at Object.<anonymous> (/home/jacquesg/dev/projects/lossbook/antaeus/node_modules/optionator/lib/help.js:6:14)                                                                                         
    at Object.<anonymous> (/home/jacquesg/dev/projects/lossbook/antaeus/node_modules/optionator/lib/help.js:260:4)                                                                                        
    at Module._compile (node:internal/modules/cjs/loader:1105:14)                                                                                                                                         
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)                                                                                                                           
    at Module.load (node:internal/modules/cjs/loader:981:32)                                                                                                                                              
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)   

@silverbackdan
Copy link

I'm also on eslint 8.43.0 - is it possible there is some cache left-overs?

@jacquesg
Copy link

No, retried from clean as well. Ended up adding an override for optionator instead, which accomplishes the same thing effectively:

"overrides": {
  "optionator" : "0.9.3"
}

@silverbackdan
Copy link

Interesting - pleased you found your solution too.

@bjornjorgensen
Copy link

Any updates?

@mahnoorkazidh
Copy link

npm audit doesn't fix it for me.. unfortunately. Any update on the solution?

@larouxn
Copy link

larouxn commented Jul 4, 2023

npm audit doesn't fix it for me.. unfortunately. Any update on the solution?

The best solution we have right now (from here) is to switch to a patched fork. #33 (comment)

"resolutions": {
  "word-wrap": "npm:@aashutoshrathi/word-wrap@^1.2.4"
},

Looks like eslint bumped their affected dependency optionator so that may work for you as well. eslint/eslint#17117

"resolutions": {
  "optionator": "^0.9.3"
}

Non-Yarn users can use overrides in place of resolutions apparently. (haven't tried)

Lastly, it seems many have swapped over to the fork according to the fork's page on npmjs.org.

Screenshot from 2023-07-04 18-58-59

NoelLH added a commit to webful-ltd/passwordmaker that referenced this issue Jul 13, 2023
By overriding `optionator` version per
jonschlinkert/word-wrap#40 (comment)

This only affects puppeteer, a test library, so no
need to cut a new app release. There was no app security
issue but fixing this reduces noise that could distract from
new, actual security issues.

Also `npm update` generally.
@kachkaev
Copy link

Duplicate of #32

@Anmol-Baranwal
Copy link

Hi, everyone.

I was looking for an answer, and never thought it would be as simple as this.

npm audit fix

It will ultimately update the version of the dependency package and it creates no problem.

For reference of the change, you can see here

@doowb
Copy link
Collaborator

doowb commented Jul 18, 2023

Fixed in word-wrap@1.2.4.

@doowb doowb closed this as completed Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests