Repository navigation
[Aikido] Fix SQL injection bypass in mysqli_execute_query parameter array handling - #502
Closed
aikido-autofix[bot] wants to merge 1 commit into
Closed
aikido-autofix[bot] wants to merge 1 commit into
aikido-autofix[bot] wants to merge 1 commit into
Conversation
…te_query by adding...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.