create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Snyk reports high risk severity for acorn in react-scripts

Open w3bdesign opened this issue 6 years ago • 28 comments

Describe the bug

Snyk reports high severity issue with react-scripts. See details below:

Regular Expression Denial of Service (ReDoS)

Vulnerable module: acorn
Introduced through: [email protected]
Exploit maturity: No known exploit
Fixed in: 7.1.1

Detailed paths

Introduced through: [email protected] › [email protected] › [email protected] › [email protected]
Remediation: No remediation path available.
Introduced through: [email protected] › [email protected] › [email protected] › [email protected] › [email protected]
Remediation: No remediation path available.
Introduced through: [email protected] › [email protected] › [email protected] › [email protected] › [email protected] › [email protected]
Remediation: No remediation path available.

…and 14 more Overview

acorn is a tiny, fast JavaScript parser written in JavaScript.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via a regex in the form of /[x-\ud800]/u, which causes the parser to enter an infinite loop.

This string is not a valid UTF16 and is therefore not sanitized before reaching the parser. An application which processes untrusted input and passes it directly to acorn, will allow attackers to leverage the vulnerability leading to a Denial of Service.

Did you try recovering your dependencies?

Yes.

Please paste the output of npm --version and/or yarn --version to confirm.

6.13.7

Which terms did you search for in User Guide?

Not applicable.

Environment

Environment Info:

System: OS: Windows 7 6.1.7601 CPU: (8) x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz Binaries: Node: 12.16.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.21.1 - C:\Program Files (x86)\Yarn x\bin\yarn.CMD npm: 6.13.7 - C:\Program Files\nodejs\npm.CMD Browsers: Internet Explorer: 11.0.9600.19301 npmPackages: react: ^16.13.0 => 16.13.0 react-dom: ^16.13.0 => 16.13.0 react-scripts: 3.4.0 => 3.4.0 npmGlobalPackages: create-react-app: Not Found

Steps to reproduce

Install new version of React.

(Write your steps here:)

  1. npx create-react-app my-app
  2. Test with Snyk.io

w3bdesign avatar Mar 07 '20 21:03 w3bdesign

I also have the same issue

nceight avatar Mar 08 '20 03:03 nceight

As do I! Feeling less lonely now

BMD-518 avatar Mar 08 '20 03:03 BMD-518

I also have this issue. npm audit throws that the acorn vuln is patched in version >=7.1.1. I don't know if installing directly the acorn module to the latest version with npm install acorn@latest will solve it. Gonna give it a try and share my results.

SirMauri avatar Mar 08 '20 05:03 SirMauri

@SirMauri any results?

jakubkratina avatar Mar 08 '20 15:03 jakubkratina

Setting resolutions in package.json is the better approach if using yarn as you don’t explicitly set a dependency on acorn in your project.

bpedersen avatar Mar 08 '20 15:03 bpedersen

@bpedersen thanks for the recommendation, this clears the warnings in yarn audit.

  "resolutions": {
    "acorn": "^7.1.1"
  },

dusty avatar Mar 08 '20 16:03 dusty

Adding the resolution worked. I came across this issue while working on a very small project using create-react-app. I'm pretty new to coding but I couldn't find a way to address this with npm. I just switched over to yarn but I'm still curious, what can be done about this in projects set up with node package manager?

BMD-518 avatar Mar 08 '20 16:03 BMD-518

@dusty @bpedersen @BMD-518

It may remove the warning to manually set the resolution, but does it affect anything in the Create React App in any way? Like, any functionality?

w3bdesign avatar Mar 09 '20 01:03 w3bdesign

I haven't noticed any build issues with the patched acorn.

dusty avatar Mar 09 '20 03:03 dusty

@dusty And no visible bugs in any React apps?

w3bdesign avatar Mar 09 '20 03:03 w3bdesign

Are there fix for this ?

ChimkenNuggyszDev avatar Mar 09 '20 08:03 ChimkenNuggyszDev

Any fix for npm? I've found 17 moderate severity vulnerabilities related to react-scripts using acorn.

jBraekke avatar Mar 09 '20 08:03 jBraekke

This needs to be fixed asap because it affect developers using create-react-app.

ChimkenNuggyszDev avatar Mar 09 '20 08:03 ChimkenNuggyszDev

resolution worked for me

chrisgiann44 avatar Mar 09 '20 09:03 chrisgiann44

Running npm, I was able to fix it temporarily by adding to package.json scripts: "preinstall": "npx npm-force-resolutions",

and adding to package.json "resolutions": { "acorn": "^7.1.1" }

waiting for react-scripts update though.

leinss avatar Mar 09 '20 10:03 leinss

Running npm, I was able to fix it temporarily by adding to package.json scripts: "preinstall": "npx npm-force-resolutions",

and adding to package.json "resolutions": { "acorn": "^7.1.1" }

waiting for react-scripts update though.

For others attempting this fix, please be mindful of your other dependencies that uses acorn. Tried this solution and sadly 7.1.1 broke some of my other modules.

shrugs, guess I'll have to wait on actual fixes.

Ordinal43 avatar Mar 09 '20 11:03 Ordinal43

Solved it temporary by using npm-audit-resolver

jBraekke avatar Mar 09 '20 13:03 jBraekke

Any updates ?

ChimkenNuggyszDev avatar Mar 09 '20 17:03 ChimkenNuggyszDev

 "resolutions": {
    "acorn": "^7.1.1"
  },

did not work for me.

any updates on the fix?

mohammedmunna avatar Mar 10 '20 08:03 mohammedmunna

same here :

Moderate Regular Expression Denial of Service Package acorn Patched in >=6.4.1 <7.0.0 || >=7.1.1 Dependency of react-scripts Path react-scripts > jest > jest-cli > jest-config > jest-environment-jsdom > jsdom > acorn More info https://npmjs.com/advisories/1488

any updates ?

Dmitrijus1989 avatar Mar 10 '20 12:03 Dmitrijus1989