The vulnerability is a time-based blind SQL injection in the article pricing module of OpenSTAManager. The analysis started by examining the provided vulnerability description, which pointed to the idarticolo parameter in the /ajax_complete.php endpoint as the source of the issue. The description detailed the execution flow, starting from /ajax_complete.php, which calls AJAX::complete, and then AJAX::getCompleteResults. This last function uses require to execute the script /modules/articoli/ajax/complete.php.
The vulnerability lies within this script, where a UNION SQL query is constructed. In the second part of the UNION, the $idarticolo variable, containing user-provided input, is concatenated directly into the query string without proper sanitization, while other variables in the same query are correctly sanitized using the prepare() function. This inconsistency is the root cause of the vulnerability.
To find the patch, I analyzed the commits between the vulnerable version 2.9.8 and the next available tag, v2.10-beta. A commit with the message 'fix: prevenzione sql injection' (bae00c0597b7a537569bec775f7999547f6dda9b) was identified. This commit contains a fix in /modules/articoli/ajax/complete.php that wraps the $idarticolo variable with the prepare() function, effectively mitigating the SQL injection vulnerability. The functions AJAX::complete and AJAX::getCompleteResults are identified as the vulnerable functions because they are the methods in the call stack that lead to the execution of the vulnerable script, and they would appear in a runtime profile during exploitation.