# GHSA-6q9v-4hq6-5m67: Doctrine SQL injection vulnerability

> Doctrine library allows SQL injection via uncast limit/offset parameters, enabling attackers to read or modify database contents.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 15 May 2024

## What is GHSA-6q9v-4hq6-5m67?

GHSA-6q9v-4hq6-5m67 is a SQL injection vulnerability in doctrine/orm, published on 15 May 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Doctrine is prone to SQL injection vulnerability. Users of Doctrine 1.2 and 2 should update to the newly released versions of both libraries immediately. Both versions only include the security fix and no other changes to their previous versions 1.2.3 and 2.0.2.

Affected versions are:
- 1.2.3 and earlier for PostgreSQL and DB2 Dialects
- 2.0.2 and earlier

The security issue was found to affect the `Doctrine\DBAL\Platforms\AbstractPlatform::modifyLimitQuery()` function which does not cast input values for limit and offset to integer and allows malicious SQL to be executed if these parameters are passed into Doctrine 2 directly from request variables without previous cast to integer. Functionality building on top using limit queries in the ORM such as `Doctrine\ORM\Query::setFirstResult()` and `Doctrine\ORM\Query::setMaxResults()` are also affected by this security issue.

The fix for this security issue breaks backwards compatibility for developers that extend the `Doctrine\DBAL\Platforms\AbstractPlatform::modifyLimitQuery()` method, because it is now marked as final. Please overwrite the `Doctrine\DBAL\Platforms\AbstractPlatform::doModifyLimitQuery()` method instead.

## Which versions are affected by GHSA-6q9v-4hq6-5m67?

4 open source packages ship an affected version, including doctrine/orm.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `doctrine/orm` | Packagist | From 1.0.0 | 1.2.4 |
| `doctrine/orm` | Packagist | From 1.0.0 | 1.2.4 |
| `doctrine/orm` | Packagist | From 2.0.0 | 2.0.3 |
| `doctrine/orm` | Packagist | From 2.0.0 | 2.0.3 |

## How do I fix GHSA-6q9v-4hq6-5m67?

Upgrade doctrine/orm to a fixed version for your release line: 1.2.4 or 2.0.3.

## Is GHSA-6q9v-4hq6-5m67 being exploited?

There is no known exploitation of GHSA-6q9v-4hq6-5m67 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-6q9v-4hq6-5m67 and fix it if it is affected.

What it is: GHSA-6q9v-4hq6-5m67 is a SQL injection vulnerability in doctrine/orm, published on 15 May 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-6q9v-4hq6-5m67 in the wild and no public exploit code.

Affected packages and fixed versions:
- doctrine/orm (Packagist): affected from 1.0.0; fixed in 1.2.4
- doctrine/orm (Packagist): affected from 1.0.0; fixed in 1.2.4
- doctrine/orm (Packagist): affected from 2.0.0; fixed in 2.0.3
- doctrine/orm (Packagist): affected from 2.0.0; fixed in 2.0.3

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/GHSA-6q9v-4hq6-5m67/ (Markdown: https://insights.sbomify.com/GHSA-6q9v-4hq6-5m67/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-6q9v-4hq6-5m67

---
From sbomify Insights: https://insights.sbomify.com/GHSA-6q9v-4hq6-5m67/
Summaries are generated and may contain mistakes; the official description above is the record.
