Summary
A configuration injection flaw in Roxy-WI allows unvalidated JSON options to be written verbatim into generated HAProxy configuration files.
Authenticated low-privilege users can inject arbitrary HAProxy directives, including external-check commands, leading to remote code execution on managed load balancers.
Affected context
This vulnerability affects Roxy-WI deployments (version 8.2.6.4 and prior) that use the HAProxy management APIs to generate and push configuration to load balancers.
The issue arises when the HAProxy section-save endpoints accept a JSON option field that is neither validated nor escaped before being rendered into Ansible Jinja2 templates (section.j2, global.j2, and defaults.j2).
Any environment where authenticated users with role ≤ 3 can create or modify HAProxy sections is potentially exposed, especially when Roxy-WI is allowed to reload HAProxy via systemctl reload haproxy on remote servers.
Exploit preconditions
- Attack surface: Roxy-WI HTTP API endpoints:
POST /api/service/haproxy/<server_id>/section/<section_type>PUT /api/service/haproxy/<server_id>/globalPUT /api/service/haproxy/<server_id>/defaults- Required access: Valid Roxy-WI account with role ≤ 3 (user) and permission to manage at least one HAProxy instance in a group.
- Trigger point: Submission of crafted JSON payloads containing malicious
optionvalues, followed by Roxy-WI's normal workflow that:
- Renders configuration via the vulnerable Jinja2 templates.
- Pushes the resulting configuration to the HAProxy servers.
- Executes
systemctl reload haproxyon those servers.
- Why exploitation is possible: The
optionfield is treated as trusted text and inserted into HAProxy configuration files without validation or escaping.
HAProxy supports directives such as option external-check and external-check command that can execute shell commands, so arbitrary directives in the config can lead to code execution as the haproxy user.
Why this happens
The root cause is improper input validation and output encoding for configuration data that ultimately controls behavior of a privileged service.
Roxy-WI accepts attacker-controlled JSON fields (notably option) and injects them directly into HAProxy configuration templates (section.j2, global.j2, defaults.j2) without:
- Constraining values to a safe, known set of directives or formats.
- Sanitizing or escaping characters that alter configuration structure.
This aligns with CWE-20 (Improper Input Validation) and CWE-94 (Improper Control of Generation of Code), because the unvalidated user input influences generated configuration that, in turn, drives execution behavior.
Since HAProxy configuration can define external commands (e.g., via external-check command), the mis-handled configuration effectively becomes an execution vector analogous to command injection (CWE-77/CWE-78) mediated through server configuration.
Potential impact
- Remote code execution as the
haproxyuser on all affected load balancers in the compromised group. - Execution of arbitrary commands on every health-check tick, enabling persistence and repeated abuse.
- Unauthorized monitoring, exfiltration, or modification of traffic handled by the HAProxy instances.
- Pivoting to other internal services reachable from the load balancers.
- Unauthorized changes to HAProxy routing, health checks, or security-related directives, potentially causing outages or weakening defenses.
General mitigation guidance
Effective mitigation patterns focus on constraining what configuration can be generated and reducing the trust placed in user-supplied fields:
- Strong schema validation: Treat HAProxy configuration as a structured object model; validate incoming JSON against strict schemas that only allow known-safe directives and argument forms.
- Whitelisting allowed options: Replace free-form
optionfields with enumerated, typed configuration controls (e.g., drop-downs, booleans, numeric ranges) that map to allowed HAProxy directives. - Output encoding and separation of concerns: Ensure user-provided values are inserted only into safe locations (e.g., as literal strings where HAProxy expects data, not directives) and are properly escaped so they cannot introduce new directives.
- Least-privilege and control boundaries: Limit which user roles can influence global or defaults sections, and restrict the ability to push and reload configs to a smaller set of trusted administrators.
- Operational safeguards: Introduce review or approval workflows for configuration changes, including automated sanity checks that reject configs containing dangerous directives such as external command execution.
How teams detect issues like this
Detection can combine code-centric and operational approaches:
- Static analysis and code review:
- Flag templating patterns where user-controlled fields are rendered directly into configuration files without validation or escaping.
- Identify APIs that accept free-form configuration fragments (like
option) and verify they are constrained to safe values. - Policy-based checks:
- Implement pre-deployment validation that scans generated HAProxy configs for disallowed directives (e.g.,
external-check command, execution of shell commands) before pushing them to servers. - Enforce CI/CD policies that prevent configuration templates from accepting raw text that can alter control flow.
- Runtime monitoring:
- Monitor configuration change events from Roxy-WI and alert on modifications introducing external command execution or other high-risk directives.
- Track unusual
systemctl reload haproxyfrequency and inspect associated configuration diffs. - Automated tooling:
- Use configuration linters and security scanners tuned for HAProxy to detect unsafe directives in generated configs as part of a pipeline or scheduled audit.

