Summary
SOGo 5.12.7 contains a SQL injection vulnerability in the Access Control List (ACL) management functionality, where the uid parameter of the addUserInAcls endpoint is not safely handled.
Authenticated users can inject SQL subqueries that cause arbitrary data from the database to be written into the sogo_acl table and later retrieved via the /acls API, enabling out-of-band data exfiltration.
Affected context
This vulnerability appears in SOGo 5.12.7 within the ACL management features, specifically when processing requests to the addUserInAcls endpoint.
It becomes relevant in deployments where authenticated users are allowed to manage or modify ACL entries and where the uid value provided by the client is passed into SQL queries without robust parameterization or sanitization.
The issue manifests when user-controlled identifiers are incorporated into database operations that influence what is stored in the sogo_acl table and subsequently exposed via the /acls API.
Exploit preconditions
- Attack surface: HTTP(S) interface exposing SOGo's ACL management endpoints (e.g.,
/addUserInAclsand/acls). - Required access: Valid authenticated SOGo account with permission to invoke ACL-related operations.
- Trigger point: Supplying a crafted
uidparameter value to theaddUserInAclsendpoint such that it alters the structure or behavior of the underlying SQL statement. - Why exploitation is possible: The backend constructs SQL queries using user-supplied data in a way that does not enforce strict separation between query structure and data, enabling injected SQL subqueries to manipulate inserts into
sogo_acland to be read back through the/aclsendpoint.
Why this happens
The root cause aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command (SQL Injection).
In the vulnerable code path, the uid parameter from an ACL-related request is treated as a trusted value and incorporated into SQL statements without using safe parameter binding or thorough validation.
As a result, crafted input can break out of the expected data context and introduce additional SQL syntax, such as subqueries, that direct the database to copy arbitrary records into the sogo_acl table.
Because these records are later exposed through the /acls API, the injection becomes a practical channel for exfiltrating data that was never intended to be accessible through this interface.
Potential impact
- Authenticated users may be able to read sensitive data from arbitrary database tables by funneling it into the
sogo_acltable. - Attackers could infer or extract user account details, email metadata, or configuration records stored in the same database, depending on schema and privileges.
- Existing access control boundaries enforced at the application level can be bypassed, allowing retrieval of data not normally available to the attacker's role.
- SQL injection pathways can sometimes be extended to modify or corrupt ACL entries, potentially altering sharing permissions or access rights.
- Database confidentiality may be degraded if the technique is automated or leveraged at scale.
General mitigation guidance
Effective mitigation focuses on enforcing strict separation between SQL code and user-controlled data, and on narrowing the scope of what ACL operations are allowed to do:
- Use parameterized queries or prepared statements for all database operations involving the
uidand other request parameters, ensuring user input cannot change query structure. - Apply rigorous validation to ACL-related identifiers, such as restricting
uidto well-defined formats (e.g., canonical usernames or UUIDs) and rejecting any input that deviates from these constraints. - Introduce an explicit data access layer that limits what ACL management routines can query or write, avoiding generic "pass-through" SQL assembly in request handlers.
- Apply the principle of least privilege to the database account used by SOGo, reducing its ability to read or write unrelated tables or sensitive columns.
- Implement defense-in-depth controls like query whitelisting or ORM-level policies that disallow dynamic SQL fragments in ACL code paths.
These patterns reduce the likelihood that malformed input can influence SQL behavior and limit the blast radius if input handling fails.
How teams detect issues like this
Detecting this kind of SQL injection typically combines code-centric and behavior-centric approaches:
- Static analysis: Configure code scanning tools to flag string concatenation or interpolation in SQL statements, especially in ACL-related modules and wherever
uidor similar parameters are used. - Code review cues: During manual reviews, scrutinize any database access logic that handles ACL operations, focusing on whether all parameters are bound through prepared statements and whether input validation is centralized and consistent.
- Runtime monitoring: Enable database query logging or use an application security monitoring solution to detect atypical queries, such as those containing nested subqueries or unexpected references to unrelated tables originating from ACL endpoints.
- Security testing: Incorporate targeted tests into CI/CD (e.g., with DAST or specific SQL injection probes) against ACL APIs to verify that crafted input cannot alter query structure or leak data.
- Policy enforcement: Adopt development guidelines that prohibit ad-hoc SQL construction in request handlers and require use of vetted data access utilities or ORM layers.

