GHSA-2g4x-fq3j-cgq4: Dalfox has an Unauthenticated Remote DoS via Closed-Channel Write in `ParameterAnalysis` (server mode)
Summary`ParameterAnalysis` in `pkg/scanning/parameterAnalysis.go` runs two sequential worker stages that both write to the same `results` channel. The channel is correctly closed after the first stage completes (`close(results)` at line 438), but the second stage — which processes POST-body parameters (`dp`) — is then launched with the same already-closed channel as its output. When a scanned parameter is reflected, `processParams` executes `results <- paramResult` on the closed channel, triggering a Go runtime panic that crashes the entire dalfox process. In server mode, the crash is remotely triggerable by any unauthenticated caller who can reach the REST API, because the default configuration has no API key and the second stage activates whenever `options.Data != ""` (i.e., the attacker supplies the `data` field) and the target reflects at least one parameter.Severity**High** (CVSS 3.1: 7.5)`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`**Attack Vector:** Network — server binds to `0.0.0.0:6664` by default; reachable by any network peer.**Attack Complexity:** Low — the attacker controls both trigger conditions: the `data` field that populates the second stage's work queue, and the target URL they point at a reflective server they control.**Privileges Required:** None — `--api-key` defaults to `""`, so no auth middleware is registered.**User Interaction:** None.**Scope:** Unchanged — a goroutine panic without a `recover` terminates the entire Go process; the impact stays within the dalfox process authority.**Confidentiality Impact:** None.**Integrity Impact:** None.**Availability Impact:** High — the entire dalfox server process crashes, requiring manual restart. A single well-timed request is sufficient.**Note on PR #917**: Commit `8a424d1` (`fix: resolve data race and nil pointer panic in processParams`) fixed two concurrent-safety bugs in `processParams` — a data race on `paramResult.Chars` and a nil pointer dereference on `resp.Header`. It did **not** fix the closed-channel panic reported here, which is a structural ordering bug in `ParameterAnalysis` itself, not inside `processParams`.Affected Component`pkg/scanning/parameterAnalysis.go` — `ParameterAnalysis()` (lines 436–448): `results` channel closed at line 438, then passed to second-stage `processParams` workers at line 445`pkg/scanning/parameterAnalysis.go` — `processParams()` (line 299): `results <- paramResult` panics when `results` is closedCWE**CWE-362**: Concurrent Execution Using Shared Resource with Improper Synchronization ('Race Condition') — channel lifecycle ordering error**CWE-404**: Improper Resource Shutdown or ReleaseDescriptionTwo-Stage Channel Lifecycle Ordering Error`ParameterAnalysis` allocates a single `results` channel shared by both worker stages:**First stage** (URL parameters in `p`):**Second stage** (POST-body parameters in `dp`):When a second-stage worker finds a reflected parameter, `processParams` sends to the closed channel:A Go runtime panic in a goroutine without a `recover` terminates the entire program. In server mode, this kills the dalfox API server process.Trigger Conditions Are Both Attacker-Controlled**Condition 1 — `dp` is non-empty**: `dp` (the POST-body parameter map) is populated in `addParamsFromWordlist` → `setP` whenever `options.Data != ""`:The attacker sets `"data": "q=test"` in the JSON body, which propagates through `Initialize` (`lib/func.go:106`). With `"mining-dict": true`, the entire GF-XSS wordlist (hundreds of parameters) flows into `dp`, ensuring the second stage has ample work.**Condition 2 — a parameter is reflected**: `processParams` sends to `results` only when `vrs` (verified reflection) is true (line 252 → line 299). The attacker controls the target URL — they point it at a server they operate that reflects any query parameter, guaranteeing `vrs = true` on the first matching entry from the wordlist.PR #917 Fixed Different BugsCommit `8a424d1` addressed:Data race: concurrent `append(paramResult.Chars, char)` with no mutex → added `charsMu sync.Mutex`Nil pointer: `resp.Header` accessed when `resp == nil` → added `&& resp != nil` guardNeither change touches the channel lifecycle in `ParameterAnalysis`. The closed-channel panic is independent and remains unpatched.Proof of ConceptNo `X-API-KEY` header is required. The reflective server is attacker-controlled and guarantees the `vrs = true` condition that triggers the channel write.Impact**Complete server process crash** on a single unauthenticated POST request — no login, no API key, no special permissions required.All in-flight scans are lost without results.The server requires a manual restart; under automated process managers (systemd, Docker `--restart=always`) repeated triggering can create a denial-of-service loop.The attack requires only network access to port 6664 and a reflective HTTP server reachable by the dalfox instance — both attacker-controlled conditions.Recommended RemediationOption 1: Allocate a fresh `results` channel for the second stage (preferred)The simplest and most direct fix: give each stage its own channel and consumer. The second stage should not reuse a channel that was created and closed for the first stage.Option 2: Merge both parameter maps before the single worker stageProcess `p` and `dp` entries through a single shared `paramsQue` and `results`, eliminating the two-stage design:This is a more invasive refactor but removes the structural root cause. The current two-stage design is the fundamental source of the ordering bug.Option 3: Add a `recover` in processParams goroutines (stopgap only)Catching the panic prevents the process from crashing but does not fix the lost results or the channel invariant violation. Recommended only as a temporary defensive measure while the channel lifecycle is corrected:Option 1 is the recommended primary fix. Option 3 should be combined with Option 1, not used as a substitute.CreditThis vulnerability was discovered and reported by [bugbunny.ai](https://bugbunny.ai).
CVSS v3.1: 7.5