Skip to content

[Aikido] Fix SQL injection bypass in mysqli_execute_query parameter array handling - #502

Closed
aikido-autofix[bot] wants to merge 1 commit into
mainfrom
fix/code-audit-137914398-jc9u
Closed

aikido-autofix[bot] wants to merge 1 commit into
mainfrom
fix/code-audit-137914398-jc9u

Conversation

@aikido-autofix

@aikido-autofix aikido-autofix Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

This patch addresses a SQL injection vulnerability in the mysqli_execute_query function where the optional array parameter could bypass SQL injection enforcement. Previously, mysqli_execute_query was incorrectly routed to the generic mysqli_query handler, which did not properly parse the optional parameters array. A dedicated handler (handle_pre_mysqli_execute_query) has been implemented to correctly parse all parameters and ensure EVENT_PRE_SQL_QUERY_EXECUTED is triggered for all valid invocations. Changes were made to HandleQueries.cpp, Hooks.cpp, and HandleQueries.h to register and implement the new handler.

✅ 1 issue fixed by this PR
Issue Severity           Description
CodeAudit#811698351
HIGH
The procedural and object-oriented mysqli_execute_query registrations both invoke handle_pre_mysqli_query. That handler parses arguments with Os|l, so a valid third-argument array causes zend_parse_method_parameters to fail and the handler to return before assigning EVENT_PRE_SQL_QUERY_EXECUTED or caching the query. The generic wrapper leaves eventId as NO_EVENT_ID, treats that as CONTINUE, and invokes the original handler. Consequently, in an application that relies on the extension's blocking SQL-injection inspection and constructs any query fragment from attacker-controlled input before calling execute_query with an array, the query reaches the database without that enforcement. This is a product protection bypass; it does not create SQL injection in an otherwise safe application, so the severity is below a direct arbitrary SQL-injection finding.

@hansott hansott closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant