A critical (CVSS 9.8) SQL injection flaw in PyAthena versions up to and including 3.35.3 lets unauthenticated attackers inject arbitrary SQL through improperly escaped string literals in DELETE and CTAS statements.
What Is It
PyAthena, the Python DB API client for Amazon Athena maintained by laughingman7743, contains an SQL injection vulnerability (CWE-89) in DefaultParameterFormatter.format(). The formatter routes DELETE and CTAS (CREATE TABLE AS SELECT) statements to the _escape_hive function, which backslash-escapes single quotes instead of doubling them.
Athena and Trino do not treat backslashes as escape characters inside string literals. As a result, attacker-supplied input containing a single quote followed by SQL syntax terminates the string literal prematurely, and the remainder is parsed as SQL. No authentication, no privileges, and no user interaction are required.
Why It Matters
The vulnerability carries a CVSS 3.1 base score of 9.8 (CRITICAL) with vector AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H, and a CVSS 4.0 score of 9.3 (CRITICAL). Confidentiality, integrity, and availability impacts are all rated HIGH.
Per the advisory, successful exploitation enables:
- Data exfiltration via
UNION SELECTinjection - Execution of destructive statements against the data lake
- Attacker-controlled CTAS destination and content, meaning an attacker can dictate both where output is written and what it contains
Because PyAthena is a data-access library, injected SQL runs with whatever Athena permissions the application holds; typically broad read access across S3-backed tables.
What's Vulnerable
- Vendor: laughingman7743
- Product: PyAthena
- Affected versions: 0 through 3.35.3 (semver), default status affected
Applications are exposed where untrusted input reaches parameterized DELETE or CTAS statements through DefaultParameterFormatter.
Patch Status
The issue is fixed in PyAthena 3.35.4. Upgrade to 3.35.4 or later. A GitHub Security Advisory (GHSA-xwj5-g6cv-4r5c) has been published against laughingman7743/PyAthena.
One caveat on the fix reference: the remediation commit circulating with this advisory (27901d1) is hosted at github.com/pyathena-dev/PyAthena, not under the laughingman7743/PyAthena repository named as the vendor of record in the CVE and GHSA entries. Whether pyathena-dev/PyAthena is a fork, a mirror, or a relocated upstream is not established by the available sources. Defenders should treat the commit link as unconfirmed provenance and verify the fix against the released 3.35.4 artifact on PyPI and the advisory itself rather than relying on the commit URL alone.
CVE-2026-65321 does not currently appear in the CISA Known Exploited Vulnerabilities catalog; the supplied KEV entry is empty, so there is no confirmation of active exploitation and no federal remediation deadline at this time. The CVE record status is "Received," published 2026-08-02.