fix(fuzz): deterministic path iteration and frequency dedup for numeric segments#7058
fix(fuzz): deterministic path iteration and frequency dedup for numeric segments#7058a638011 wants to merge 1 commit intoprojectdiscovery:devfrom
Conversation
…ic segments Two root causes for numeric path segments being skipped during fuzzing: 1. Path.Parse() stored segments in a plain map, causing non-deterministic iteration order. Switched to OrderedMap (matching the Cookie component pattern) and updated Rebuild() to use KV.Get() accessor. 2. Frequency tracker used the numeric index key (e.g. "1", "2") instead of the actual parameter value for dedup, causing cross-target collisions when different URLs had the same number of path segments. Fixes projectdiscovery#6398
Neo - PR Security ReviewNo security issues found Highlights
Comment |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
WalkthroughChanges address path segment fuzzing by replacing unordered maps with ordered maps to preserve insertion order, adding a regression test for deterministic ordering, and fixing a parameter reference in the frequent-parameter skip logic. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Proposed Changes
Fixes #6398 — fuzzing templates skip numeric path parts (e.g.
55in/user/55/profile).Found two independent root causes:
1. Non-deterministic path segment iteration
Path.Parse()stored segments in a plainmap[string]interface{}, which has random iteration order in Go. This caused segments to be visited in unpredictable order across runs, sometimes skipping numeric parts entirely.Fix: Switch to
OrderedMap(same pattern used by the Cookie component) and updateRebuild()to use theKV.Get()accessor instead of direct.Map.GetOrDefault()access.2. Frequency tracker index collision
The frequency dedup in
parts.gopassed the numeric index key ("1","2","3") toIsParameterFrequent()instead of the actual parameter value ("user","55","profile"). This caused cross-target collisions — different URLs with the same number of path segments would suppress each other in the frequency tracker.Fix: Use
actualParameter(which already resolves numeric indices to their values) for frequency tracking.Proof
All existing + new tests pass:
Checklist
devbranch/claim #6398
Summary by CodeRabbit
Bug Fixes
Improvements
Tests