url: keep the next '=' across pairs in parseParams #67653
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 231 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.326
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #67653"
general
weight: 0.35
panva
parseParamssearched for=from the start of every pair. In a run of pairs with no=after them, each search scanned to the end of the string, sonew URLSearchParams('a&'.repeat(n))took quadratic time.Request#formData()reaches the same loop with an urlencoded body, so a client can block the event loop with one body: a 21 MB body ofa&held a server's CPU for over 4 minutes before it was stopped.This keeps the position of the next
=across pairs and searches again only once the parser has passed it.Timings of the loop copied into a script, median of 5, v26.13.1 arm64:
| pairs of
a&| before | after || ---: | ---: | ---: |
| 65,536 | 94 ms | 1.7 ms |
| 262,144 | 1476 ms | 8.3 ms |
The copied loop with and without the change returned the same output for 300,000 random strings over
a b = & ? + %2 0. The new test covers pairs with no=before and after pairs that have one, empty keys and values, a leading?, and encoded input. The new test checks that output; it passes before and after the change, since it guards the parse result rather than its speed. The speed is in a new benchmark,benchmark/url/url-searchparams-parse-no-equals.js. On v26.13.1, without the change,pairs=1e5runs 4.6 ops/s foraagainst 306 ops/s fora=b.I have not built Node locally, so I haven't run the full suite or the benchmark against the change; Node's ESLint config (
tools/eslint) passes on the three files.Fixes: https://github.com/nodejs/node/issues/67652
Refs: https://github.com/nodejs/node/pull/65363
---
Disclosure: I found and fixed this with a coding agent, which also opened this PR and #67652 from my account. I checked the fix against the source, compared the old and new loop on 300,000 random inputs, ran Node's ESLint, and timed the new benchmark on v26.13.1. I'll answer review comments myself.