# GHSA-x2f4-8wxf-w3vf: ZendFramework SQL injection due to execution of platform-specific SQL containing interpolations

> Attackers can execute arbitrary SQL commands via flawed value quoting in Zend Framework's database abstraction layer, potentially reading or modifying data.

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

## What is GHSA-x2f4-8wxf-w3vf?

GHSA-x2f4-8wxf-w3vf is a SQL injection vulnerability in zendframework/zendframework, published on 7 Jun 2024. It can be exploited over the network, with no action from the victim.

### Official description

The `Zend\Db` component in Zend Framework 2 provides platform abstraction, which is used in particular for SQL abstraction. Two methods defined in the platform interface, `quoteValue()` and `quoteValueList()`, allow users to manually quote values for creating SQL statements; these are in turn consumed by aspects of the SQL abstraction platform, including `Zend\Db\Sql\Sql::getSqlStringForSqlObject()`, and the `getSqlString()` method provided in a number of classes in the Zend\Db\Sql namespace.

While these methods are primarily intended for debugging and logging purposes, developers can use them to produce SQL that is then passed to the driver to execute. Due to a flaw in how the `quoteValue()` and `quoteValueList()` methods were written, this can lead to potential SQL injection.

The offending code is located in any of the `Zend\Db\Adapter\Platform*` objects, particularly the quoteValue() and `quoteValueList()` methods. These methods did not take into account most of the possible escapable characters that would need to be escaped when attempting to create a quoted value for interpolation into a SQL string. Moreover, these methods did value quoting without extension level coordination which, when available, takes character-sets into account when quoting.

## Which versions are affected by GHSA-x2f4-8wxf-w3vf?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `zendframework/zendframework` | Packagist | From 2.0.0 | 2.0.8 |
| `zendframework/zendframework` | Packagist | From 2.0.0 | 2.0.8 |
| `zendframework/zendframework` | Packagist | From 2.1.0 | 2.1.4 |
| `zendframework/zendframework` | Packagist | From 2.1.0 | 2.1.4 |

## How do I fix GHSA-x2f4-8wxf-w3vf?

Upgrade zendframework/zendframework to a fixed version for your release line: 2.0.8 or 2.1.4.

## Is GHSA-x2f4-8wxf-w3vf being exploited?

There is no known exploitation of GHSA-x2f4-8wxf-w3vf in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-x2f4-8wxf-w3vf and fix it if it is affected.

What it is: GHSA-x2f4-8wxf-w3vf is a SQL injection vulnerability in zendframework/zendframework, published on 7 Jun 2024. It can be exploited over the network, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-x2f4-8wxf-w3vf in the wild and no public exploit code.

Affected packages and fixed versions:
- zendframework/zendframework (Packagist): affected from 2.0.0; fixed in 2.0.8
- zendframework/zendframework (Packagist): affected from 2.0.0; fixed in 2.0.8
- zendframework/zendframework (Packagist): affected from 2.1.0; fixed in 2.1.4
- zendframework/zendframework (Packagist): affected from 2.1.0; fixed in 2.1.4

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-x2f4-8wxf-w3vf/ (Markdown: https://insights.sbomify.com/GHSA-x2f4-8wxf-w3vf/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-x2f4-8wxf-w3vf

---
From sbomify Insights: https://insights.sbomify.com/GHSA-x2f4-8wxf-w3vf/
Summaries are generated and may contain mistakes; the official description above is the record.
