CVE-2024-36039
python-pymysql: SQL injection if used with untrusted JSON input
Severity
ModerateRed Hat Product Security
CVSS 3.1
Review impact separately from score.
Published · May 21, 2024
Updated · November 1, 2026
Description
A flaw was found in PyMySQL. When processing untrusted JSON input, keys are not escaped by the escape_dict function due to insufficient input sanitization, allowing an attacker to inject malicious SQL queries.
Statement
Applications not exposed to untrusted JSON input are not vulnerable to this issue. Additionally, exploitation of this vulnerability depends on the permissions granted to the database user, limiting the security impact. For this reason, this flaw was rated with a Moderate severity.
CVSS score applicability
The CVSS score(s) listed for this vulnerability do not reflect the associated product's status, and are included for informational purposes to better understand the severity of this vulnerability.
Mitigation
Make sure the permissions are set correctly for each user, database, table, operation, etc. Do not expose the PyMySQL library to untrusted JSON input.
CVSS / CWE
CVSS 3.1 · 6.3CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L
CWE-89 · Improper Neutralization of Special Elements used in an SQL Command