Summary
Dalfox's REST API server mode prior to 2.13.0 allows attackers to control log file paths via JSON options fields that are deserialized directly from client requests and passed into the logging subsystem.
Because these paths are opened for append/create without restriction and no API key is required by default, an unauthenticated remote attacker can create or append to any file writable by the dalfox process on the host filesystem.
Affected context
This vulnerability appears when Dalfox is deployed in REST API server mode and accepts JSON requests that populate model.Options, including output, output-all, and debug fields.
The issue is most relevant when the Dalfox server runs on hosts where its process user has write permissions to sensitive directories (for example, application configuration paths, log directories, or shared volumes).
It is exacerbated in environments where the REST API is reachable over a network (including internal networks) and is operated with the default configuration that lacks authentication or an API key requirement.
Exploit preconditions
- Attack surface: Dalfox REST API HTTP endpoint exposed over a network.
- Required access: No authentication in the default configuration; any network client that can reach the REST API can send crafted JSON.
- Trigger point: A scan request whose JSON body sets
output,output-all, ordebugto attacker-chosen file paths. - Why exploitation is possible: User-controlled file path fields are deserialized directly into options and propagated unchanged into the logging path. The logger opens these paths with
os.O_APPEND|os.O_CREATE|os.O_WRONLYoutside theIsLibraryguard, so file creation/appending occurs even in modes where file output was not intended, and no validation, sanitization, or access control is applied to the supplied paths.
Why this happens
The core issue is the direct use of client-supplied file path values in filesystem operations without validation or restriction, mapping to CWE-73: External Control of File Name or Path.
Dalfox's REST API server deserializes JSON request bodies into model.Options, including logging-related fields, and then passes them through dalfox.Initialize into the logging subsystem. The logger trusts these values and calls filesystem APIs with flags that create or append files.
This design mixes remotely supplied configuration with internal host-level file operations, and the safeguard (IsLibrary guard) that should prevent file I/O in certain modes does not enclose the vulnerable log-writing block.
Additionally, the absence of default authentication or API key enforcement (related to CWE-306: Missing Authentication for Critical Function) means attackers can invoke this behavior without prior access, and the ability to influence files that may later be executed or consumed by other components can resemble aspects of CWE-434: Unrestricted Upload of File with Dangerous Type at the pattern level.
Potential impact
- Remote creation of new files in directories writable by the Dalfox process.
- Remote appending to existing application or system log files, which could:
- Pollute logs with misleading entries.
- Interfere with monitoring or incident response.
- Overwriting or corrupting configuration files that rely on append semantics, potentially influencing behavior of Dalfox or other applications.
- Indirect code or command execution in scenarios where appended content is later interpreted by other services (for example, if logs are ingested into pipelines that execute commands based on log data).
- Lateral impact on multi-tenant or shared environments where Dalfox has access to common volumes.
General mitigation guidance
Effective mitigation centers on decoupling untrusted input from filesystem operations and narrowing the trust boundary around logging configuration.
Defensible patterns include:
- Treating all file paths derived from external clients as untrusted and disallowing them as direct inputs to file open calls.
- Restricting logging destinations to a predefined, server-side controlled set of paths or rotating strategies, rather than user-configurable paths in server mode.
- Introducing a strict separation between library/server modes and CLI behavior so that features intended for local CLI usage (like arbitrary output file paths) are disabled or heavily constrained when servicing remote requests.
- Enforcing robust authentication and authorization around any endpoint that can influence logging, configuration, or filesystem interaction, including API keys or tokens as a baseline.
- Running Dalfox under a dedicated, least-privileged system account whose writable directories are tightly scoped to non-sensitive locations, and using sandboxing or containerization to limit exposure of the host filesystem.
How teams detect issues like this
High-level detection practices for this type of vulnerability include:
- Static analysis: Configure rules to identify code paths where user-controlled fields are deserialized and used as arguments to filesystem APIs (e.g.,
os.OpenFile,os.Create), particularly when they bypass validation or normalization. Look for logging or configuration structs that accept arbitrary paths from external sources. - Code review signals: Flag patterns where REST API handlers map JSON or other request fields directly into logger or output configuration. Pay attention to mismatches between documented modes (e.g., library/server vs CLI) and actual guards enforcing behavior.
- Runtime monitoring: Enable application-layer logging to record when unexpected or non-standard log destinations are configured, and monitor filesystem activity to detect unusual file creation or modification originating from the Dalfox process.
- Policy enforcement: Apply organizational policies or CI checks that prohibit externally supplied file paths in server modes, and ensure that authentication requirements are enforced before endpoints that can affect logging or configuration are exposed.

