feat(modules): implement batteringram and a scan-wide fuzz budget - #387
Open
TBX3D wants to merge 16 commits into
Open
feat(modules): implement batteringram and a scan-wide fuzz budget#387TBX3D wants to merge 16 commits into
TBX3D wants to merge 16 commits into
Conversation
checkMatchers/checkMatcher took (resp, body), so every matcher type that needs anything else (the request url, how long the round trip took, extractor output) forces another signature change through the whole engine and all of its callers. collect the per-response state into a MatchContext built once at each of the two call sites (single request and chain step) and thread that instead. no matcher behavior changes: the classic types read Resp and Body exactly as before. extraction moves above the matcher check in executeHTTPRequest. runExtractors is side-effect-free and the finding is only built on a match, so the order is behavior-preserving, and it lets a matcher read extractor values from the context. in a chain step the context carries the running variable set, so a matcher there also sees earlier steps' values.
add the dsl matcher type with a curated helper allowlist and load-time compile validation (bad syntax, non-allowlisted functions, empty or over-length expressions all rejected before scan time). evaluation lands in a follow-up; a loaded dsl matcher currently misses at match time.
drives a live httptest server through ExecuteHTTPModule with a dsl matcher bound to status_code and body, mirroring the existing favicon integration test, and asserts exactly one finding.
parse the request url and expose host[:port] so a nuclei-style host == "..." expression matches; dedupe the header serialization.
covers the bound variables, the helper allowlist and the load-time compile, so a module author does not have to read dsl.go to know what an expression can touch.
overload the payloads field with a custom unmarshaler: a yaml sequence is the
legacy single set named "payload", a mapping is ordered named sets injectable
at {{name}}. generation moves to a lazy iter.Seq that never materializes the
product, and substitution now reaches header values. file-backed sets parse but
are rejected until the loader lands.
a named set whose yaml value is a scalar string is a local wordlist path, loaded via the existing loadWordlist at resolve time. resolveSets is the single point set resolution can fail.
per fuzzing-module-per-target request cap, default 25000, 0 = unlimited. threaded into modules.Options; enforced by the executor in a follow-up.
ExecuteHTTPModule consumes streamRequests directly instead of materializing the full product and sizing the results channel to it. a fixed worker pool pulls from an unbuffered feed, a single collector owns the findings slice (dropping the mutex), and the producer enforces -fuzz-max-requests with a one-shot truncation log.
the existing cancel test only ever passes an already-cancelled context, so the producer returns at its up-front ctx.Err() check and never reaches the send-select guarding reqCh. add a regression test that cancels while a large payload set is mid-flight against a blocking server, so the producer's and workers' send-selects both get exercised, and assert ExecuteHTTPModule still returns promptly with no goroutine leak.
substitute header values on the no-payload path too, matching the payload and chain paths; warn when a resolved payload set is empty so a misconfigured wordlist is not mistaken for a clean no-findings run. harden the mid-stream cancel test to poll for goroutine drain instead of a fixed sleep.
the payloads field grew two shapes (named sets, file-backed sets) and a scan-wide cap; none of that was discoverable without reading yaml.go.
each fuzzing module's producer already caps its own requests via -fuzz-max-requests, but a scan running many fuzz-capable modules against one target had no overall ceiling on total fuzz traffic. FuzzBudget is a shared atomic counter passed through Options and reserved per request by every module's producer; -fuzz-global-max-requests (default 100000, 0 = unlimited) sizes it once per scan run and it's reused across every concurrently scanned target. exhaustion truncates each affected module's producer cleanly and logs once scan-wide, not once per module.
validateAttack previously rejected batteringram alongside sniper as not-yet-implemented. match nuclei's semantics: every payload position in a request gets the same value simultaneously, drawn from the first declared set, crossed with paths and stopping at that set's length (not clusterbomb's cross-product). integrates with the existing lazy streamRequests iterator, so nothing is materialized.
pr summary18 files changed (+1543 -198)
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #387 +/- ##
=======================================
Coverage ? 65.64%
=======================================
Files ? 89
Lines ? 8109
Branches ? 0
=======================================
Hits ? 5323
Misses ? 2384
Partials ? 402 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
stacked on #386, so only the commits above it are this pr's.
validateAttack rejected batteringram alongside sniper as not implemented. it is the simple one: every payload position in a request takes the same value at once, drawn from the first declared set, crossed with paths and stopping at that set's length rather than clusterbomb's product. it rides the existing lazy iterator, so nothing is materialized. the second commit adds the ceiling the per-module cap does not give: FuzzBudget is a shared atomic reserved per request by every producer, sized once per run by -fuzz-global-max-requests and reused across concurrently scanned targets, so exhaustion logs once for the scan instead of once per module.