Problem/Motivation
The braces NPM package, a dependency used in Drupal's core JavaScript tooling, has a known vulnerability in versions earlier than 3.0.3. This vulnerability allows for uncontrolled resource consumption, potentially leading to memory exhaustion and a crash. Specifically, when parsing input with "imbalanced braces," the package may enter an infinite loop, allocating heap memory without releasing it.
This issue was identified by a Dependabot alert, which could not automatically update the package due to the absence of a package.json in the web/core/ directory. The vulnerability needs to be addressed to ensure the security and stability of Drupal's core dependencies.
Steps to reproduce
- Use a version of Drupal that depends on
bracesversion3.0.2or earlier. - Parse input with "imbalanced braces" using the
bracespackage. - Observe that the process consumes increasing amounts of memory and eventually crashes due to memory exhaustion.
Proposed resolution
- Update the
bracespackage in Drupal's dependencies to version3.0.3by modifying thepackage.jsonandyarn.lockfiles. - Ensure that all transitive dependencies are also using
bracesversion3.0.3. - Verify that the issue is resolved by testing the behavior with inputs that previously caused memory exhaustion.
- Submit a patch to apply these changes to the Drupal core repository.
Remaining tasks
- Apply the
bracesupdate to the relevant branches (10.3.x). - Verify that the update does not introduce any regressions or new issues.
- Submit the patch for review.
- Communicate with the maintainers to ensure the patch is merged into the appropriate Drupal core versions.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3467599
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
hossein.daliran commentedPatch for 10.2.x
Comment #3
cilefen commentedComment #4
longwaveyarn auditalso reports problems withws, let's fix that at the same time.Comment #5
longwaveNote also that this only affects development dependencies and can't be exploited at runtime, the Drupal Security Team will not be issuing a security release or advisory about this change.
Comment #8
spokjeLet's see...
Comment #9
spokjeOh, the joy of supporting multiple versions of core...
This looks like this is going to be a different MR for at least 11.x/10.x and perhaps even one for every minor version.
Lets start with
11.x.Firstly in yarn v4-land apparently
yarn auditnow becameyarn npm audit -R.On
11.xthat gives us:If we snip the deprecations that leaves us with:
Comment #10
spokjeComment #11
spokjeSo the
11.x-branch didn't break tests.Let the backport-games begin!
Comment #12
spokjeComment #13
smustgrave commentedif I understand the thread a piece of the change should be reverted.
Comment #14
spokjeThanks @smustgrave, wasn't pinged on the comment on the MR.
Replied inline, back to NR to await the answer of @longwave.
Comment #17
spokjeOpened a new branch using the
yarn up -R <name>method, not usingresolutions.Comment #18
smustgrave commentedReviewed the MR with just the lock file and seems straight forward. Didn't cause any issues locally updating.
Comment #21
nod_11.x in, next branch is 11.0.x :)
Committed 46ee730 and pushed to 11.x. Thanks!
Comment #22
spokje11.0.x:
That means we want to update:
Comment #24
spokjeComment #25
spokjeThings got more involved with this one, after a
$ yarn up -R braces ejs micromatch tar wsit turned outbraces,ejsandmicromatchwe're not updated.Next up, I tried removing the entry for each of them in
yarn.lockand doing ayarn install.That worked for
micromatch, however that has a CVE stating we need to go3.0.8or higher (See https://github.com/advisories/GHSA-952p-6rrq-rcjv). However the latest release is3.0.7(See https://www.npmjs.com/package/micromatch).So this one still gets flagged by
yarn audit -R, but as far as I can tell there's a mistake made in the CVE.Finally:
braces,ejscould only be bumped by usingresolutions. I know this is not optimal, but at least this will only happen in version branches and not in main/11.xAlso they all have
resolutionsalready, due to having an ancient nightwatch version.Comment #26
spokjeComment #27
smustgrave commentedThe reasoning in #25 I believe makes sense (js is not my strong area). But 11.0.x tests didn't break and updates for 11.x seem accepted.
Comment #30
nod_branches below have a different yarn version/lock file format so let's to that in a different issue if necessary and leave this one here.
Committed cf5738b and pushed to 11.0.x. Thanks!