Daptin SQL Injection Vulnerability via Fuzzy Search
Daptin versions up to 0.11.4 are vulnerable to SQL injection, where an authenticated user can inject unvalidated column names into raw SQL via the `processFuzzySearch` function, allowing them to read the entire database.
Daptin versions up to and including 0.11.4 are susceptible to a SQL injection vulnerability within the processFuzzySearch function located in server/resource/resource_findallpaginated.go. This flaw allows any authenticated user, including those self-registered without administrative oversight, to inject arbitrary SQL commands by manipulating the column parameter during a fuzzy search. Specifically, when a GET request is made to /api/<entity> with the operator set to fuzzy, fuzzy_any, or fuzzy_all, the application fails to properly sanitize the column name before incorporating it into a raw SQL query. This vulnerability enables malicious actors to bypass column whitelists, potentially granting them unauthorized access to sensitive data within the entire database. The issue is distinct from the vulnerability patched in GHSA-rw2c-8rfq-gwfv and requires a separate patch to address the vulnerable fuzzy search path.
Attack Chain
- An attacker registers a new user account, leveraging the default self-signup feature which requires no admin approval.
- The attacker authenticates with the newly created account to obtain a valid JWT (JSON Web Token).
- The attacker crafts a malicious HTTP GET request to
/api/<entity>, setting theoperatorparameter tofuzzy(orfuzzy_any,fuzzy_all). - The attacker injects a SQL payload into the
columnparameter using string formatting. For example:reference_id) OR 1=1 OR LOWER(world.reference_id. - The crafted
columnparameter bypasses the column name whitelist check due to the execution path going throughprocessFuzzySearchinstead ofprocessQueryFilter. - The injected SQL payload is passed to
goqu.L, which incorporates it directly into a raw SQL query without proper sanitization. - The database executes the malicious SQL query, potentially leaking sensitive information or allowing for data manipulation.
- The attacker extracts data using boolean-blind SQL injection, exploiting the vulnerability to read data from all tables within the database, including credential data (emails, bcrypt password hashes) in the
user_accounttable.
Impact
Successful exploitation of this vulnerability allows an attacker with only a valid JWT to read the entire database via boolean-blind extraction. This includes sensitive information such as user credentials (emails and bcrypt password hashes). The self-signup feature of Daptin means that no administrative involvement is needed for an attacker to create an account and exploit this vulnerability. The extraction rate is approximately 7 HTTP requests per character, making full database extraction feasible.
Recommendation
- Apply the patch that adds a
GetColumnByNamewhitelist check inprocessFuzzySearch(line 1484) to prevent SQL injection via thecolumnparameter. - Implement input validation and sanitization for the
columnparameter in theprocessFuzzySearchfunction to prevent the injection of arbitrary SQL commands. - Deploy the Sigma rule “Daptin Suspicious Fuzzy Search Query” to detect potential exploitation attempts based on the presence of SQL syntax in the
queryparameter of HTTP requests to the/api/<entity>endpoint. - Monitor web server logs (logsource: webserver) for requests to
/api/worldor other entities that include thefuzzyoperator and contain suspicious characters or SQL syntax in thequeryparameter, as detected by the “Daptin Suspicious Fuzzy Search Query” rule.
Detection coverage 2
Daptin Suspicious Fuzzy Search Query
criticalDetects suspicious requests to the Daptin API with 'fuzzy' operator and potential SQL injection attempts in the query parameter.
Daptin User Account Signup Activity
lowDetects Daptin User account signup attempts which can be a precursor to vulnerability exploitation.
Detection queries are kept inside the platform. Get full rules →