The analysis began by examining the provided vulnerability description and reference URLs. The description clearly points to the sqliteDeleteRecord function in Netmaker's database layer as the source of a boolean-based SQL injection vulnerability, specifically stating that it 'constructs SQL DELETE statements using direct string concatenation of user-supplied input.'
Initial attempts to find the specific fixing commit by looking at the v1.5.0 release commit and comparing v1.4.0 and v1.5.0 did not immediately yield the direct code fix. The v1.5.0 commit primarily contained version bumps and release notes, indicating the actual functional fix was likely in an earlier commit merged into the v1.5.0 branch.
However, the content of the GHSA advisory (fetched from https://github.com/gravitl/netmaker/security/advisories/GHSA-r8cr-4f9w-7r75) provided highly specific and actionable details:
- Vulnerable function:
sqliteDeleteRecord
- Vulnerable file:
database/sqlite.go
- Vulnerable code pattern:
deleteSQL := "DELETE FROM " + tableName + " WHERE key = \"" + key + "\""
- Vulnerability flow:
logic.DeleteDNS → database.DeleteRecord → sqliteDeleteRecord
- Nature of the fix: 'replaces string concatenation with parameterised SQL queries'.
This explicit information from the official advisory is sufficient to confidently identify the vulnerable function. The vulnerability stems from the direct concatenation of user-supplied input (key) into the SQL query string within sqliteDeleteRecord without proper sanitization or the use of parameterized queries. This allows an authenticated attacker to inject SQL operators, leading to boolean-based SQL injection, as detailed in the advisory. When exploited, a runtime profiler would show sqliteDeleteRecord in the stack trace as it's the function directly responsible for constructing and executing the vulnerable SQL query.