Skip to content

fix(fuzz): keep parameters named like duplicate-parameter aliases - #8349

Open
m3lonxd wants to merge 1 commit into
projectdiscovery:devfrom
m3lonxd:fix/form-keep-params-named-like-duplicate-aliases-8347
Open

m3lonxd wants to merge 1 commit into
projectdiscovery:devfrom
m3lonxd:fix/form-keep-params-named-like-duplicate-aliases-8347

Conversation

@m3lonxd

@m3lonxd m3lonxd commented Nov 29, 2026 •

Copy link
Copy Markdown

Fixes #8347

Summary of Changes

Form encoding previously folded any parameter named key_N into key whenever key already existed in the request, even when key_N was a distinct, authentic parameter from the input (such as address=home&address_1=apt5).

  1. pkg/fuzz/dataformat/kv.go:
    • Added duplicateAliases map[string]duplicateAlias to KV (and cloned in KV.Clone()) to explicitly remember generated duplicate aliases.
    • Added Lookup(key string) (any, bool) on KV.
  2. pkg/fuzz/dataformat/form.go:
    • In Form.Decode, record generated duplicate alias keys (key_1, key_2, ...) via setDuplicateAlias() and ensure alias naming does not collide with existing parameter names in the request.
    • In Form.Encode, only fold keys that were marked as duplicate aliases back into repeated base parameters. Authentic parameter names that match key_N are preserved verbatim.
  3. Regression Tests:
    • Added TestFormDecodeEncode_KeepsParametersNamedLikeNormalizedKeys, TestFormEncode_DuplicateParameterAliasAfterClone, TestFormDecodeEncode_DuplicateParametersWithAliasNameCollision, and TestFormDecodeEncode_DuplicateParametersKeepOrder in pkg/fuzz/dataformat/form_test.go.
    • Added TestQueryComponentKeepsParametersNamedLikeDuplicateAliases and TestQueryComponentFuzzesDuplicateParameterAlias in pkg/fuzz/component/query_test.go.
    • Added TestBodyFormComponentKeepsParametersNamedLikeDuplicateAliases in pkg/fuzz/component/body_test.go.

All tests in pkg/fuzz/... pass cleanly.

Summary by CodeRabbit

  • Bug Fixes
    • Form and query parameters with names that resemble generated duplicate aliases are now preserved correctly when values are changed.
    • Rebuilding form data now retains duplicate parameter values and their order, including after cloning and editing.
    • Existing parameters are less likely to be overwritten when duplicate names require generated aliases.

Form encoding folded any parameter named key_N into key whenever key
already existed, even if key_N was an authentic parameter from the
request rather than a normalized duplicate alias.

Record generated duplicate aliases during Form.Decode and only fold
those back during Form.Encode, allowing parameters like address_1
alongside address to keep their distinct names and values.
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Form decoding now records generated aliases for duplicate parameters and avoids collisions with existing names. Form encoding uses that metadata to preserve distinct parameter names. Regression tests cover encoding and cloned query and form-body values.

Changes

Form Alias Preservation

Layer / File(s) Summary
Track aliases and preserve form parameters
pkg/fuzz/dataformat/kv.go, pkg/fuzz/dataformat/form.go, pkg/fuzz/dataformat/form_test.go, pkg/fuzz/component/query_test.go, pkg/fuzz/component/body_test.go
KV stores and clones generated-alias metadata and provides Lookup. Form decoding avoids alias-name collisions. Form encoding combines only recorded aliases and preserves other keys. Tests cover duplicate parameters, alias-like names, and cloned query and body values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: tarunkoyalwar, james-yusuke, ice3man543

Merge Risk: Minimal · up to ef764

This fixes form and query fuzzing so that parameters such as address_1 are no longer folded into address. Duplicate-key behavior is unchanged. Regression tests cover the main cases, and I found no remaining merge-blocking issue.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: form and query parameters whose names resemble duplicate-parameter aliases (such as address_1) are kept as separate parameters instead of being folded into the base ke…
Linked Issues check Passed Directly linked issue #8347 requires that parameters named like duplicate aliases (for example address_1 next to address) stay separate, and that fuzzing them neither renames, drops, nor overwrite…
Out of Scope Changes check Passed All changes support the objective in #8347. form.go changes implement alias tracking, collision-free alias naming, and key-specific folding. The kv.go changes add duplicateAliases metadata, its …
Full details: Title check

Explanation

The title names the main change: form and query parameters whose names resemble duplicate-parameter aliases (such as address_1) are kept as separate parameters instead of being folded into the base key. The changes in form.go, kv.go, and the tests all match this. The title is specific and uses the fix(fuzz) convention.

Full details: Linked Issues check

Explanation

Directly linked issue #8347 requires that parameters named like duplicate aliases (for example address_1 next to address) stay separate, and that fuzzing them neither renames, drops, nor overwrites address. At the reviewed head, Form.Decode records only aliases it generates for repeated parameters (setDuplicateAlias) and skips names already present in the request (taken set). Form.Encode folds back only keys with alias metadata; any other key, including address_1, is emitted under its own name via params.Add(key, ...). KV.Clone() copies the alias metadata, so the foo_1 case after cloning is covered. Regression tests cover the three cases listed in the issue (form round trip, alias after clone, query component with address_1), plus a body-form component test. Reordering of duplicate keys to the end of the query is explicitly out of scope and was not required. The implementation addresses every coding requirement in the issue. Test results were taken from the PR description and not re-executed.

Full details: Out of Scope Changes check

Explanation

All changes support the objective in #8347. form.go changes implement alias tracking, collision-free alias naming, and key-specific folding. The kv.go changes add duplicateAliases metadata, its clone handling, and Lookup, which Form.Encode requires. The removed suffix-regex normalization and reconstruction logic were replaced by the new metadata-based logic, so they are part of the same fix. The test additions in form_test.go, query_test.go, and body_test.go verify the changed behavior. No unrelated feature or unrelated file change was found in the reviewed summary. The removal of verbose conversion and index error logging is a small side effect in the touched function and does not relate to a separate feature.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks each form key twice
And keeps address_1 in place
Duplicate names get aliases tracked
Cloned values keep their trace
The query and body tests agree
Then hops away with tidy forms

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 70e152c9-5dc1-4c9d-b4af-9e7a247a8d9f
Commits

Reviewing files that changed from the base of the PR and between f710b6d and ef764c1.

Files selected for processing: 5

  • pkg/fuzz/component/body_test.go
  • pkg/fuzz/component/query_test.go
  • pkg/fuzz/dataformat/form.go
  • pkg/fuzz/dataformat/form_test.go
  • pkg/fuzz/dataformat/kv.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Fuzzing merges query/form parameters named like name_1 into name

1 participant