The analysis is based on the provided security advisory and the corresponding patch for the second-order SQL injection vulnerability in Admidio. The vulnerability existed because user-supplied data for list configurations was stored in the database with insufficient validation and later used in raw SQL query construction.
The function Admidio\Roles\Entity\ListConfiguration::addColumn served as the entry point, allowing malicious strings for column names (lsc_special_field), sort orders (lsc_sort), and filters (lsc_filter) to be saved to the database. The patch introduces strict allow-listing for column names and validates sort order values, preventing malicious data from being stored.
The primary exploitation occurs in two functions that read this stored data:
Admidio\Roles\Entity\ListConfiguration::getSql: This function retrieved the stored column and sort values and directly concatenated them into SELECT and ORDER BY clauses. The patch adds a defense-in-depth check against the same allowlist, ensuring that even if malicious data is already in the database, it is not used in the query.
Admidio\Roles\ValueObject\ConditionParser::makeSqlStatement: This function processed the stored filter conditions (lsc_filter). It was vulnerable because it built the WHERE clause by appending raw characters from the filter string. The patch remedies this by collecting the filter value and then applying proper escaping using $db->escapeString(), neutralizing any injected SQL syntax.
These three functions are the key runtime indicators for this vulnerability. An exploit would involve a call to addColumn to store the payload, followed by a call to getSql or makeSqlStatement (which is called by getSql) to trigger its execution.