# CVE-2012-0805: SQLAlchemy vulnerable to SQL injection

> Remote attackers can execute arbitrary SQL commands via crafted limit or offset parameters in SQLAlchemy select functions.

- **Severity:** High 7.5 (`AV:N/AC:L/Au:N/C:P/I:P/A:P`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 5 Jun 2012
- **Updated:** 6 Aug 2024
- **Also known as:** DEBIAN-CVE-2012-0805, DSA-2449-1, GHSA-hfg2-wf6j-x53p, PYSEC-2012-9, RHSA-2012:0369

## What is CVE-2012-0805?

CVE-2012-0805 is a high-severity SQL injection vulnerability in n/a, published on 5 Jun 2012. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Multiple SQL injection vulnerabilities in SQLAlchemy before 0.7.0b4, as used in Keystone, allow remote attackers to execute arbitrary SQL commands via the (1) limit or (2) offset keyword to the select function, or unspecified vectors to the (3) select.limit or (4) select.offset function.

Weakness: CWE-89 (Improper Neutralization of Special Elements used in an SQL Command)

## Which versions are affected by CVE-2012-0805?

3 open source packages ship an affected version, including sqlalchemy and SQLAlchemy. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `sqlalchemy` | PyPI | All versions | 0.7.0 |
| `sqlalchemy` | PyPI | All versions | 0.7.0b4 |
| `SQLAlchemy` | PyPI | All versions | 0.7.0b4 |
| `python-sqlalchemy` | Red Hat:enterprise_linux:6::server | All versions | 0:0.5.5-3.el6_2 |
| `python-sqlalchemy` | Red Hat:enterprise_linux:6::workstation | All versions | 0:0.5.5-3.el6_2 |

Products: Sqlalchemy Sqlalchemy.

## How do I fix CVE-2012-0805?

Upgrade sqlalchemy to a fixed version for your release line: 0.7.0 or 0.7.0b4.

## Is CVE-2012-0805 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2012-0805 and fix it if it is affected.

What it is: CVE-2012-0805 is a high-severity SQL injection vulnerability in n/a, published on 5 Jun 2012. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2012-0805 in the wild and no public exploit code.

Affected packages and fixed versions:
- sqlalchemy (PyPI): affected all versions; fixed in 0.7.0
- sqlalchemy (PyPI): affected all versions; fixed in 0.7.0b4
- SQLAlchemy (PyPI): affected all versions; fixed in 0.7.0b4

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-2012-0805/ (Markdown: https://insights.sbomify.com/CVE-2012-0805/index.md)
```

## Sources

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

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