CVE-2024-36039 PyMySQL SQL Injection vulnerability

Medium 6.3 Published Updated

Attackers can execute arbitrary SQL commands via untrusted JSON input due to improper key escaping in PyMySQL.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2024-36039?

CVE-2024-36039 is a medium-severity SQL injection vulnerability in n/a, published on 21 May 2024. Any signed-in user can exploit it over the network, with no action from the victim.

Official description

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

Weakness: CWE-89

Which versions are affected by CVE-2024-36039?

3 open source packages ship an affected version, including pymysql.

PackageAffectedFixed in
pymysql PyPIAll versions1.1.1
pymysql PyPIAll versions1.1.1
pymysql PyPIAll versions1.1.1
Linux distribution packages (21)
python3.11-PyMySQL AlmaLinux:8All versions1.0.2-2.el8_10
python3.12-PyMySQL AlmaLinux:8All versions1.1.0-3.el8_10
python3.11-PyMySQL AlmaLinux:9All versions1.0.2-2.el9
python3.11-PyMySQL+rsa AlmaLinux:9All versions1.0.2-2.el9
python3.12-PyMySQL AlmaLinux:9All versions1.1.0-3.el9
python3.12-PyMySQL+rsa AlmaLinux:9All versions1.1.0-3.el9
python3.11-PyMySQL Red Hat:enterprise_linux:8::appstreamAll versions0:1.0.2-2.el8_10
python3.12-PyMySQL Red Hat:enterprise_linux:8::appstreamAll versions0:1.1.0-3.el8_10
python3.11-PyMySQL Red Hat:enterprise_linux:9::appstreamAll versions0:1.0.2-2.el9
python3.11-PyMySQL+rsa Red Hat:enterprise_linux:9::appstreamAll versions0:1.0.2-2.el9
python3.12-PyMySQL Red Hat:enterprise_linux:9::appstreamAll versions0:1.1.0-3.el9
python3.12-PyMySQL+rsa Red Hat:enterprise_linux:9::appstreamAll versions0:1.1.0-3.el9
python3.11-PyMySQL Rocky Linux:8All versions0:1.0.2-2.el8_10
python3.12-PyMySQL Rocky Linux:8All versions0:1.1.0-3.el8_10
python3.11-PyMySQL Rocky Linux:9All versions0:1.0.2-2.el9
python3.12-PyMySQL Rocky Linux:9All versions0:1.1.0-3.el9
python-PyMySQL SUSE:Linux Enterprise Module for Package Hub 15 SP5All versions0.7.11-150000.3.3.1
python-PyMySQL SUSE:Linux Enterprise Module for Package Hub 15 SP6All versions0.7.11-150000.3.3.1
python-PyMySQL openSUSE:Leap 15.5All versions0.7.11-150000.3.3.1
python-PyMySQL openSUSE:Leap 15.6All versions1.1.0-150600.3.3.1
python-PyMySQL openSUSE:TumbleweedAll versions1.2.0-1.2

How do I fix CVE-2024-36039?

Upgrade pymysql to 1.1.1 or later.

Use parameterised queries everywhere and never build SQL by joining strings. Upgrade affected software first; a web application firewall only buys time. More about SQL injection.

Is CVE-2024-36039 being exploited?

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

Public exploit code: 1 proofs of concept on GitHub.

Sources

Also known as ALSA-2024:4244, ALSA-2024:4245, ALSA-2024:9193, ALSA-2024:9194, AZL-43726, AZL-44457 and 22 more.

Is CVE-2024-36039 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free