Applying a patch with a fuzzFactor can be very very slow

Open
#692 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@json-open-source is already working on this.

Since Oct 1, 2026.

  • #711 by @json-open-source — open
  • #716 by @anzal1 — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
javascript
Domain
security

Research direction

Start at the applyPatch(...) and applyPatches(...) entrypoints and trace the fuzzy patch matching logic described in the report. Reproduce the control and crafted high-fuzzFactor cases to measure the slowdown. Done means crafted fuzzy patches no longer trigger excessive CPU time while normal fuzzy application behavior remains intact.

Written by the indexing model from the issue text.

Description

performance

Thanks to the following five security researchers for reporting this:

Finding 1: Fuzzy patch application can cause algorithmic complexity DoS
Affected behavior

applyPatch and applyPatches support fuzzy patch matching. With crafted hunks and a high fuzzFactor, the matching logic can end up exploring many alternatives recursively and spend a large amount of CPU time on a single input.

Affected entrypoints

`applyPatch(...)`
`applyPatches(...)`

Reproduction notes
In our reproduction, a normal control case completed in under 1 ms, while a crafted fuzzy patch took about 7.7 seconds on the same setup:

control time: 0.568181 ms
exploit time: 7737.472789 ms
slowdown: 13617.9717x

The issue appears to come from recursive branch exploration in the fuzzy patch application logic.

Dominant language
JavaScript
Stars
9.2k
Forks
555
Avg merge
1d 9h
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from kpdecker/jsdiff

All issues in kpdecker/jsdiff

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.