The vulnerability is a SQL injection in Pimcore's DataObject class definition functionality. The analysis of the provided patch in pull request #19108 reveals the root cause. An authenticated administrative user can define composite indices for DataObjects. The vulnerability stems from two key functions: Pimcore\Model\DataObject\ClassDefinition::setCompositeIndices and Pimcore\Model\DataObject\Traits\CompositeIndexTrait::updateCompositeIndices.
First, setCompositeIndices receives the index definitions, including index keys and column names, from the user. Before the patch, this function did not perform any validation or sanitization on these inputs.
Second, the unsanitized data is passed to updateCompositeIndices, which is responsible for creating and dropping database indices. This function constructed ALTER TABLE queries by directly concatenating the unvalidated index key and column names into the SQL statements. This allowed an attacker to inject arbitrary SQL commands by crafting a malicious index definition.
The patch addresses this vulnerability at two levels. It introduces a new assertValidIdentifier function to strictly validate the format of index keys and column names within both setCompositeIndices and updateCompositeIndices. Additionally, it modifies updateCompositeIndices to use the database's quoteIdentifier method, which properly escapes identifiers to prevent injection, thus neutralizing the threat. The vulnerable functions are the ones that previously handled the user input without proper validation and constructed the insecure SQL queries.