Summary
The Coturn HTTPS admin panel contains a SQL injection flaw where HTTP query parameters are interpolated directly into SQL statements without sanitization.
An authenticated administrator can inject arbitrary SQL via specific admin operations, leading to full database compromise and possible OS-level code execution in certain deployments.
Affected context
This vulnerability affects deployments of the Coturn HTTPS admin panel where administrators interact with delete-related operations such as delete-user, delete-secret, and delete-IP.
It becomes relevant when the server relies on a relational database backend and the admin interface is exposed to authenticated operators, particularly in environments where database privileges allow filesystem interaction or command execution (e.g., PostgreSQL COPY TO PROGRAM).
Exploit preconditions
- Attack surface: HTTPS admin panel endpoints handling delete operations (e.g., du, ds, dip parameters).
- Required access: Valid authenticated administrator access to the Coturn web administration interface.
- Trigger point: Submission of crafted HTTP query parameters that are directly formatted into SQL queries via snprintf.
- Why exploitation is possible: Input from HTTP query parameters is used in SQL string construction without proper sanitization or parameterization, and the existing is_secure_string filter is not applied to these admin operations.
Why this happens
The underlying issue is the construction of SQL queries by concatenating or interpolating user-supplied data into query strings, rather than using parameterized statements or robust escaping.
In the vulnerable code path, snprintf is used to embed HTTP query parameters directly into SQL, bypassing the is_secure_string filter applied elsewhere in the application.
This aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where special characters and control tokens in untrusted input can alter the structure and behavior of SQL statements.
Potential impact
- Authenticated administrators may execute arbitrary SQL commands against the Coturn database.
- Attackers could read, modify, or delete TURN user credentials, secrets, and configuration data.
- Database integrity and availability can be compromised, including dropping tables or altering schemas.
- In environments where the database supports shell interaction (such as PostgreSQL COPY TO PROGRAM), attackers could potentially gain OS-level code execution under the database service account.
- Pivoting to other systems that trust the compromised database may become possible.
General mitigation guidance
Mitigation generally focuses on eliminating direct string-based SQL construction and reducing trust in administrative inputs.
Recommended patterns include:
- Adopting parameterized queries or prepared statements for all database interactions, especially in administrative endpoints.
- Applying consistent input validation and normalization filters across all paths, including admin-only operations, rather than assuming admin input is inherently safe.
- Enforcing least-privilege roles for the database account used by the application, limiting its ability to perform filesystem or OS-level actions.
- Segregating administrative interfaces on dedicated network segments and protecting them with strong authentication and access control.
- Implementing defense-in-depth controls, such as database-level query auditing and restrictions on dangerous features like COPY TO PROGRAM where not strictly needed.
How teams detect issues like this
Detection efforts can focus on both code and runtime behavior:
- Static analysis rules to flag string interpolation into SQL queries, especially uses of snprintf, sprintf, or manual concatenation in database-related code.
- Code review checklists that explicitly require verification of parameterized queries and consistent use of validation filters for all admin endpoints.
- Application-level logging of admin actions and anomalous query patterns, such as unexpected use of SQL meta-commands or multi-statement submissions.
- Database security monitoring and auditing to detect suspicious queries, privilege escalations, or use of advanced features like COPY TO PROGRAM.
- Integration of automated security scanners or linters in CI pipelines to detect SQL injection patterns early in the development lifecycle.

