Skip to content

Commit cd507a1

Browse files
Copilotmeta-codesync[bot]
authored andcommitted
Fix jsdiff DoS vulnerability (CVE) by forcing upgrade to 8.0.3 (#264)
Summary: ## Problem The `diff` package v5.0.0 has a DoS vulnerability where `parsePatch`/`applyPatch` enter infinite loops on patches with filenames containing `\r`, `\u2028`, or `\u2029`, causing OOM crashes. The vulnerable version comes from transitive dependency: `docusaurus-plugin-internaldocs-fb@1.19.2` → `uvu@0.5.3` → `diff@^5.0.0`. ## Changes - Added `"diff": "^8.0.3"` to Yarn resolutions in `website/package.json` - Updated `website/yarn.lock` to resolve all diff dependencies to patched version 8.0.3 This forces the patched version across all transitive dependencies while maintaining compatibility with existing constraints. <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[BUG] Fix jsdiff has a Denial of Service vulnerability in parsePatch and applyPatch</issue_title> > <issue_description>Dependabot cannot update diff to a non-vulnerable version > The latest possible version that can be installed is 5.0.0 because of the following conflicting dependency: > > docusaurus-plugin-internaldocs-fb@1.19.2 requires diff@^5.0.0 via a transitive dependency on uvu@0.5.3 > The earliest fixed version is 8.0.3. > > Transitive dependency diff 5.0.0 is introduced via > docusaurus-plugin-internaldocs-fb 1.19.2 ... diff 5.0.0 > Package > Affected versions > Patched version > diff > (npm) > < 8.0.3 > 8.0.3 > Impact > Attempting to parse a patch whose filename headers contain the line break characters \r, \u2028, or \u2029 can cause the parsePatch method to enter an infinite loop. It then consumes memory without limit until the process crashes due to running out of memory. > > Applications are therefore likely to be vulnerable to a denial-of-service attack if they call parsePatch with a user-provided patch as input. A large payload is not needed to trigger the vulnerability, so size limits on user input do not provide any protection. Furthermore, some applications may be vulnerable even when calling parsePatch on a patch generated by the application itself if the user is nonetheless able to control the filename headers (e.g. by directly providing the filenames of the files to be diffed). > > The applyPatch method is similarly affected if (and only if) called with a string representation of a patch as an argument, since under the hood it parses that string using parsePatch. Other methods of the library are unaffected. > > Finally, a second and lesser bug - a ReDOS - also exhibits when those same line break characters are present in a patch's patch header (also known as its "leading garbage"). A maliciously-crafted patch header of length n can take parsePatch O(n³) time to parse. > > Patches > All vulnerabilities described are fixed in v8.0.3. > > Workarounds > If using a version of jsdiff earlier than v8.0.3, do not attempt to parse patches that contain any of these characters: \r, \u2028, or \u2029. > > References > PR that fixed the bug: https://github.com/kpdecker/jsdiff/pull/649</issue_description> > > <agent_instructions>Fix it</agent_instructions> > > ## Comments on the Issue (you are copilot in this section) > > <comments> > </comments> > </details> - Fixes #263 --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). Pull Request resolved: #264 Differential Revision: D90757733 Pulled By: talgalili fbshipit-source-id: 916a91df8d111dce571dc71e3f4ead44dbbe6944
1 parent 9006991 commit cd507a1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

website/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"axios": "^1.7.9",
7777
"wait-on": "^7.2.0",
7878
"js-yaml": "^3.14.2",
79-
"brace-expansion": "^1.1.12"
79+
"brace-expansion": "^1.1.12",
80+
"diff": "^8.0.3"
8081
}
8182
}

website/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4886,10 +4886,10 @@ detect-port@^1.3.0:
48864886
address "^1.0.1"
48874887
debug "4"
48884888

4889-
diff@^5.0.0:
4890-
version "5.0.0"
4891-
resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b"
4892-
integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==
4889+
diff@^5.0.0, diff@^8.0.3:
4890+
version "8.0.3"
4891+
resolved "https://registry.yarnpkg.com/diff/-/diff-8.0.3.tgz#c7da3d9e0e8c283bb548681f8d7174653720c2d5"
4892+
integrity sha512-qejHi7bcSD4hQAZE0tNAawRK1ZtafHDmMTMkrrIGgSLl7hTnQHmKCeB45xAcbfTqK2zowkM3j3bHt/4b/ARbYQ==
48934893

48944894
dir-glob@^3.0.1:
48954895
version "3.0.1"

0 commit comments

Comments
 (0)