# CVE-2024-9774: Python-sql: python-sql unary operators does not escape non-expression

> Attackers can inject SQL commands via unary operators in python-sql, potentially leading to code execution or data theft.

- **Severity:** Medium 6.5 (`CVSS:3.0/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 27 Dec 2024
- **Updated:** 30 Aug 2025
- **Also known as:** DEBIAN-CVE-2024-9774, DLA-3932-1, DSA-5795-1, GHSA-pq9p-pc3p-9hm4, PYSEC-2026-1855, UBUNTU-CVE-2024-9774, USN-8765-1, openSUSE-SU-2024:0412-1, openSUSE-SU-2024:0413-1

## What is CVE-2024-9774?

CVE-2024-9774 is a medium-severity SQL injection vulnerability in python-sql, published on 27 Dec 2024. An attacker needs administrator access to exploit it, with no action from the victim.

### Official description

A vulnerability was found in python-sql where unary operators do not escape non-Expression.

Weakness: CWE-150 (Improper Neutralization of Escape, Meta, or Control Sequences)

## Which versions are affected by CVE-2024-9774?

3 open source packages ship an affected version, including python-sql.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `python-sql` | PyPI | All versions | 1.5.2 |
| `python-sql` | PyPI | All versions | 1.5.2 |
| `python-sql` | PyPI | All versions | 1.5.2 |
| `python-python-sql` | SUSE:Package Hub 15 SP5 | All versions | 1.5.1-bp155.3.6.1 |
| `python-python-sql` | SUSE:Package Hub 15 SP6 | All versions | 1.5.1-bp156.2.6.1 |
| `python-python-sql` | openSUSE:Leap 15.5 | All versions | 1.5.1-bp155.3.6.1 |
| `python-python-sql` | openSUSE:Leap 15.6 | All versions | 1.5.1-bp156.2.6.1 |

## How do I fix CVE-2024-9774?

Upgrade python-sql to 1.5.2 or later.

## Is CVE-2024-9774 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-9774 and fix it if it is affected.

What it is: CVE-2024-9774 is a medium-severity SQL injection vulnerability in python-sql, published on 27 Dec 2024. An attacker needs administrator access to exploit it, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2024-9774 in the wild and no public exploit code.

Affected packages and fixed versions:
- python-sql (PyPI): affected all versions; fixed in 1.5.2
- python-sql (PyPI): affected all versions; fixed in 1.5.2
- python-sql (PyPI): affected all versions; fixed in 1.5.2

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-9774/ (Markdown: https://insights.sbomify.com/CVE-2024-9774/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-9774
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-9774
- OSV: https://osv.dev/vulnerability/CVE-2024-9774

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-9774/
Summaries are generated and may contain mistakes; the official description above is the record.
