# CVE-2026-65321: PyAthena SQL Injection via DefaultParameterFormatter DELETE/CTAS

> Attackers can inject arbitrary SQL via improper quote escaping in PyAthena, enabling data exfiltration and destructive database modifications.

- **Severity:** Critical 9.3 (`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`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 2 Aug 2026
- **Updated:** 6 Aug 2026
- **Also known as:** CLEANSTART-2026-DS89074, CLEANSTART-2026-WC06247, GHSA-xwj5-g6cv-4r5c

## What is CVE-2026-65321?

CVE-2026-65321 is a critical SQL injection vulnerability in laughingman7743 PyAthena, published on 2 Aug 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

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.

Weakness: CWE-89 (Improper Neutralization of Special Elements used in an SQL Command)

## Which versions are affected by CVE-2026-65321?


## How do I fix CVE-2026-65321?

Upgrade to a fixed version.

## Is CVE-2026-65321 being exploited?

There is no known exploitation of CVE-2026-65321 in the wild and no public exploit code.

Public exploit code:

- SQL injection in PyAthena via DefaultParameterFormatter (CVE-2026-65321) (github_poc): https://github.com/rahulreddykarne/CVE-2026-65321-pyathena

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-65321 and fix it if it is affected.

What it is: CVE-2026-65321 is a critical SQL injection vulnerability in laughingman7743 PyAthena, published on 2 Aug 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2026-65321 in the wild and no public exploit code.

Affected product: laughingman7743 PyAthena. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-65321/ (Markdown: https://insights.sbomify.com/CVE-2026-65321/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-65321
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-65321
- OSV: https://osv.dev/vulnerability/CVE-2026-65321

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-65321/
Summaries are generated and may contain mistakes; the official description above is the record.
