# GHSA-v42g-7q2x-cw32: Zendframework1 potential SQL injection vector using null byte for PDO (MsSql, SQLite)

> Attackers can inject arbitrary SQL via null bytes in PDO queries, potentially reading or modifying database contents.

- **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-v42g-7q2x-cw32?

GHSA-v42g-7q2x-cw32 is a SQL injection vulnerability in zendframework/zendframework1, published on 7 Jun 2024. It can be exploited over the network, with no action from the victim.

### Official description

The PDO adapters of Zend Framework 1 do not filter null bytes values in SQL statements. A PDO adapter can treat null bytes in a query as a string terminator, allowing an attacker to add arbitrary SQL following a null byte, and thus create a SQL injection.

We tested and verified the null byte injection using pdo_dblib (FreeTDS) on a Linux environment to access a remote Microsoft SQL Server, and also tested against and noted the vector against pdo_sqlite.

## Which versions are affected by GHSA-v42g-7q2x-cw32?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `zendframework/zendframework1` | Packagist | From 1.12.0 | 1.12.16 |
| `zendframework/zendframework1` | Packagist | From 1.12.0 | 1.12.16 |

## How do I fix GHSA-v42g-7q2x-cw32?

Upgrade zendframework/zendframework1 to 1.12.16 or later.

## Is GHSA-v42g-7q2x-cw32 being exploited?

There is no known exploitation of GHSA-v42g-7q2x-cw32 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-v42g-7q2x-cw32 and fix it if it is affected.

What it is: GHSA-v42g-7q2x-cw32 is a SQL injection vulnerability in zendframework/zendframework1, 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-v42g-7q2x-cw32 in the wild and no public exploit code.

Affected packages and fixed versions:
- zendframework/zendframework1 (Packagist): affected from 1.12.0; fixed in 1.12.16
- zendframework/zendframework1 (Packagist): affected from 1.12.0; fixed in 1.12.16

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-v42g-7q2x-cw32/ (Markdown: https://insights.sbomify.com/GHSA-v42g-7q2x-cw32/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-v42g-7q2x-cw32

---
From sbomify Insights: https://insights.sbomify.com/GHSA-v42g-7q2x-cw32/
Summaries are generated and may contain mistakes; the official description above is the record.
