The vulnerability is a SQL injection in the datastore_search_sql action of CKAN's DataStore extension. The root cause is twofold. First, the is_single_statement function, which was supposed to prevent multiple SQL statements from being executed, could be bypassed. The sqlparse library used in this function handles escaped quotes differently than PostgreSQL, allowing an attacker to craft an input that sqlparse sees as a single statement but PostgreSQL interprets as multiple statements. The patch addresses this by explicitly checking for the problematic escape sequence (\') in the input SQL. Second, a dangerous PostgreSQL function ts_rewrite was allowed to be used in the SQL queries. This function could be abused to execute arbitrary SQL. The patch removed ts_rewrite from the list of allowed functions. The primary vulnerable function is datastore_search_sql as it's the user-facing action that accepts the malicious input. The is_single_statement function is also identified as vulnerable as it's the security control that failed to protect against the injection.