Summary
Dalfox's REST API server mode previously allowed client-supplied file paths in the custom-payload-file option to be used directly as sources for XSS payloads.
An unauthenticated network attacker could point this option at arbitrary files on the Dalfox host, causing their contents to be read and exfiltrated line-by-line via outbound scan traffic to attacker-controlled targets.
Affected context
This vulnerability affects environments where Dalfox is run in REST API server mode and exposed to a network where untrusted clients can send scan requests.
The issue manifests when:
- The
custom-payload-filefield is accepted directly from client JSON input, - The Dalfox process has read access to sensitive files on the host (e.g., configuration files, SSH keys, tokens, or logs),
- Outbound HTTP scan traffic is allowed to reach attacker-controlled domains, enabling the attacker to observe payload content.
It is most concerning when Dalfox runs on shared security tooling servers, CI agents, or other hosts that store secrets and sensitive configuration.
Exploit preconditions
- Attack surface: Dalfox REST API endpoint that accepts scan configuration (including
custom-payload-file) over HTTP. - Required access: Network access to the Dalfox REST API server; no API key or authentication is required by default.
- Trigger point: Submitting a scan request where
custom-payload-fileis set to a path pointing to a file readable by the Dalfox process. - Why exploitation is possible:
- The
custom-payload-filefield is bound directly from JSON into internal options without validation. - The scan engine passes this path to
voltFile.ReadLinesOrLiteral, which reads contents from the specified file on disk. - Each line from the file is then used as a payload in outbound HTTP requests to attacker-controlled URLs, effectively leaking file contents via the network.
Why this happens
The core issue is the unrestricted propagation of user-controlled file paths into file read operations without validation or access control, aligning with CWE-73: External Control of File Name or Path.
In Dalfox's REST API mode, the custom-payload-file field is:
- Directly deserialized from client JSON into
model.Options, - Passed through
dalfox.Initializeinto the scan engine without sanitization or whitelisting, - Used by
voltFile.ReadLinesOrLiteralto open and read arbitrary host files.
This design treats externally supplied file paths as trusted configuration, conflating client-supplied parameters with local operator-controlled settings.
The lack of authentication (related to CWE-306) and inadequate protection of host-resident data (related to CWE-552) amplify the impact, but the primary bug class is uncontrolled file path usage in a server-facing API.
Potential impact
- An attacker may read the contents of arbitrary files that the Dalfox process can access, including:
- Application configuration files
- API keys, tokens, or credential files
- SSH private keys or deployment keys
- Source code or internal scripts
- Sensitive data could be exfiltrated line-by-line through scan payload traffic to attacker-controlled endpoints.
- Attackers can gain insights into internal network architecture, service endpoints, or debug logs.
- Exfiltrated secrets may enable lateral movement, further compromise of infrastructure, or impersonation of services.
- Security tooling integrity can be undermined, eroding trust in scan results and the platform hosting Dalfox.
General mitigation guidance
Durable mitigation focuses on separating untrusted client input from local file system operations and hardening access controls around the API:
- Treat all file-path-related options as privileged configuration, not as user input in a remote API; avoid exposing them directly over network-facing interfaces.
- When file-based configuration is necessary, restrict paths to:
- A fixed, application-controlled directory, and
- A known allowlist of filenames or patterns.
- Replace generic file path parameters with higher-level identifiers (e.g., named payload sets) that map to pre-configured resources.
- Enforce authentication and authorization for the REST API, ensuring only trusted callers can initiate scans and influence configuration-like parameters.
- Run Dalfox under a dedicated, least-privileged OS account with minimal file system access, and avoid co-locating sensitive secrets on the same host.
- Consider segregating outbound scan traffic so it cannot be used as a high-bandwidth exfiltration channel (e.g., proxy controls, domain allowlists).
These patterns reduce the blast radius even if an attacker can interact with the API.
How teams detect issues like this
Detection typically combines configuration review, code analysis, and behavioral monitoring:
- Static analysis and code review:
- Flag code paths where HTTP/JSON request fields are directly mapped to file system operations such as
open,ReadFile, or similar abstractions. - Look for API models that expose configuration-like file path fields (e.g.,
*File,Path,Config) without validation or restriction. - Review REST handlers for the use of options structs that were originally intended for CLI-only use.
- Configuration and deployment checks:
- Validate that REST API endpoints are not publicly exposed or are protected by authentication and network controls.
- Check runtime permissions of the Dalfox process (e.g., whether it has access to system-wide secret directories).
- Runtime monitoring:
- Monitor for suspicious scan requests where
custom-payload-fileor similar fields reference unexpected paths (e.g.,/etc/passwd,/home/*/.ssh/*). - Inspect outbound scan traffic for payloads containing internal file content patterns, secrets, or configuration fragments.
- Automated security testing and SAST tools can be configured with rules to detect externally controlled file paths and missing authentication controls in API handlers.

