Summary
Roxy-WI versions prior to 8.2.6.4 contain a SQL injection vulnerability where the server_ip value taken from the URL path is interpolated directly into SQL query strings.
An attacker who can send crafted HTTP requests to the Roxy-WI interface may execute arbitrary SQL commands against the application's database, which can lead to data exfiltration, modification, or complete compromise of the management platform.
Affected context
The vulnerability occurs in the haproxy_section_save route within app/routes/config/routes.py of Roxy-WI, where server_ip is read from the URL path and propagated through several functions without validation.
In deployments where the web interface is reachable to administrators or operators, any party capable of issuing HTTP requests to the affected route can influence the server_ip parameter that is later embedded into SQL statements.
Environments exposing Roxy-WI beyond a tightly controlled administrative network, or those with weak authentication and authorization controls, are particularly exposed to risk.
Exploit preconditions
- Attack surface: HTTP(S) interface of the Roxy-WI application.
- Required access: Ability to reach the Roxy-WI web interface and invoke the vulnerable
haproxy_section_savepath; authentication requirements depend on local configuration. - User-controlled input: The
server_ipsegment in the URL path is attacker-controlled and not normalized or constrained to IP syntax before being used. - Trigger point: The vulnerable code path that builds and executes SQL queries using Python string formatting with
server_ipembedded. - Why exploitation is possible: The parameter is passed unsanitized through multiple layers and concatenated directly into a SQL query string rather than being bound as a parameter, allowing crafted input to alter the structure of the SQL command.
Why this happens
This issue is caused by constructing SQL queries via string interpolation with untrusted data instead of using parameterized queries or a query builder.
The server_ip value originates from the URL path, is treated as trusted, and flows through several functions without validation or escaping, ultimately being embedded directly into a SQL statement using Python string formatting.
This pattern matches CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where user input is allowed to inject control characters (such as quotes, operators, and comment markers) that change the intended semantics of the SQL query.
The absence of robust input validation, strict typing, or ORM-level protections at the query construction layer enables attackers to transform a data field (an IP address) into executable SQL logic.
Potential impact
- Extraction of sensitive data from Roxy-WI databases, including configuration details and potentially credentials or connection information.
- Modification or deletion of configuration records for HAProxy, Nginx, Apache, and Keepalived, impacting load balancing and high-availability behavior.
- Creation of rogue configuration entries that may route traffic through attacker-controlled endpoints.
- Escalation of privileges within the application by altering access-control or user records stored in the database.
- Potential pivot to underlying infrastructure if database access leads to stored credentials or command-execution capabilities via backend features.
General mitigation guidance
Effective mitigation focuses on eliminating direct string concatenation in SQL construction and tightening the trust boundary around URL-derived parameters:
- Replace all ad-hoc SQL string formatting with parameterized queries or prepared statements provided by the database driver or ORM, ensuring that values like
server_ipare always bound as parameters. - Enforce strict validation and normalization on route parameters that represent structured data (such as IP addresses), rejecting values that do not conform to expected formats before they reach the data access layer.
- Centralize data access through a limited set of query-building utilities or an ORM layer, disallowing raw SQL construction in routing code wherever possible.
- Apply the principle of least privilege to the database account used by Roxy-WI so that even if a query is abused, the account cannot perform schema changes or access unrelated databases.
- Introduce secure-by-default coding guidelines that flag any concatenation of user input into query strings as a design defect, requiring explicit review and justification.
How teams detect issues like this
Detection can leverage both static and dynamic techniques:
- Static analysis: Configure linters or security-focused static analyzers to detect patterns of raw SQL string construction that embed variables (e.g., f-strings,
%formatting, orformat) in database-related code paths. - Code review signals: During review, treat any route handler or helper function that builds SQL with user-derived data as a high-risk area; ensure reviewers trace the data flow from HTTP parameters to data access calls.
- Policy enforcement: Establish CI checks that fail builds when new raw SQL construction patterns are introduced outside of an approved and vetted data access layer.
- Runtime monitoring: Where supported, enable database logging and anomaly detection to identify unusual query patterns, such as injected UNION clauses, stacked queries, or attempts to access system tables.
- Automated application security testing tools (SAST/DAST) can be integrated into the pipeline to probe for SQL injection behaviors on routes that accept path and query parameters.

