Skip to content

CWE-400 | Uncontrolled resource consumption #35

Closed

Description

@archanasharma3

Ran latest scan and landed with this issue - CWE-400 | Uncontrolled resource consumption

The NPM package "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.

braces/lib/parse.js on line 308 - do {

Activity

  1. doowb commented on Mar 12, 2024

    @doowb
    Member

    @archanasharma3 could you provide the error you're seeing when the heap limit is reached and your program crashes?

    The pattern length is checked here.
    You could either check the pattern length before passing it to braces or handle the error in a try-catch.

    There's also an option that will enforce a lower max length if you'd like to do that and catch the error.

  2. rahulmukherjee85 commented on Mar 18, 2024

    @rahulmukherjee85

    In addition to @archanasharma3 comments,
    braces flagged as vulnerable package:
    Dependency npm:braces 3.0.2 is vulnerable
    Cxab55612e-3a56 7.5 - CWE-400
    Results powered by Checkmarx(c)
    Braces is a transitive dependency of Npm-chokidar in our application.
    there any way to set the limit in global level ? please let us know

  3. cx-mario-teixeira commented on Mar 20, 2024

    @cx-mario-teixeira

    Hello @doowb,

    I'm reaching out here to confirm that this is indeed the other vulnerability reported by the Checkmarx CxResearch group. We opened this issue (micromatch/micromatch#243) after trying to reach out by email unsuccessfully. You can still find the details in the report we sent.

    CVEs for both vulnerabilities will come out soon.

    Thank you,
    Mário Teixeira

  4. LoganArnett commented on Apr 19, 2024

    @LoganArnett

    It looks like the description of this vulnerability is around the do/while loop for the imbalanced braces:

    The NPM package "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.
    
  5. cx-mario-teixeira commented on May 13, 2024

    @cx-mario-teixeira

    Hello @doowb ,

    CVEs for micromatch and braces vulnerabilities are now public. You can see this comment for additional details:
    micromatch/micromatch#243 (comment)

    Best regards,
    Mário Teixeira

  6. sdupont73 commented on May 13, 2024

    @sdupont73

    Does anyone know when a fix is expected for this vulnerability?

  7. benjsmi commented on May 16, 2024

    @benjsmi

    @sdupont73 -- I'm going to guess that the answer to "when is a fix coming" is probably never. The last commit to this repository was 2019. Same goes for the npm. I do not maintain this project, so I don't actually know, but we've not heard anything from the maintainers and there seems to be very little development effort, so my guess is that a replacement is a better option.

  8. BlueTux611 commented on May 16, 2024

    @BlueTux611

    For this issue proposed this as potential fix:

  9. prabhu commented on May 21, 2024

    @prabhu

    So you found an infinite loop and then decided to call it a security vulnerability? The amount of time human civilization wastes with low quality CVEs is staggering.

  10. theta682 commented on May 22, 2024

    @theta682

    I see a commit 9f5b4cf which is included in v3.0.3. Probably this means the issue is fixed.

  11. cx-mario-teixeira commented on May 22, 2024

    @cx-mario-teixeira

    Hi,

    We did a PoC and can confirm that version 3.0.3 fixed the issue for CVE-2024-4068.

    However, as stated here, the ReDoS vulnerability (CVE-2024-4067) still exists and can potentially be exploited if a certain library is calling the vulnerable method.

    Best regards,
    Mário Teixeira

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions