Commit cd507a1
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: 916a91df8d111dce571dc71e3f4ead44dbbe69441 parent 9006991 commit cd507a1
2 files changed
+6
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4886 | 4886 | | |
4887 | 4887 | | |
4888 | 4888 | | |
4889 | | - | |
4890 | | - | |
4891 | | - | |
4892 | | - | |
| 4889 | + | |
| 4890 | + | |
| 4891 | + | |
| 4892 | + | |
4893 | 4893 | | |
4894 | 4894 | | |
4895 | 4895 | | |
| |||
0 commit comments