Skip to content

feat(modules): implement batteringram and a scan-wide fuzz budget - #387

Open
TBX3D wants to merge 16 commits into
vmfunc:mainfrom
TBX3D:lane/fuzz-batteringram
Open

feat(modules): implement batteringram and a scan-wide fuzz budget#387
TBX3D wants to merge 16 commits into
vmfunc:mainfrom
TBX3D:lane/fuzz-batteringram

Conversation

@TBX3D

@TBX3D TBX3D commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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.

TBX3D added 16 commits July 30, 2026 19:12
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.
@TBX3D
TBX3D requested a review from vmfunc as a code owner July 31, 2026 02:30
@github-actions github-actions Bot added modules changes to scan modules docs documentation changes tests test changes config configuration changes deps dependency updates size/xl 500+ lines changed labels Jul 31, 2026
@github-actions

Copy link
Copy Markdown

pr summary

18 files changed (+1543 -198)

category files
go source 15
tests 8
deps 1

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 90.09288% with 32 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@a38ba0a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
internal/modules/executor.go 92.63% 8 Missing and 6 partials ⚠️
internal/modules/yaml.go 78.37% 6 Missing and 2 partials ⚠️
sif.go 14.28% 6 Missing ⚠️
internal/modules/dsl.go 95.06% 2 Missing and 2 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

config configuration changes deps dependency updates docs documentation changes modules changes to scan modules size/xl 500+ lines changed tests test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants