{"id":"CVE-2024-36039","kind":"vulnerability","aliases":["CVE-2024-36039","GHSA-v9hf-5j83-6xpp"],"related":[],"title":"PyMySQL SQL Injection vulnerability","description":"PyMySQL through 1.1.0 allows SQL injection if used with untrusted JSON input because keys are not escaped by `escape_dict`.","summary":"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.","severity":"critical","cvss":9.8,"epss":0.00691,"exploited":false,"exploited_at":null,"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"],"how_to_check":"- Check the installed version with `pip show pymysql`; versions below `1.1.1` are affected.\n- 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`.","status":"open","published_at":"2024-05-21T16:15:26+00:00","first_seen_at":"2026-11-16T16:08:24+00:00","triaged_at":"2026-11-16T16:08:53+00:00","updated_at":"2026-11-16T16:38:06+00:00","category":"package","confidence":0.8,"triage":{"at":"2026-11-16T16:08:53Z","model":"claude-haiku-5-5","output":{"fix":"- `pymysql` (pypi): move to `1.1.1`.","reach":"internet","title":"PyMySQL: JSON keys are not escaped, allowing SQL injection","impact":"high","summary":"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.","audience":"developers","category":"package","nicknames":[],"who_cares":["python","pymysql","mysql"],"confidence":0.8,"fix_status":"available","needs_auth":"unknown","worst_case":"attacker injects SQL and reads or changes database data","analyst_note":"","how_to_check":"- Check the installed version with `pip show pymysql`; versions below `1.1.1` are affected.\n- Search the code for `escape_dict` or dict-based query parameters built from JSON input that is not trusted.","plain_action":"","product_name":"","needs_analyst":false,"not_affected_if":["trusted-input-only","no-json-keys-in-sql"],"who_is_affected":"Applications that use PyMySQL and build SQL from dictionary keys that come from untrusted JSON are exposed. Apps that only pass fixed keys or trusted data can skip the change, but upgrading to 1.1.1 is still the stated fix.","user_interaction":"no","product_ecosystem":"","needs_special_setup":"yes","severity_if_unknown":"unknown"},"cost_usd":0.000711,"input_tokens":4562,"output_tokens":510,"severity_before":"critical"},"analyst_status":null,"analyst_note":null,"search":"'-2024':6A,14A '-36039':7A,15A '-89':18B '1.1.0':62C '5j83':11A '6xpp':12A 'allow':63C 'attack':46B 'carri':43B 'chang':57B 'control':48B 'cve':5A,13A 'cwe':17B 'data':59B 'databas':58B 'dict':26B,79C 'dictionari':31B 'escap':25B,30B,76C,78C 'function':27B 'ghsa':9A 'ghsa-v9hf-5j83-6xpp':8A 'inject':3A,52B,65C 'input':35B,71C 'json':34B,50B,70C 'key':32B,38B,73C 'mysql':19B 'packag':20B 'pymysql':1A,16A,21B,23B,60C 'python':22B 'queri':41B 'read':55B 'sql':2A,44B,53B,64C 'untrust':69C 'use':36B,67C 'v9hf':10A 'vulner':4A","nicknames":[],"mitigations":[],"who_affected":"Applications that use PyMySQL and build SQL from dictionary keys that come from untrusted JSON are exposed. Apps that only pass fixed keys or trusted data can skip the change, but upgrading to 1.1.1 is still the stated fix.","tier":"B","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"developers","plain_action":null,"pkeys":["pymysql"],"ptokens":["pymysql"],"labels":["critical","cwe89","mysql","package","pymysql","pypi","python"],"campaign_type":null,"search_a":"'-2024':6A,14A '-36039':7A,15A '5j83':11A '6xpp':12A 'cve':5A,13A 'ghsa':9A 'ghsa-v9hf-5j83-6xpp':8A 'inject':3A 'pymysql':1A,16A 'sql':2A 'v9hf':10A 'vulner':4A","search_b":"'-89':18B 'attack':46B 'carri':43B 'chang':57B 'control':48B 'cwe':17B 'data':59B 'databas':58B 'dict':26B 'dictionari':31B 'escap':25B,30B 'function':27B 'inject':52B 'input':35B 'json':34B,50B 'key':32B,38B 'mysql':19B 'packag':20B 'pymysql':21B,23B 'python':22B 'queri':41B 'read':55B 'sql':44B,53B 'use':36B","search_c":"'1.1.0':62C 'allow':63C 'dict':79C 'escap':76C,78C 'inject':65C 'input':71C 'json':70C 'key':73C 'pymysql':60C 'sql':64C 'untrust':69C 'use':67C","cause_entry":null,"cause_path":null,"disclosures_checked_at":null,"first_public_at":"2024-05-21T16:15:26+00:00","kev":null,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","cvss_by":"GitHub","poc_count":0,"sources":[{"source":"ghsa","external_id":"GHSA-v9hf-5j83-6xpp","url":"https://github.com/advisories/GHSA-v9hf-5j83-6xpp","severity":"critical","published_at":"2024-05-21T18:31:23+00:00","modified_at":"2026-11-16T16:07:59+00:00","first_seen_at":"2026-11-16T16:08:24+00:00","fetched_at":"2026-11-16T16:17:15+00:00","note":null},{"source":"nvd","external_id":"CVE-2024-36039","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-36039","severity":null,"published_at":"2024-05-21T16:15:26+00:00","modified_at":"2026-06-17T07:36:00+00:00","first_seen_at":"2026-11-16T16:38:06+00:00","fetched_at":"2026-11-16T16:38:06+00:00","note":null}],"documents":[{"id":171029,"url":"https://github.com/PyMySQL/PyMySQL/releases/tag/v1.1.1","title":"Release: github.com","kind":"release","source":"ghsa","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Release: github.com"},{"id":171030,"url":"https://github.com/PyMySQL/PyMySQL/commit/521e40050cb386a499f68f483fefd144c493053c","title":"Patch: github.com","kind":"other","source":"ghsa","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Patch: github.com"}],"disclosures":[],"exploit_sources":[{"type":"epss","score":0.00691,"url":"https://api.first.org/data/v1/epss?cve=CVE-2024-36039"}],"notice":"Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai"}