Summary
A command injection vulnerability in Roxy-WI's configuration comparison endpoint allows authenticated users to inject arbitrary system commands into a template string that is later executed on the application host.
When attacker-controlled parameters are embedded directly into shell command templates, an authenticated user can pivot from web access to full command execution on the underlying server.
Affected context
This vulnerability affects Roxy-WI deployments that expose the /config/compare/<service>/<server_ip>/show endpoint to authenticated users.
The issue arises when user-supplied values for service and/or server_ip are interpolated directly into a command template in app/modules/config/config.py (around line 362), which is subsequently executed, likely via a shell.
Environments where Roxy-WI runs with high system privileges (e.g., root or broad sudo access) are at increased risk because successful exploitation translates directly into powerful system-level control.
Exploit preconditions
- Attack surface: HTTP(S) interface of the Roxy-WI application, specifically the
/config/compare/<service>/<server_ip>/showroute. - Required access: Valid authenticated access to Roxy-WI with the ability to reach the configuration comparison feature.
- Trigger point: Submission of crafted values in the path or parameters that are incorporated into the command template used for configuration comparison.
- Why exploitation is possible: User input is directly formatted into a template string that is used to build a shell command without proper escaping, validation, or use of a safe execution API, enabling injection of additional shell metacharacters and commands.
Why this happens
The underlying bug stems from constructing shell commands by concatenating or interpolating untrusted input into a command string that is later executed by the system.
This design matches CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') and is closely related to CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').
Instead of treating user input as opaque data passed to a parameterized execution API, the code builds a shell command line where user-controlled segments can introduce shell metacharacters, pipelines, or additional arguments.
Because the shell interprets these special characters, an attacker can escape the intended command context and execute arbitrary OS-level commands.
Potential impact
- Execution of arbitrary system commands under the privileges of the Roxy-WI process.
- Unauthorized access to sensitive configuration files and stored secrets on the host.
- Lateral movement to other services or infrastructure managed by Roxy-WI.
- Installation of backdoors, web shells, or other persistent malware on the host.
- Interference with HAProxy, Nginx, Apache, or Keepalived configurations, potentially causing outages or traffic hijacking.
- Use of the compromised server as a pivot point for broader network compromise.
General mitigation guidance
Effective mitigation focuses on eliminating direct shell command construction from untrusted input and hardening the execution model:
- Avoid shell invocation where possible: Prefer native language APIs or libraries (e.g., filesystem operations, diff libraries, configuration parsers) instead of calling external tools via the shell.
- Use parameterized execution: When external commands are unavoidable, use APIs that accept argument arrays (e.g.,
execve-style calls,subprocesswithshell=False), ensuring user input is treated purely as data. - Strict input validation: Constrain
service,server_ip, and similar parameters to well-defined formats (whitelists of known services, IP/hostname validation) and reject any unexpected characters. - Escape and encode cautiously: If shell usage is absolutely required, apply robust escaping mechanisms tailored to the target shell, while still combining this with strong validation and least privilege.
- Least-privilege execution: Run the Roxy-WI process under a dedicated, low-privilege account with minimal file system and network permissions to limit the blast radius in case of exploitation.
- Defense in depth: Use network segmentation, application-layer access controls, and logging/monitoring to detect and contain abnormal command execution behavior.
How teams detect issues like this
Identifying and preventing similar vulnerabilities can be approached through code-centric and operational measures:
- Static analysis: Configure SAST rules to flag:
- Use of shell-invoking APIs (
system,popen,subprocesswithshell=True, etc.) with string concatenation or formatting that includes variables derived from HTTP requests or user inputs. - Direct integration of URL path components or query parameters into command strings.
- Code review patterns: During manual review, scrutinize any code that:
- Constructs command lines using f-strings,
format, or string concatenation. - Uses unfiltered request-derived values (
service,server_ip, etc.) in OS-level operations. - Relies on shell features (pipes, redirection) instead of safer, library-based alternatives.
- Centralized security policies: Establish development guidelines that discourage shell command usage and mandate safe execution patterns, enforced via linters or pre-commit hooks.
- Runtime monitoring: Implement logging and monitoring of command execution events (e.g., process creation logs) and watch for unusual commands triggered by web requests or by the Roxy-WI process.
- Automated testing: Incorporate security-focused tests or fuzzing around routes that perform configuration comparisons or environment introspection to catch injection vectors.

