Repository navigation
bug: upgrade moment to 2.29.4 (CVE-2022-31129 RFC2822 ReDoS) - #1126
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Code Scan finding sfind-e5ddd93b (high, Snyk
SNYK-JS-MOMENT-2944238/ CVE-2022-31129, CWE-1333): upgradesmoment2.15.1 -> 2.29.4 inpackage.json+package-lock.json(the only moment entries; no other deps changed).routes/index.js/importpasses the CSVwhenfield from the request straight tomoment(when). In moment 2.18.0-2.29.3 a long string like'(' x NmakespreprocessRFC2822run in quadratic time and blocks the event loop. 2.29.4 caps that parsing.No app code changes.
moment.locale()/moment(when).format(format)behave the same for normal input (checked below). This also moves past the other moment advisories on 2.15.1 (locale path traversal SNYK-JS-MOMENT-2440688, ReDoS SNYK-JS-MOMENT-10164).Note: the RFC2822 parser was added in moment 2.18.0, so 2.15.1 on
maindoesn't run this exact code path (timings below show this). Snyk still flags 2.15.1, and 2.29.4 is the fixed version it recommends.How it was tested
Ran the real
app.js(NODE_OPTIONS=--openssl-legacy-provider, Mongo replaced by an in-memory stub) and used curl to send a CSV toPOST /import. Comparedmain(2.15.1),mainwith moment 2.29.3 (the last vulnerable version), and this branch (2.29.4):POST /importdentist,2016-10-01,en,LL+rfc,01 Oct 2016 10:00:00 +0000,en,LL[October 1, 2016]when = '(' x 20000when = '(' x 40000when = '(' x 80000GET /about_newtook 6.0 s instead of the usual ~2.7 s)Direct library probe,
moment('('.repeat(n))for n = 10k/20k/40k: 2.29.3 took 54 / 318 / 1074 ms; 2.29.4 took 0.9 / 0.2 / 0.3 ms.Not run:
npm test(snyk test), because there's no Snyk token and api.snyk.io isn't reachable from the test box. The repo has no other runnable test suite.Devin-Org: engineering
Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/040d25a12a1240ce9204a9b2dcf2d869
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/040d25a12a1240ce9204a9b2dcf2d869?variant=devin
Devin Review