---
id: "CVE-2024-36039"
page: "https://infrastack.ai/live/CVE-2024-36039"
kind: "vulnerability"
aliases: ["CVE-2024-36039", "GHSA-v9hf-5j83-6xpp"]
title: "PyMySQL SQL Injection vulnerability"
severity: "critical"
cvss: 9.8
epss: 0.00691
exploited: false
status: "open"
category: "package"
products: [{"name": "pymysql", "fixed": ["1.1.1"], "affected": "< 1.1.1", "ecosystem": "pypi"}]
ecosystems: ["pypi"]
tags: ["cwe-89", "mysql", "package", "pymysql", "python"]
not_affected_if: ["no-json-keys-in-sql", "trusted-input-only"]
published_at: "2024-05-21T16:15:26+00:00"
first_seen_at: "2026-11-16T16:08:24+00:00"
updated_at: "2026-11-16T16:38:06+00:00"
sources: [{"source": "ghsa", "url": "https://github.com/advisories/GHSA-v9hf-5j83-6xpp", "first_seen_at": "2026-11-16T16:08:24+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-36039", "first_seen_at": "2026-11-16T16:38:06+00:00"}]
exploit_sources: [{"type": "epss", "score": 0.00691, "url": "https://api.first.org/data/v1/epss?cve=CVE-2024-36039"}]
---

# PyMySQL SQL Injection vulnerability

Link for people: https://infrastack.ai/live/CVE-2024-36039 (this .md is for agents)

PyMySQL's escape_dict function does not escape dictionary keys, so JSON input used as keys in a query can carry SQL. An attacker who controls that JSON can inject SQL and read or change database data.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- pypi:pymysql affected < 1.1.1 fixed 1.1.1

## How to check

- Check the installed version with `pip show pymysql`; versions below `1.1.1` are affected.
- Search the code for `escape_dict` or dict-based query parameters built from JSON input that is not trusted.

## Fix

- `pymysql` (pypi): move to `1.1.1`.

## Timeline

- 2026-11-16T16:08:24+00:00 ghsa https://github.com/advisories/GHSA-v9hf-5j83-6xpp
- 2026-11-16T16:38:06+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2024-36039

## Documents

- [fix] Release: github.com https://github.com/PyMySQL/PyMySQL/releases/tag/v1.1.1
- [fix] Patch: github.com https://github.com/PyMySQL/PyMySQL/commit/521e40050cb386a499f68f483fefd144c493053c

## From the sources

PyMySQL through 1.1.0 allows SQL injection if used with untrusted JSON input because keys are not escaped by `escape_dict`.

---

_Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai_
