fix(fuzz): preserve form parameters with shared prefixes - #7515
Conversation
WalkthroughThe key-normalization logic in form.go's Encode function was changed from a strings.HasPrefix-based check to a new normalizedKeyBase helper that derives base keys via regex matching, preventing prefix-sharing parameter names from being incorrectly merged. Tests were added covering query and form components. ChangesPrefix Key Merge Fix
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai create an issue for this. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
repo="projectdiscovery/nuclei"
pr_number="7515"
echo "=== CodeRabbit review comments ==="
gh api --paginate "repos/$repo/pulls/$pr_number/comments" --jq '
.[] | select((.user.login | ascii_downcase) == "coderabbitai") |
{url: .html_url, path: .path, line: .line, body: .body}
'
echo "=== CodeRabbit PR conversation comments ==="
gh api --paginate "repos/$repo/issues/$pr_number/comments" --jq '
.[] | select((.user.login | ascii_downcase) == "coderabbitai") |
{url: .html_url, body: .body}
'Length of output: 750
|
|
@coderabbitai just create a tracking issue for this. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
repo="projectdiscovery/nuclei"
pr_url="https://github.com/projectdiscovery/nuclei/pull/7515"
comment_url=$(gh api "repos/$repo/issues/7515/comments" \
--jq '.[] | select(.user.login == "dwisiswant0" and (.body | contains("just create a tracking issue for this"))) | .html_url' \
| tail -n1)
if [ -z "$comment_url" ]; then
comment_url="$pr_url"
fi
body=$(cat <<EOF
## Summary
Track post-merge validation and any follow-up work for the fuzzing parameter-normalization change in `#7515`.
## Rationale
Fuzzing request reconstruction must preserve the identity and order of parameters whose names share prefixes. For example, \`foo\` must remain distinct from \`foobar\`, while true duplicate keys such as repeated \`foo\` parameters must continue to merge according to the existing normalization behavior.
## Affected areas
- \`pkg/fuzz/dataformat/form.go\`
- \`pkg/fuzz/component/query_test.go\`
- Form and query parameter decode/encode/rebuild paths
## Acceptance criteria
- Confirm prefix-sharing parameter names are never merged during form or query reconstruction.
- Confirm true duplicate parameters retain the established normalization behavior and value order.
- Add or adjust regression coverage if additional request formats or edge cases are discovered.
## Backlinks
- Pull request: $pr_url
- Requesting comment: $comment_url
- Requested by: `@dwisiswant0`
EOF
)
gh issue create \
--repo "$repo" \
--title "Track fuzzing parameter normalization follow-up" \
--body "$body" \
--assignee "dwisiswant0"Length of output: 1748
|
Proposed changes
Fixes incorrect reconstruction of form/query parameters when different parameter names share a prefix.
Before this change, decoding and re-encoding a query like:
could incorrectly treat
foobar_1as if it belonged tofoo, producing:This PR makes normalized duplicate-parameter handling match the exact base parameter name before merging values. It preserves the existing duplicate-parameter behavior for cases like
foo=a&foo=b&foo=c, while avoiding accidental merges for prefix-sharing names such asfooandfoobar.Proof
Tested with:
Checklist
Summary by CodeRabbit
Bug Fixes
Tests