Severity by source
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
Injection originates from untrusted input reaching a parameterized DELETE/CTAS path, so AV:N/AC:L/PR:N/UI:N; full read, tamper, and destructive/availability impact yields C:H/I:H/A:H.
Primary rating from Vendor (vulncheck).
CVSS VectorVendor: vulncheck
Lifecycle Timeline
3DescriptionCVE.org
PyAthena prior to 3.35.4 contains a sql injection vulnerability that allows unauthenticated attackers to inject arbitrary SQL by exploiting improper quote-escaping in DefaultParameterFormatter.format(), which routes DELETE and CTAS statements to the _escape_hive function that backslash-escapes single quotes rather than doubling them. Because Athena and Trino do not treat backslashes as escape characters inside string literals, attacker-supplied input such as a single quote followed by SQL syntax causes the parser to terminate the string literal prematurely, enabling data exfiltration via UNION SELECT, execution of destructive statements, and attacker-controlled CTAS destination and content.
AnalysisAI
SQL injection in PyAthena before 3.35.4 lets remote unauthenticated attackers break out of parameterized string literals in DELETE and CTAS (CREATE TABLE ... AS SELECT) statements because DefaultParameterFormatter.format() routes these to the Hive escaper, which backslash-escapes single quotes instead of doubling them. Since Athena/Trino treat backslashes as ordinary characters inside string literals, a single quote in attacker-supplied input terminates the literal early and injects arbitrary SQL, enabling data exfiltration via UNION SELECT, destructive statement execution, and attacker-controlled CTAS output. There is no public exploit identified at time of analysis, but a fixing commit and vendor advisory are public.
Technical ContextAI
PyAthena is a Python DB-API 2.0 / SQLAlchemy client for AWS Athena, whose queries are executed by the Trino/Presto engine (for DML and CTAS) or the Hive DDL engine (for catalog/table DDL). The flaw is a CWE-89 SQL injection rooted in an escaper-selection bug: the pre-fix code chose _escape_presto only for statements literally beginning with SELECT/WITH/INSERT/UPDATE/MERGE and fell back to _escape_hive for everything else, silently including DELETE and CTAS. _escape_hive backslash-escapes single quotes (\'), which is correct only for the Hive lexer; Trino and Athena do not honor backslash as an escape character inside string literals, so the doubled-quote convention ('') is required. The fix (commit 27901d1) introduces _get_escaper with a Hive-statement allowlist regex, strips leading SQL comments before detection so a leading /* ... */ or -- comment cannot defeat statement typing, and defaults all other statements (including DELETE, CTAS, CREATE VIEW) to the safe Presto/Trino escaper.
RemediationAI
Vendor-released patch: upgrade PyAthena to 3.35.4 or later, which replaces the naive prefix check with _get_escaper() and safely defaults DELETE, CTAS, and CREATE VIEW statements to the quote-doubling Trino escaper (commit 27901d1); consult GHSA-xwj5-g6cv-4r5c and the VulnCheck advisory for details. If immediate upgrade is not possible, do not pass untrusted input into parameterized DELETE or CREATE TABLE ... AS SELECT / CREATE VIEW statements - instead validate and strictly allowlist any user-supplied values (reject single quotes and SQL metacharacters) before they reach cursor.execute with parameters, or restrict such statements to trusted internal callers; the trade-off is that input validation is error-prone and can break legitimate values containing quotes, so it is a stopgap rather than a fix. Additionally scope the IAM role used by Athena to least privilege so a successful injection cannot perform destructive DROP/CTAS actions or write to arbitrary S3 destinations, accepting that this limits blast radius but does not close the injection.
Same weakness CWE-89 – SQL Injection
View allShare
External POC / Exploit Code
Leaving vuln.today
EUVD-2026-52004