Summary
Authenticated SQL injection in Dolibarr's REST API allows malicious API clients to inject crafted SQL via the sqlfilters parameter on dictionary and multicurrency endpoints.
When these filters are concatenated into the WHERE clause with insufficient sanitization, an attacker can exfiltrate arbitrary database contents, including sensitive records, under typical authenticated API access conditions.
Affected context
This vulnerability appears in Dolibarr deployments that expose the REST API, particularly the setup dictionary and multicurrencies endpoints implemented in api_setup.class.php and api_multicurrencies.class.php.
It becomes relevant when authenticated API users can supply sqlfilters values that are directly incorporated into dynamically built SQL WHERE clauses.
The existing validation only checks for balanced parentheses and rewrites certain triplet patterns, leaving any text outside those patterns unaltered and potentially dangerous.
Exploit preconditions
- Attack surface: Dolibarr REST API, specifically dictionary and multicurrencies endpoints that accept
sqlfilters. - Required access: Valid authenticated API credentials with permission to call the affected endpoints.
- Trigger point: Submission of a crafted
sqlfiltersparameter that injects additional SQL fragments such asUNION SELECTor extended predicates. - Why exploitation is possible: The server-side logic performs limited syntactic checks (e.g., balanced parentheses and triplet rewriting) but does not properly parameterize or sanitize the remaining content, allowing attacker-controlled fragments to be concatenated directly into the SQL WHERE clause.
Why this happens
The core issue is dynamic SQL construction using untrusted user input embedded directly into query strings without proper parameterization.
In Dolibarr's API handlers, the sqlfilters parameter is only partially validated and then concatenated into the WHERE clause, trusting that remaining text is safe.
This pattern maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where application code fails to treat user-controlled query modifiers as data and instead allows them to function as executable SQL logic.
Potential impact
- Authenticated attackers may retrieve arbitrary database rows beyond their intended authorization scope.
- Sensitive information such as password hashes, API keys, and configuration secrets could be exposed.
- Business-critical records (customers, invoices, orders, financial data) can be enumerated and exfiltrated.
- Database reconnaissance and schema harvesting may be possible via injected queries.
- The vulnerability could aid in chaining attacks, such as credential cracking or lateral movement using leaked secrets.
General mitigation guidance
Effective mitigation focuses on eliminating direct concatenation of user-controlled values into SQL and reducing trust in client-supplied filter syntax.
Recommended patterns include:
- Use parameterized queries or query builders that represent filters as structured data (fields, operators, values) rather than raw SQL fragments.
- Introduce a strict allowlist model for filterable columns and accepted operators, validating each component independently.
- Normalize filtering logic so that client input is mapped to safe query parameters, not embedded SQL fragments.
- Apply least-privilege principles to API accounts and database roles so that even if a filter is abused, access is constrained.
- Prefer high-level search or filter APIs that abstract away SQL semantics from clients, reducing opportunities for injection.
How teams detect issues like this
Detection commonly relies on inspecting both code and runtime behavior:
- Static analysis rules targeting string-based SQL construction and direct inclusion of request parameters like
sqlfilters. - Manual code reviews focusing on API handlers that accept dynamic filter or search parameters and checking for parameterization.
- Centralized logging of SQL queries and API calls, with anomaly detection for unexpected
UNION, subqueries, or tautological predicates in generated SQL. - Security test automation, such as dynamic application security testing, that probes filter parameters for injection behavior during CI/CD.
- Policy enforcement that flags or blocks deployment of endpoints relying on raw SQL fragments from clients.

