Summary
Dolibarr's CSV and XLSX import wizard constructs SQL filters from submitted update-key values without verifying them against an allow-list. A user with import permission may exploit this behavior to read arbitrary database content and influence which record the import operation updates.
Affected context
The vulnerability occurs in Dolibarr deployments where the CSV or XLSX import wizard processes attacker-influenced update keys. The issue becomes risky when a user with import permission can submit crafted values and the server uses those values to build SQL conditions without restricting them to known column codes.
Exploit preconditions
- Attack surface: CSV/XLSX import wizard and its server-side update-key handling
- Required access: An authenticated account with permission to use the import functionality
- Trigger point: Processing imported records and constructing SQL filters for record lookup or updates
- Why exploitation is possible: Generic input filtering removes some markup but does not enforce an allow-list, allowing submitted values to influence SQL syntax and subsequent update targeting
Why this happens
The root cause is improper neutralization of user-controlled input used in SQL statements. Dolibarr accepts update-key values after applying a generic HTML-oriented filter, then concatenates those values into SQL conditions and executes the resulting query. Because the server does not verify that each key is one of the supported column codes, attacker-controlled syntax can alter query behavior. This maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Potential impact
- Arbitrary database records or fields may be disclosed
- The import process could select an attacker-influenced record identifier
- An unintended existing record may be overwritten
- Data integrity could be damaged through unauthorized updates
- Sensitive business information may be exposed
- Further compromise could become possible if database privileges are excessive
General mitigation guidance
Mitigation generally focuses on eliminating dynamic SQL construction from user-controlled field names and values.
Common defensive patterns include:
- Enforcing a strict server-side allow-list of supported import column codes
- Mapping external column names to fixed internal identifiers rather than inserting them into SQL
- Using parameterized queries for data values and safe query-builder abstractions for structural elements
- Validating input by expected type, format, and context before query construction
- Restricting database accounts to the minimum permissions required by import operations
- Separating read and update responsibilities where practical and applying authorization checks to target records
- Preserving audit logs for imports, query errors, and unexpected field names
How teams detect issues like this
Detection can combine source analysis, runtime monitoring, and policy enforcement:
- Search for concatenation of request parameters into SQL conditions, especially field names or filter fragments
- Flag generic sanitizers being used as substitutes for SQL parameterization or allow-list validation
- Review import handlers for missing server-side validation of supported column codes
- Use code-review rules that require parameterized queries and fixed mappings for dynamic identifiers
- Monitor database and application logs for anomalous import filters, query errors, unexpected unions, or unusual record-selection patterns
- Enforce CI policies that reject unapproved dynamic SQL construction and run automated security analysis

