CVE-2026-45089: Github.com/hahwul/dalfox/v2 Dalfox Server Mode Has An Vulnerability

HIGH
Advisory Identifier: GHSA-8hf9-3q64-q2qf
CVSS 8.2
CWE-434 CWE-306 CWE-73
Published
Advisory Summary

CVE-2026-45089 is a HIGH (CVSS 8.2) dalfox server mode has an vulnerability (CWE-434: Unrestricted Upload of File with Dangerous Type) affecting Github.com/hahwul/dalfox/v2 libraries in the Go ecosystem. The issue involves dalfox server mode has an unauthenticated arbitrary file create/append via `output` option. Remediation is available by upgrading affected packages to version 2.13.0.

CVE-2026-45089 at a Glance

CVE Identifier CVE-2026-45089
GHSA Identifier GHSA-8hf9-3q64-q2qf
Severity HIGH
CVSS v3.1 Base Score 8.2
CWE Classification CWE-434: Unrestricted Upload of File with Dangerous Type
Affected Product Github.com/hahwul/dalfox/v2
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 8.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability Low (A:L)

How to Fix CVE-2026-45089

To remediate this vulnerability, upgrade all affected Github.com/hahwul/dalfox/v2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/hahwul/dalfox/v2 fixed: 2.13.0
Upgrade github.com/hahwul/dalfox/v2 to 2.13.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/hahwul/dalfox/v2

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-45089, inspect your project dependencies for Github.com/hahwul/dalfox/v2:

inspect dependencies for github.com/hahwul/dalfox/v2

Analyze the terminal output to locate any version of Github.com/hahwul/dalfox/v2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.13.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-434: Unrestricted Upload of File with Dangerous Type, where the product allows the upload or transfer of dangerous file types that are automatically processed within its environment. In Github.com/hahwul/dalfox/v2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary When dalfox is run in REST API server mode, the `output`, `output-all`, and `debug` fields in `model.Options` are JSON-tagged and deserialized directly from the attacker's request body, then propagated unchanged through `dalfox.Initialize` into the scan engine's logging path. The logger opens the attacker-supplied path with `os.O_APPEND|os.O_CREATE|os.O_WRONLY` and writes scan log lines to it. Critically, this file write block lives outside the `IsLibrary` guard in `DalLog`, so it executes even in server/library mode where file output was never intended to operate. Because no API key is required in the default configuration, an unauthenticated network caller can create or append to any file writable by the dalfox process on the host filesystem. ## Severity **High** (CVSS 3.1: 8.2) `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L` - **Attack Vector:** Network — server binds to `0.0.0.0:6664` by default. - **Attack Complexity:** Low — no preconditions; all trigger options (`output`, `output-all`, `debug`) are fully attacker-supplied in the JSON body. - **Privileges Required:** None — `--api-key` defaults to `""`, so the auth middleware is never registered. - **User Interaction:** None. - **Scope:** Unchanged — the file write stays within the dalfox process's OS authority. - **Confidentiality Impact:** None — this is a write-only primitive; no data is returned to the caller. - **Integrity Impact:** High — the attacker has full control over which file path is opened, enabling creation of new files or corruption of existing files anywhere the dalfox process has write permission. While the log content format is semi-fixed, the file path is entirely attacker-determined, making the integrity violation complete with respect to file targeting. - **Availability Impact:** Low — corrupting application configuration files or log files on the host can degrade the availability of other services relying on those files. ## Affected Component - `cmd/server.go` — `init()` (line 51): `--api-key` defaults to `""` — no auth by default - `pkg/server/server.go` — `setupEchoServer()` (line 68): auth middleware only registered when `APIKey != ""` - `pkg/server/server.go` — `postScanHandler()` (lines 173–191): `rq.Options` (including `OutputFile`, `OutputAll`, `Debug`) passed to `ScanFromAPI` without sanitization - `lib/func.go` — `Initialize()` (line 107): `OutputFile` explicitly propagated from caller options; `OutputAll` (line 167) and `Debug` (line 176) likewise - `internal/printing/logger.go` — `DalLog()` (lines 230–244): `os.OpenFile(options.OutputFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)` executes outside the `IsLibrary` guard ## CWE - **CWE-306**: Missing Authentication for Critical Function - **CWE-73**: External Control of File Name or Path - **CWE-434**: Unrestricted Upload of File with Dangerous Type (write-path variant) ## Description ### `output`, `output-all`, and `debug` Are Fully Attacker-Controlled `model.Options` exposes all three trigger fields with JSON tags: ```go // pkg/model/options.go:88,85,88 OutputFile string `json:"output,omitempty"` OutputAll bool `json:"output-all,omitempty"` Debug bool `json:"debug,omitempty"` ``` `postScanHandler` binds the entire `Req.Options` from the JSON body and passes it directly to `ScanFromAPI`: ```go // pkg/server/server.go:173-191 rq := new(Req) if err := c.Bind(rq); err != nil { ... } go ScanFromAPI(rq.URL, rq.Options, *options, sid) ``` `Initialize` explicitly copies all three fields into `newOptions`: ```go // lib/func.go:107, 167, 176 "OutputFile": {&newOptions.OutputFile, options.OutputFile}, ... "OutputAll": {&newOptions.OutputAll, options.OutputAll}, ... "Debug": {&newOptions.Debug, options.Debug}, ``` ### The File Write Is Not Guarded by `IsLibrary` `Initialize` always sets `IsLibrary: true` (line 20) and `Silence: true` (line 44) in its returned options — the intent being that the scan engine runs in embedded/library mode during API calls, suppressing terminal I/O. `DalLog` does respect this for stderr output: lines 203–228 route logs to `ScanResult.Logs` (not stderr) when `IsLibrary` is true. However, the file write block at lines 230–244 is positioned **after and outside** that `if-else`: ```go // internal/printing/logger.go mutex.Lock() if options.IsLibrary { options.ScanResult.Logs = append(options.ScanResult.Logs, text) // API path } else { // stderr printing (CLI path) } // ← file write is here, unconditionally — no IsLibrary check if options.OutputFile != "" { var fdtext string if ftext != "" { fdtext = ftext f, err := os.OpenFile(options.OutputFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { fmt.Fprintln(os.Stderr, "output file error (file)") } defer f.Close() if _, err := f.WriteString(fdtext + "\n"); err != nil { fmt.Fprintln(os.Stderr, "output file error (write)") } } } mutex.Unlock() ``` The `ftext` variable is populated whenever `allWrite` is true (`options.Debug || options.OutputAll`). Since both are attacker-supplied, both conditions are trivially satisfied. ### What Gets Written Log lines of the form: ``` [*] Starting scan [SID:<id>] / URL: <attacker-supplied-url> [I] Checking BAV [E] connection refused [DEBUG] <internal state> ... ``` The URL appears verbatim in log messages, giving the attacker partial influence over the written content. While the format is not fully arbitrary (fixed prefixes like `[*] `, `[I] `, `[E] `), the **file path is entirely attacker-controlled**. The flags `O_CREATE` (creates the file if absent) and `O_APPEND` (never truncates) mean the attacker can: - Create new files at arbitrary paths - Append log content to existing files (corrupting configs, auth files, cron entries if the line happens to match syntax) ### No Defense at Any Layer The same opt-in API key gap applies here as in all prior findings: ```go // pkg/server/server.go:68-70 if options.ServerType == "rest" && options.APIKey != "" { e.Use(apiKeyAuth(options.APIKey, options)) } ``` There is no path allowlist, no `IsLibrary` guard on the file write, and no stripping of `OutputFile` from API-sourced requests anywhere in the codebase. ## Proof of Concept ```bash # Step 1 — Start dalfox REST server (default: no API key) go run . server --host 127.0.0.1 --port 16664 --type rest # Step 2 — Verify health (unauthenticated) curl -s http://127.0.0.1:16664/health # Expected: {"code":200,"msg":"ok"} # Step 3 — Trigger arbitrary file creation with attacker-controlled path curl -s -X POST http://127.0.0.1:16664/scan \ -H 'Content-Type: application/json' \ --data '{ "url": "http://127.0.0.1:1/?x=1", "options": { "output": "/tmp/dalfox_sink_poc.log", "output-all": true, "debug": true, "use-headless": false } }' # Step 4 — Verify file was created and written to by the dalfox process sleep 2 cat /tmp/dalfox_sink_poc.log # Expected: # [*] Starting scan [SID:...] / URL: http://127.0.0.1:1/?x=1 # [I] Checking BAV # [E] ... ``` No `X-API-KEY` header is required. Replace `/tmp/dalfox_sink_poc.log` with any path writable by the dalfox process: `/var/www/html/injected.txt`, `/etc/cron.d/dalfox`, `~/.ssh/authorized_keys` (appending log lines that won't break key format but pollute the file), etc. ## Impact - **Arbitrary file creation**: The attacker can create files at any path on the dalfox host filesystem accessible to the dalfox process, including web-serving directories, cron drop-in directories, and application config directories. - **Arbitrary file append/corruption**: Existing files can have log-format lines appended, degrading parsers that expect strict formats (sshd_config, crontab, /etc/hosts, application config files). - **Partial content control via URL**: The scan target URL appears verbatim in log output; combined with creative path targeting, this may enable injection into certain file formats. - **No authentication required** in the default deployment. - When dalfox runs under a privileged account (e.g., in a CI pipeline or as root in a container), the blast radius extends to system-wide files. ## Recommended Remediation ### Option 1: Strip filesystem-dangerous fields from API-sourced requests (preferred) Nullify all fields that touch the local filesystem before passing options to `ScanFromAPI`. This is the same remediation recommended for the `found-action` RCE and `custom-payload-file` file-read findings and should be applied as a single consolidated patch: ```go // pkg/server/server.go — in postScanHandler, before ScanFromAPI: rq.Options.OutputFile = "" rq.Options.OutputAll = false // safe to leave user value; file write is blocked by OutputFile="" rq.Options.CustomPayloadFile = "" rq.Options.CustomBlindXSSPayloadFile = "" rq.Options.FoundAction = "" rq.Options.FoundActionShell = "" rq.Options.HarFilePath = "" ``` ### Option 2: Guard the file write with `IsLibrary` in `DalLog` Move the `OutputFile` write block inside the `else` branch so it only executes in non-library (CLI) mode: ```go // internal/printing/logger.go — restructure the if-else: if options.IsLibrary { options.ScanResult.Logs = append(options.ScanResult.Logs, text) } else { // existing stderr printing logic... // file write belongs here, not after the if-else if options.OutputFile != "" && ftext != "" { f, err := os.OpenFile(options.OutputFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) ... } } ``` This fix addresses the root structural cause — the file write was intended for CLI mode only, and gating it on `!IsLibrary` matches that intent. Option 1 is still recommended as the primary fix; Option 2 adds defence-in-depth but requires care to not break legitimate CLI usage. ### Option 3: Require `--api-key` at server startup As with the other server-mode findings, making authentication mandatory eliminates the unauthenticated attack surface entirely: ```go // cmd/server.go — in runServerCmd: if serverType == "rest" && apiKey == "" { fmt.Fprintln(os.Stderr, "ERROR: --api-key is required when running in REST server mode.") os.Exit(1) } ``` All three options should be applied together. ##Credit Emmanuel David Github:- https://github.com/drmingler.

CVE-2026-45089 Affected Github.com/hahwul/dalfox/v2 Versions

1 component(s)
Fixed Versions:
2.13.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/hahwul/dalfox/v2
Go
< 2.13.0
2.13.0

References

Frequently Asked Questions

What is CVE-2026-45089?
CVE-2026-45089 is a security vulnerability in Github.com/hahwul/dalfox/v2 involving Dalfox Server Mode has an Unauthenticated Arbitrary File Create/Append via `output` Option under CWE-434: Unrestricted Upload of File with Dangerous Type.
Which Github.com/hahwul/dalfox/v2 versions are affected?
Affected versions include releases prior to 2.13.0 across affected packages: github.com/hahwul/dalfox/v2.
What version fixes CVE-2026-45089?
Upgrading to 2.13.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/hahwul/dalfox/v2 affected?
Yes, github.com/hahwul/dalfox/v2 is affected in releases prior to 2.13.0. Upgrade your dependency to 2.13.0 or later.
What is the CVSS score of CVE-2026-45089?
CVE-2026-45089 has a CVSS v3.1 base score of 8.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L.
What CWE is associated with CVE-2026-45089?
CVE-2026-45089 is classified under CWE-434: Unrestricted Upload of File with Dangerous Type (The product allows the upload or transfer of dangerous file types that are automatically processed within its environment.).
How can I check Go dependencies for CVE-2026-45089?
Run the dependency tree command: 'inspect dependencies for github.com/hahwul/dalfox/v2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8hf9-3q64-q2qf",
  "modified" : "2026-06-08T23:50:06Z",
  "published" : "2026-05-12T15:08:27Z",
  "aliases" : [ "CVE-2026-45089" ],
  "summary" : "Dalfox Server Mode has an Unauthenticated Arbitrary File Create/Append via `output` Option",
  "details" : "## Summary\n\nWhen dalfox is run in REST API server mode, the `output`, `output-all`, and `debug` fields in `model.Options` are JSON-tagged and deserialized directly from the attacker's request body, then propagated unchanged through `dalfox.Initialize` into the scan engine's logging path. The logger opens the attacker-supplied path with `os.O_APPEND|os.O_CREATE|os.O_WRONLY` and writes scan log lines to it. Critically, this file write block lives outside the `IsLibrary` guard in `DalLog`, so it executes even in server/library mode where file output was never intended to operate. Because no API key is required in the default configuration, an unauthenticated network caller can create or append to any file writable by the dalfox process on the host filesystem.\n\n## Severity\n\n**High** (CVSS 3.1: 8.2)\n\n`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L`\n\n- **Attack Vector:** Network — server binds to `0.0.0.0:6664` by default.\n- **Attack Complexity:** Low — no preconditions; all trigger options (`output`, `output-all`, `debug`) are fully attacker-supplied in the JSON body.\n- **Privileges Required:** None — `--api-key` defaults to `\"\"`, so the auth middleware is never registered.\n- **User Interaction:** None.\n- **Scope:** Unchanged — the file write stays within the dalfox process's OS authority.\n- **Confidentiality Impact:** None — this is a write-only primitive; no data is returned to the caller.\n- **Integrity Impact:** High — the attacker has full control over which file path is opened, enabling creation of new files or corruption of existing files anywhere the dalfox process has write permission. While the log content format is semi-fixed, the file path is entirely attacker-determined, making the integrity violation complete with respect to file targeting.\n- **Availability Impact:** Low — corrupting application configuration files or log files on the host can degrade the availability of other services relying on those files.\n\n## Affected Component\n\n- `cmd/server.go` — `init()` (line 51): `--api-key` defaults to `\"\"` — no auth by default\n- `pkg/server/server.go` — `setupEchoServer()` (line 68): auth middleware only registered when `APIKey != \"\"`\n- `pkg/server/server.go` — `postScanHandler()` (lines 173–191): `rq.Options` (including `OutputFile`, `OutputAll`, `Debug`) passed to `ScanFromAPI` without sanitization\n- `lib/func.go` — `Initialize()` (line 107): `OutputFile` explicitly propagated from caller options; `OutputAll` (line 167) and `Debug` (line 176) likewise\n- `internal/printing/logger.go` — `DalLog()` (lines 230–244): `os.OpenFile(options.OutputFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)` executes outside the `IsLibrary` guard\n\n## CWE\n\n- **CWE-306**: Missing Authentication for Critical Function\n- **CWE-73**: External Control of File Name or Path\n- **CWE-434**: Unrestricted Upload of File with Dangerous Type (write-path variant)\n\n## Description\n\n### `output`, `output-all`, and `debug` Are Fully Attacker-Controlled\n\n`model.Options` exposes all three trigger fields with JSON tags:\n\n```go\n// pkg/model/options.go:88,85,88\nOutputFile  string `json:\"output,omitempty\"`\nOutputAll   bool   `json:\"output-all,omitempty\"`\nDebug       bool   `json:\"debug,omitempty\"`\n```\n\n`postScanHandler` binds the entire `Req.Options` from the JSON body and passes it directly to `ScanFromAPI`:\n\n```go\n// pkg/server/server.go:173-191\nrq := new(Req)\nif err := c.Bind(rq); err != nil { ... }\ngo ScanFromAPI(rq.URL, rq.Options, *options, sid)\n```\n\n`Initialize` explicitly copies all three fields into `newOptions`:\n\n```go\n// lib/func.go:107, 167, 176\n\"OutputFile\": {&newOptions.OutputFile, options.OutputFile},\n...\n\"OutputAll\":  {&newOptions.OutputAll, options.OutputAll},\n...\n\"Debug\":      {&newOptions.Debug, options.Debug},\n```\n\n### The File Write Is Not Guarded by `IsLibrary`\n\n`Initialize` always sets `IsLibrary: true` (line 20) and `Silence: true` (line 44) in its returned options — the intent being that the scan engine runs in embedded/library mode during API calls, suppressing terminal I/O. `DalLog` does respect this for stderr output: lines 203–228 route logs to `ScanResult.Logs` (not stderr) when `IsLibrary` is true. However, the file write block at lines 230–244 is positioned **after and outside** that `if-else`:\n\n```go\n// internal/printing/logger.go\nmutex.Lock()\nif options.IsLibrary {\n    options.ScanResult.Logs = append(options.ScanResult.Logs, text)  // API path\n} else {\n    // stderr printing (CLI path)\n}\n\n// ← file write is here, unconditionally — no IsLibrary check\nif options.OutputFile != \"\" {\n    var fdtext string\n    if ftext != \"\" {\n        fdtext = ftext\n        f, err := os.OpenFile(options.OutputFile,\n            os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)\n        if err != nil {\n            fmt.Fprintln(os.Stderr, \"output file error (file)\")\n        }\n        defer f.Close()\n        if _, err := f.WriteString(fdtext + \"\\n\"); err != nil {\n            fmt.Fprintln(os.Stderr, \"output file error (write)\")\n        }\n    }\n}\nmutex.Unlock()\n```\n\nThe `ftext` variable is populated whenever `allWrite` is true (`options.Debug || options.OutputAll`). Since both are attacker-supplied, both conditions are trivially satisfied.\n\n### What Gets Written\n\nLog lines of the form:\n\n```\n[*] Starting scan [SID:<id>] / URL: <attacker-supplied-url>\n[I] Checking BAV\n[E] connection refused\n[DEBUG] <internal state>\n...\n```\n\nThe URL appears verbatim in log messages, giving the attacker partial influence over the written content. While the format is not fully arbitrary (fixed prefixes like `[*] `, `[I] `, `[E] `), the **file path is entirely attacker-controlled**. The flags `O_CREATE` (creates the file if absent) and `O_APPEND` (never truncates) mean the attacker can:\n- Create new files at arbitrary paths\n- Append log content to existing files (corrupting configs, auth files, cron entries if the line happens to match syntax)\n\n### No Defense at Any Layer\n\nThe same opt-in API key gap applies here as in all prior findings:\n\n```go\n// pkg/server/server.go:68-70\nif options.ServerType == \"rest\" && options.APIKey != \"\" {\n    e.Use(apiKeyAuth(options.APIKey, options))\n}\n```\n\nThere is no path allowlist, no `IsLibrary` guard on the file write, and no stripping of `OutputFile` from API-sourced requests anywhere in the codebase.\n\n## Proof of Concept\n\n```bash\n# Step 1 — Start dalfox REST server (default: no API key)\ngo run . server --host 127.0.0.1 --port 16664 --type rest\n\n# Step 2 — Verify health (unauthenticated)\ncurl -s http://127.0.0.1:16664/health\n# Expected: {\"code\":200,\"msg\":\"ok\"}\n\n# Step 3 — Trigger arbitrary file creation with attacker-controlled path\ncurl -s -X POST http://127.0.0.1:16664/scan \\\n  -H 'Content-Type: application/json' \\\n  --data '{\n    \"url\": \"http://127.0.0.1:1/?x=1\",\n    \"options\": {\n      \"output\": \"/tmp/dalfox_sink_poc.log\",\n      \"output-all\": true,\n      \"debug\": true,\n      \"use-headless\": false\n    }\n  }'\n\n# Step 4 — Verify file was created and written to by the dalfox process\nsleep 2\ncat /tmp/dalfox_sink_poc.log\n# Expected:\n# [*] Starting scan [SID:...] / URL: http://127.0.0.1:1/?x=1\n# [I] Checking BAV\n# [E] ...\n```\n\nNo `X-API-KEY` header is required. Replace `/tmp/dalfox_sink_poc.log` with any path writable by the dalfox process: `/var/www/html/injected.txt`, `/etc/cron.d/dalfox`, `~/.ssh/authorized_keys` (appending log lines that won't break key format but pollute the file), etc.\n\n## Impact\n\n- **Arbitrary file creation**: The attacker can create files at any path on the dalfox host filesystem accessible to the dalfox process, including web-serving directories, cron drop-in directories, and application config directories.\n- **Arbitrary file append/corruption**: Existing files can have log-format lines appended, degrading parsers that expect strict formats (sshd_config, crontab, /etc/hosts, application config files).\n- **Partial content control via URL**: The scan target URL appears verbatim in log output; combined with creative path targeting, this may enable injection into certain file formats.\n- **No authentication required** in the default deployment.\n- When dalfox runs under a privileged account (e.g., in a CI pipeline or as root in a container), the blast radius extends to system-wide files.\n\n## Recommended Remediation\n\n### Option 1: Strip filesystem-dangerous fields from API-sourced requests (preferred)\n\nNullify all fields that touch the local filesystem before passing options to `ScanFromAPI`. This is the same remediation recommended for the `found-action` RCE and `custom-payload-file` file-read findings and should be applied as a single consolidated patch:\n\n```go\n// pkg/server/server.go — in postScanHandler, before ScanFromAPI:\nrq.Options.OutputFile = \"\"\nrq.Options.OutputAll = false          // safe to leave user value; file write is blocked by OutputFile=\"\"\nrq.Options.CustomPayloadFile = \"\"\nrq.Options.CustomBlindXSSPayloadFile = \"\"\nrq.Options.FoundAction = \"\"\nrq.Options.FoundActionShell = \"\"\nrq.Options.HarFilePath = \"\"\n```\n\n### Option 2: Guard the file write with `IsLibrary` in `DalLog`\n\nMove the `OutputFile` write block inside the `else` branch so it only executes in non-library (CLI) mode:\n\n```go\n// internal/printing/logger.go — restructure the if-else:\nif options.IsLibrary {\n    options.ScanResult.Logs = append(options.ScanResult.Logs, text)\n} else {\n    // existing stderr printing logic...\n\n    // file write belongs here, not after the if-else\n    if options.OutputFile != \"\" && ftext != \"\" {\n        f, err := os.OpenFile(options.OutputFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)\n        ...\n    }\n}\n```\n\nThis fix addresses the root structural cause — the file write was intended for CLI mode only, and gating it on `!IsLibrary` matches that intent. Option 1 is still recommended as the primary fix; Option 2 adds defence-in-depth but requires care to not break legitimate CLI usage.\n\n### Option 3: Require `--api-key` at server startup\n\nAs with the other server-mode findings, making authentication mandatory eliminates the unauthenticated attack surface entirely:\n\n```go\n// cmd/server.go — in runServerCmd:\nif serverType == \"rest\" && apiKey == \"\" {\n    fmt.Fprintln(os.Stderr, \"ERROR: --api-key is required when running in REST server mode.\")\n    os.Exit(1)\n}\n```\n\nAll three options should be applied together.\n\n##Credit\n\nEmmanuel David\n\nGithub:- https://github.com/drmingler.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/hahwul/dalfox/v2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.13.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.12.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/hahwul/dalfox/security/advisories/GHSA-8hf9-3q64-q2qf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-45089"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/hahwul/dalfox"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hahwul/dalfox/releases/tag/v2.13.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-306", "CWE-434", "CWE-73" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-05-12T15:08:27Z",
    "nvd_published_at" : "2026-05-27T18:16:24Z"
  }
}