Skip to content

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

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

feat(modules): implement batteringram and a scan-wide fuzz budget#387
TBX3D wants to merge 17 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
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

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

pr summary

16 files changed (+1552 -169)

category files
go source 13
tests 6
deps 1

@codecov-commenter

codecov-commenter commented Jul 31, 2026

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 91.27517% with 26 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@e9d578a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
internal/modules/executor.go 92.72% 7 Missing and 5 partials ⚠️
sif.go 14.28% 6 Missing ⚠️
internal/modules/dsl.go 95.06% 2 Missing and 2 partials ⚠️
internal/modules/yaml.go 89.18% 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        ?   69.23%           
=======================================
  Files           ?       90           
  Lines           ?     9153           
  Branches        ?        0           
=======================================
  Hits            ?     6337           
  Misses          ?     2402           
  Partials        ?      414           

☔ 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.

vmfunc commented Aug 22, 2026

Copy link
Copy Markdown
Owner

batteringram and the shared budget both look right. this is the tip of the #384#386 stack though so it can't move til those do. one thing for the rebase: Reserve() bumps the counter even on the failed reservation, so the budget's off by one per module - tidy that up.


Generated by Claude Code

TBX3D added 17 commits August 22, 2026 11:54
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.
the yaml shape rejections and the clusterbomb empty-set short-circuit were
unexercised; removing either left the suite green.
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.
Reserve incremented the shared counter before comparing it to the ceiling,
so every producer that hit the cap left the count one higher than the number
of requests actually issued. swap it for a compare-and-swap loop that only
increments when the request fits.
Copilot AI lite review requested due to automatic review settings August 22, 2026 20:05
@TBX3D
TBX3D force-pushed the lane/fuzz-batteringram branch from 3f5b1a9 to 794bc69 Compare August 22, 2026 20:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends HTTP module fuzzing with batteringram attack mode and a scan-wide request budget, plus adds DSL matcher support.

Changes:

  • Adds batteringram generation and named/file-backed payload handling.
  • Adds per-module and global fuzz request limits.
  • Adds DSL compilation, evaluation, validation, tests, and documentation.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
sif.go Updated as part of this pull request.
internal/modules/yaml.go Updated as part of this pull request.
internal/modules/module.go Updated as part of this pull request.
internal/modules/matchers_test.go Updated as part of this pull request.
internal/modules/fuzz_test.go Updated as part of this pull request.
internal/modules/favicon.go Updated as part of this pull request.
internal/modules/favicon_test.go Updated as part of this pull request.
internal/modules/executor.go Updated as part of this pull request.
internal/modules/executor_test.go Updated as part of this pull request.
internal/modules/dsl.go Updated as part of this pull request.
internal/modules/dsl_test.go Updated as part of this pull request.
internal/modules/attack_modes_test.go Updated as part of this pull request.
internal/config/config.go Updated as part of this pull request.
go.mod Updated as part of this pull request.
docs/usage.md Updated as part of this pull request.
docs/modules.md Updated as part of this pull request.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +175 to +187
budget := opts.FuzzMaxRequests
for req := range streamRequests(target, cfg, paths, sets) {
if ctx.Err() != nil {
return
}
if budget > 0 && sent >= budget {
log.Warnf("fuzz: module %s hit the %d-request budget on %s (further combinations skipped)", def.ID, budget, target)
return
}
if !opts.FuzzGlobalBudget.Reserve() {
opts.FuzzGlobalBudget.warnOnce(def.ID, target)
return
}
Comment thread internal/modules/yaml.go
set := PayloadSet{Name: name}
switch v.Kind {
case yaml.ScalarNode:
set.File = v.Value
Comment thread internal/modules/dsl.go
Comment on lines +43 to +45
"to_lower", "to_upper", "trim", "trim_left", "trim_right", "trim_space",
"trim_prefix", "trim_suffix", "split", "join", "replace", "replace_regex",
"concat", "reverse",
Comment on lines +115 to +117
// DSL holds one or more boolean expressions evaluated against the response
// (dsl matchers only). Compiled and validated at module load.
DSL []string `yaml:"dsl,omitempty"`
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.

4 participants