Skip to content

Fix Option for CVE-2024-4068: Memory Exhaustion in Braces - #38

Closed
BlueTux611 wants to merge 1 commit into
micromatch:masterfrom
BlueTux611:memory-fix
Closed

BlueTux611 wants to merge 1 commit into
micromatch:masterfrom
BlueTux611:memory-fix

Conversation

@BlueTux611

Copy link
Copy Markdown

Proposing as a possible solution if it fits.

Issue Description: "braces" fails to limit the number of characters it can handle, which could lead to Memory Exhaustion. In "lib/parse.js," if a malicious user sends "imbalanced braces" as input, the parsing will enter a loop, which will cause the program to start allocating heap memory without freeing it at any moment of the loop. Eventually, the JavaScript heap limit is reached, and the program will crash.

To address this issue I added a check for imbalanced braces after the maxLength check. When tested it no longer leads to "Javascript heap out of memory" and will instead throw syntax error when imbalanced braces are used similar to when input is above the max length.

@lroal

lroal commented May 16, 2024

Copy link
Copy Markdown

Yes, hope this gets published soon.

@NitishGameChanges

Copy link
Copy Markdown

When this PR will get merged?

@paulmillr

Copy link
Copy Markdown
Contributor

it needs tests.

@paulmillr paulmillr closed this May 17, 2024
@quiquetubi

Copy link
Copy Markdown

Was there a reason why this PR was closed instead of merged? I see tests weren't added either

@paulmillr

Copy link
Copy Markdown
Contributor

@quiquetubi no particular reason. I was not in the mood of keeping it open.

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

Successfully merging this pull request may close these issues.

6 participants