Skip to main content
COSMICBYTEZLABS
NewsSecurityHOWTOsToolsTraining
StudyProjectsNewsletterHire MeAbout
Subscribe

Press Enter to search or Esc to close

News
Security
HOWTOs
Tools
Training
Study
Projects
Newsletter
Hire Me
About
RSS Feed
Reading List
Subscribe

Stay in the Loop

Get the latest security alerts, tutorials, and tech insights delivered to your inbox.

Subscribe NowFree forever. No spam.
COSMICBYTEZLABS

Your trusted source for IT intelligence, cybersecurity insights, and hands-on technical guides.

2184+ Articles
157+ Guides

CONTENT

  • Latest News
  • Security Alerts
  • HOWTOs
  • Checklists
  • Projects
  • Exam Prep

RESOURCES

  • Search
  • Browse Tags
  • Newsletter Archive
  • Reading List
  • RSS Feed

COMPANY

  • About Us
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CosmicBytez Labs. All rights reserved.

System Status: Operational
  1. Home
  2. Security
  3. CVE-2026-65321: PyAthena SQL Injection via Improper Quote Escaping
CVE-2026-65321: PyAthena SQL Injection via Improper Quote Escaping

Critical Security Alert

This vulnerability is actively being exploited. Immediate action is recommended.

SECURITYCRITICALCVE-2026-65321

CVE-2026-65321: PyAthena SQL Injection via Improper Quote Escaping

A critical SQL injection vulnerability in PyAthena prior to 3.35.4 allows unauthenticated attackers to inject arbitrary SQL through improper quote-escaping in DefaultParameterFormatter, scoring CVSS 9.8.

Dylan H.

Security Team

August 3, 2026
2 min read

Affected Products

  • PyAthena < 3.35.4

Overview

CVE-2026-65321 is a critical SQL injection vulnerability in PyAthena, the popular Python DB API 2.0 client for Amazon Athena. Assigned a CVSS score of 9.8 (Critical), the flaw allows unauthenticated attackers to inject arbitrary SQL by exploiting improper quote-escaping logic in the library's default parameter formatter.

The vulnerability is patched in PyAthena 3.35.4. All prior versions are affected.

Technical Details

The root cause lies in DefaultParameterFormatter.format(), which routes DELETE and CTAS (Create Table As Select) statements to a private method called _escape_hive. This method backslash-escapes single quotes using a naive string replacement — a pattern that is insufficient for Athena's Hive-style SQL dialect.

An attacker can craft parameter values containing sequences that survive the backslash-escaping step and break out of the intended string context, injecting arbitrary SQL clauses.

Proof of Concept (Conceptual)

# Vulnerable: attacker-controlled value breaks out of string context
cursor.execute(
    "SELECT * FROM my_table WHERE id = %(id)s",
    {"id": "1'; DROP TABLE my_table; --"}
)
# _escape_hive fails to neutralize the payload in DELETE/CTAS paths

Attack Vector

  • Vector: Network
  • Authentication Required: None (unauthenticated)
  • Complexity: Low
  • Impact: High — arbitrary SQL execution against the caller's Athena environment

Because PyAthena connects to AWS Athena, successful exploitation can result in unauthorized data exfiltration, data destruction via DROP/DELETE statements, or creation of attacker-controlled tables in AWS S3-backed datasets.

Affected Versions

PackageAffected VersionsFixed Version
PyAthena (PyPI)All versions < 3.35.43.35.4

Remediation

Upgrade PyAthena to 3.35.4 or later immediately.

# Upgrade via pip
pip install --upgrade pyathena
 
# Verify installed version
pip show pyathena | grep Version
 
# Or with uv
uv pip install "pyathena>=3.35.4"

Additional Hardening

  1. Avoid raw string interpolation for Athena queries — always use parameterized queries.
  2. Restrict Athena IAM permissions to the minimum required (avoid DROP, DELETE grants for application roles).
  3. Audit query logs in AWS CloudTrail for unexpected DROP or DELETE statements.

References

  • NVD Advisory: CVE-2026-65321
  • PyAthena on PyPI
  • PyAthena GitHub Repository
#CVE#PyAthena#SQL Injection#Python#AWS Athena#Vulnerability

Related Articles

CVE-2026-63232: Koollab LMS SQL Injection and RCE via Unsafe Deserialisation

A critical CVSS 9.9 vulnerability in Koollab LMS allows authenticated attackers to exploit SQL injection and unsafe PHP deserialisation in the assessment reinforcement endpoint to write a webshell and execute arbitrary code.

2 min read

CVE-2026-12877: Critical SQL Injection in WordPress Project Management Plugin

An unauthenticated SQL injection flaw with a CVSS score of 9.1 affects the Project Management, Bug and Issue Tracking Plugin for WordPress before version...

3 min read

CVE-2026-16227: SQL Injection in SourceCodester Class and Exam Timetabling System

A remotely exploitable SQL injection vulnerability in SourceCodester Class and Exam Timetabling System 1.0 allows unauthenticated attackers to manipulate...

3 min read
Back to all Security Alerts