Summary
Roxy-WI's WAF rule save endpoint allows attackers to control the destination path of configuration writes with only minimal substring checks, enabling arbitrary file creation on the load balancer.
By writing crafted cron files or other executable configuration, an attacker can achieve remote code execution as root on affected load balancers under conditions where they can call the vulnerable endpoint.
Affected context
The vulnerability appears in Roxy-WI deployments that expose the WAF rule management feature and rely on the backend to safely constrain where rule files are written.
It specifically affects the POST /waf/<service>/<server_ip>/rule/<rule_id>/save endpoint, where the config_file_name form field is used to construct a filesystem path.
The flawed validation only checks for the presence of certain service-related substrings (e.g., nginx, haproxy, apache2, httpd, keepalived) and configuration-related substrings (conf, cfg), while forbidding the literal ..., but it does not adequately restrict absolute paths or enforce directory confinement.
Because encoded slashes (92) are converted to / before validation, attackers can still generate arbitrary absolute paths on the load balancer that meet these superficial substring requirements.
Exploit preconditions
- Attack surface: The vulnerable interface is the HTTP endpoint
POST /waf/<service>/<server_ip>/rule/<rule_id>/saveexposed by Roxy-WI. - Required access: The attacker must be able to send authenticated or otherwise accepted requests to this WAF configuration endpoint in a Roxy-WI instance managing one or more load balancers.
- Trigger point: During request handling, the
config_file_nameform field is passed directly intoconfig_mod.master_slave_upload_and_restart(...)as the destination path, after applying a92→/substitution and minimal substring checks. - Why exploitation is possible: The validation chain (
_replace_config_path_to_correct→check_is_conf) does not enforce that paths remain within a dedicated configuration directory or prevent arbitrary absolute paths; it merely checks for certain substrings and the absence of.... By using encoded slashes and including required substrings in a crafted filename, an attacker can cause the WAF rule content (configfield) to be written as a file in sensitive locations such as/etc/cron.d/, where content is later executed by system components likecron.
Why this happens
The underlying issue is a combination of insufficient input validation and improper restriction of filesystem paths, aligning primarily with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') and CWE-73: External Control of File Name or Path.
Instead of constraining config_file_name to a fixed, server-controlled directory and sanitizing user input, the code implicitly trusts the client-provided path, performing only naive substring checks for service names and configuration-related tokens.
Additionally, the preprocessing step that replaces the magic sequence 92 with / allows bypassing straightforward validation logic that does not reason about the decoded path structure.
Because the resulting file is treated as a configuration artifact and may be consumed by privileged processes (e.g., cron), this arbitrary file write escalates into CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), as the system executes attacker-controlled commands indirectly via scheduled jobs.
Overall, the bug class is "arbitrary file write due to path traversal and weak validation," where external input controls both the file location and content without proper normalization, canonicalization, or directory confinement.
Potential impact
- Creation of arbitrary files anywhere on the load balancer filesystem that satisfy simple substring constraints
- Dropping malicious cron jobs in
/etc/cron.d/or equivalent, leading to command execution as root - Persistent remote code execution on all managed load balancers grouped under the compromised Roxy-WI account or tenant
- Tampering with web server, load balancer, or WAF configurations (e.g., HAProxy, Nginx, Apache, Keepalived) to reroute traffic or weaken security controls
- Planting backdoors or modifying startup scripts for long-term compromise of infrastructure
General mitigation guidance
Mitigation should focus on tightening how file paths are derived from user input and reducing the privileges associated with configuration operations.
Harden path handling and confinement
- Derive the destination path for WAF rules from server-side configuration only, treating any user-supplied filename as a simple, extension-checked basename rather than a full path.
- Enforce strict directory confinement by resolving paths to their canonical form and rejecting any that do not reside within an expected configuration directory tree.
- Remove or avoid custom encodings like
92→/for path construction; instead, use standard path utilities and avoid any mechanism that allows encoding directory separators. - Apply allowlists for filenames and extensions (e.g.,
.conf), and strip or reject characters commonly used in path manipulation.
Reduce execution and privilege risk
- Run Roxy-WI and its helper processes under a dedicated, least-privileged system account that cannot write to globally sensitive directories such as
/etc,/etc/cron.d, or system-wide configuration locations. - Separate configuration directories for user-managed WAF rules from directories consumed directly by privileged daemons (e.g., cron, systemd), and ensure those daemons are not configured to process arbitrary files from user-writable locations.
- Introduce defense-in-depth checks so that any file destined to be consumed by system services (e.g., cron or web servers) is generated or vetted exclusively by trusted server-side components, not directly from client input.
Process and design measures
- Treat configuration upload endpoints as high-risk and subject them to rigorous security review, including threat modeling around "user controls filename and path."
- Document and enforce a clear boundary between "configuration data" and "execution paths," ensuring that user-originated configuration cannot trivially become code or commands.
How teams detect issues like this
Organizations can use a mix of code-level analysis and operational monitoring to detect this class of vulnerability and potential exploitation:
Static and code review signals
- Search for code paths where user-controlled parameters (HTTP form fields, query parameters, JSON fields) are passed into file-related functions or helpers (e.g.,
open,write,upload_and_restart) without strict validation or canonicalization. - Flag any logic that performs custom substring-based path checks or non-standard encoding/decoding of path separators (
/,\) instead of using robust path libraries. - Use static analysis rules targeting CWE-22/CWE-73 patterns such as "external input → path join → file write," especially when combined with privileged directories or configuration reloads.
- During code review, pay special attention to endpoints that can modify configuration and then trigger restarts or reloads of services, as these often provide indirect code execution paths.
Runtime and operational monitoring
- Enable audit logging around configuration changes via Roxy-WI, including which user initiated a WAF rule save, the target service, and the final resolved filesystem path.
- Monitor sensitive directories (e.g.,
/etc/cron.d, web server config directories) for unexpected new files or changes originating from the Roxy-WI process user or at atypical times. - Deploy host-based intrusion detection systems (HIDS) or EDR solutions configured to flag new cron entries, executable scripts, or config files that deviate from a baseline.
Automated tooling
- Integrate security-focused linters or SAST tools into CI pipelines to automatically highlight instances of external path control and arbitrary file writes.
- Use configuration scanning tools or policy-as-code frameworks to ensure that application service accounts do not have write access to critical system directories where configuration implies code execution.

