Skip to main content

PyAthena CVE-2026-65321

| EUVDEUVD-2026-52004 CRITICAL
SQL Injection (CWE-89)
2026-08-02 disclosure@vulncheck.com
9.3
CVSS 4.0 · Vendor: vulncheck
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Reach app endpoint using PyAthena
  2. Delivery
    Submit single-quote-laden parameter to DELETE/CTAS query
  3. Exploit
    Hive escaper backslash-escapes quote
  4. Execution
    Trino terminates literal early
  5. Persist
    Injected UNION SELECT or destructive/CTAS SQL executes
  6. Impact
    Exfiltrate or destroy data

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Parameterized queries, prepared statements
MITRE ATT&CK

2 techniques across 2 tactics: Initial Access, Persistence

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Exploitation requires the embedding application to route attacker-controlled parameter values through PyAthena's DefaultParameterFormatter into a DELETE statement or a CTAS/CREATE VIEW statement (CREATE TABLE ... AS SELECT), which pre-3.35.4 were misrouted to the backslash-escaping _escape_hive function; SELECT/WITH/INSERT/UPDATE/MERGE were already handled safely and are NOT vulnerable. The concrete condition is a query whose statement type falls outside the old SELECT/WITH/INSERT/UPDATE/MERGE prefix allowlist yet is executed by Trino/Athena. Limiting factors: the attacker's input must reach one of these specific statement paths as a bound parameter, and the backend must be Athena/Trino (which ignore backslash escaping) rather than the Hive DDL engine; pure Hive DDL statements (CREATE EXTERNAL TABLE, DROP TABLE, MSCK REPAIR, SHOW/DESCRIBE) are not vulnerable because backslash escaping is correct there. Authentication requirements against the underlying app are not determinable from the library CVSS alone - CVSS PR:N reflects the injection source being untrusted input, not a confirmed unauthenticated app endpoint.

Impact

The provided CVSS 4.0 vector (AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H, base 9.3) indicates a network-reachable, low-complexity flaw with no privileges or user interaction and high confidentiality, integrity, and availability impact - consistent with the described data exfiltration, destructive DML, and attacker-controlled CTAS. However, real-world reachability is conditional: this is a library defect, so an attacker only benefits when a downstream application actually passes untrusted input into a parameterized DELETE or CTAS query through the vulnerable formatter path. No EPSS score, KEV entry, or POC was supplied, so the PR:N/AV:N rating reflects worst-case library exposure rather than confirmed mass exploitability; treat the 'unauthenticated network' framing as dependent on the embedding application's exposure. Given a confirmed fixing commit, a clear root cause, and high impact, this is a genuine priority for anyone running PyAthena in a path that parameterizes DELETE/CTAS with external input, but it is not confirmed as actively exploited.

Exploit ScenarioDerived

An application built on PyAthena exposes a data-management endpoint that deletes rows matching a user-supplied filter, e.g. cursor.execute("DELETE FROM t WHERE c = %(v)s", {"v": user_input}). The attacker submits a value like a' OR 1=1 -- ; because the pre-fix Hive escaper only backslash-escapes the quote, Trino terminates the string literal early and the injected clause executes, allowing mass deletion, a UNION SELECT exfiltration through a CTAS destination the attacker controls, or writing attacker-chosen content to an S3 location. No public exploit was identified at time of analysis, though the fixing commit and its tests illustrate the payload.

Act Now Prioritize within 24-48h. Why: CRITICAL severity.
No patch listed yet 0.4% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Aug 02, 2026

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.

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.

Affected VersionsENISA

PyAthena 0 ≤3.35.3

Affected Packages

euvd pyathena no fix

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in euvd

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

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.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (vulncheck) PRIMARY 9.3 CRITICAL
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
vuln.today AI 9.8 CRITICAL

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.

3.1 AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
4.0 AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N

Primary rating from Vendor (vulncheck).

CVSS VectorVendor: vulncheck

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
None
User Interaction
None
Vulnerable system: Confidentiality
High
Vulnerable system: Integrity
High
Vulnerable system: Availability
High
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

DescriptionCVE.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.

Executive ViewAI

Why It Matters

PyAthena, the Python client for Amazon Athena, contains a critical SQL injection vulnerability (CVSS 9.3) permitting remote unauthenticated attackers to extract sensitive data or corrupt database contents. No public exploit identified at time of analysis, but the vulnerability is highly exploitable and requires immediate mitigation. Organizations using PyAthena to query Amazon Athena data warehouses face urgent risk of data breach and integrity compromise without interim compensating controls.

Business Impact: Severe
Compensating Controls

No vendor-released patch identified at time of analysis. Interim mitigations: (1) enforce parameterized queries and input validation at the application layer independent of PyAthena; (2) restrict network access to Athena to authorized internal systems only; (3) implement detailed query monitoring and alerting for suspicious SQL patterns; (4) apply restrictive IAM policies limiting Athena principal permissions to minimal required datasets and operations; (5) enable and review CloudTrail logs for Athena API calls; (6) use read-only or limited-scope Athena credentials for PyAthena client connections.

Threat Intelligence Overview

EPSS Score
0.4%
Top 64% exploitable
Prevalence
Medium
popular Python client for AWS Athena, common in data-engineering stacks
Social Media
4
Sightings
Data Quality
7 sources
Confidence: High
EUVD NVD CVE.org EPSS Vulnrichment CIRCL GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity CRITICAL
CISA KEV No
Public POC No
EPSS 0.4%
Patch available No
Active threat No
Deciding rule
CRITICAL severity
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision
Out-of-Cycle
Exploitation
None
System Exposure· derived
Open
Automatable
Yes
Human Impact
Very High
Technical Impact
Total

Priority Score

46
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +46
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

SQL injection exploits the way applications construct database queries by mixing user input directly into SQL statements.

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy