GHSA-v25v-m36w-jp4h Dalfox Server Mode Vulnerable to Unauthenticated Remote Code Execution via `found-action`
GHSA: Unauthenticated Remote Code Execution via `found-action` in Dalfox Server ModeSummaryWhen dalfox is started in REST API server mode (`dalfox server`), the server binds to `0.0.0.0:6664` by default and requires no API key unless the operator explicitly passes `--api-key`. Because `model.Options` — including `FoundAction` and `FoundActionShell` — is deserialized directly from attacker-supplied JSON in `POST /scan`, and because `dalfox.Initialize` explicitly propagates those two fields into the final scan options without stripping them, any unauthenticated caller who can reach the server port can supply an arbitrary shell command that the dalfox process will execute on the host whenever a scan finding is triggered.Severity**Critical** (CVSS 3.1: 10.0)`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H`**Attack Vector:** Network — the server binds to `0.0.0.0` by default; reachable by any network peer.**Attack Complexity:** Low — the attacker fully controls the scanned URL and can trivially host a one-line reflective server to guarantee a finding is triggered.**Privileges Required:** None — no API key is enforced in the default configuration.**User Interaction:** None.**Scope:** Changed — exploitation escapes the dalfox process boundary and executes arbitrary commands on the host OS.**Confidentiality Impact:** High — full read access to the host filesystem and secrets in the process environment.**Integrity Impact:** High — arbitrary file writes, code deployment, persistence mechanisms.**Availability Impact:** High — process kill, resource exhaustion, service disruption.Affected Component`cmd/server.go` — `init()` (line 51): `--api-key` defaults to `""``pkg/server/server.go` — `setupEchoServer()` (line 68): auth middleware only registered when `APIKey != ""``pkg/server/server.go` — `postScanHandler()` (lines 173–191): `rq.Options` passed to `ScanFromAPI` without sanitization`lib/func.go` — `Initialize()` (lines 118–119): `FoundAction` / `FoundActionShell` explicitly propagated from caller options`pkg/scanning/foundaction.go` — `foundAction()` (lines 17–18): `exec.Command(options.FoundActionShell, "-c", afterCmd)` executed unconditionallyCWE**CWE-306**: Missing Authentication for Critical Function**CWE-78**: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')**CWE-15**: External Control of System or Configuration SettingDescriptionOpt-in Authentication with a Dangerous Default`cmd/server.go` registers the `--api-key` flag with an empty string default:`setupEchoServer` only installs the `apiKeyAuth` middleware when that value is non-empty:A server started without `--api-key` accepts every request on every route with no challenge. The `apiKeyAuth` implementation itself is correct — the flaw is purely in the opt-in condition that makes authentication off by default.Attacker-Controlled `Options` Reaches Shell Execution Without Stripping`POST /scan` deserializes the full `model.Options` struct from the JSON body:`model.Options` exposes both execution-control fields as JSON-tagged properties:`ScanFromAPI` builds the scan target directly from `rqOptions` and passes it to `dalfox.Initialize`:`Initialize` explicitly copies both fields into `newOptions` — there is no stripping path:Shell Execution on Any Finding`foundAction` is called from seven locations across `pkg/scanning/scanning.go` and `pkg/scanning/sendReq.go` whenever `options.FoundAction != ""` and any vulnerability is detected. None of these call sites check `options.IsAPI`:Because the attacker supplies both the scan target URL and `found-action`, they trivially guarantee that a finding is produced (by hosting a one-line reflective server) and that the shell command is executed.Proof of ConceptNo `X-API-KEY` header is required. The reflective server ensures dalfox finds a vulnerability, which triggers `foundAction`.Impact**Unauthenticated remote code execution** on any host running `dalfox server` in its default configuration.Full read access to secrets, configuration files, and credentials visible to the dalfox process.Arbitrary file writes: persistence, backdoor installation, data exfiltration staging.Lateral movement using the dalfox host's network position and credentials.The default `0.0.0.0` bind address means exposure to all network interfaces, including public-facing ones in misconfigured cloud environments.Recommended RemediationOption 1: Require API key — make `--api-key` mandatory (preferred)Reject server startup when no API key is provided and emit a loud warning. This is the lowest-risk fix because it protects all current and future routes without code changes to the scan path.Option 2: Strip `FoundAction` / `FoundActionShell` from API-sourced requestsPrevent untrusted callers from setting execution-control options regardless of auth state. This adds defence-in-depth and protects authenticated deployments against credential theft.Both options should be applied together. Option 1 prevents unauthenticated access; Option 2 ensures that even authenticated callers (who may be external consumers of the REST API) cannot trigger host-level command execution.##CreditEmmanuel DavidGithub:- https://github.com/drmingler
CVSS v3.1 score: 10