# CVE-2021-3007: Remote code execution in zendframework and laminas-http

> Remote code execution via unsafe deserialization in Laminas HTTP and Zend Framework when attacker-controlled data is processed.

- **Severity:** Critical 9.8 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 4 Jan 2021
- **Updated:** 3 Aug 2024
- **Also known as:** CLSA-2026-1779151616, CLSA-2026-1782867594, CLSA-2026-1783645389, GHSA-xx8f-qf9f-5fgw

## What is CVE-2021-3007?

CVE-2021-3007 is a critical unsafe deserialization vulnerability in n/a, published on 4 Jan 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Laminas Project laminas-http before 2.14.2, and Zend Framework 3.0.0, has a deserialization vulnerability that can lead to remote code execution if the content is controllable, related to the __destruct method of the Zend\Http\Response\Stream class in Stream.php. NOTE: Zend Framework is no longer supported by the maintainer. NOTE: the laminas-http vendor considers this a "vulnerability in the PHP language itself" but has added certain type checking as a way to prevent exploitation in (unrecommended) use cases where attacker-supplied data can be deserialized

Weakness: CWE-502 (Deserialization of Untrusted Data)

## Which versions are affected by CVE-2021-3007?

4 open source packages ship an affected version, including laminas/laminas-http and zendframework/zendframework. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `laminas/laminas-http` | Packagist | All versions | 2.14.2 |
| `laminas/laminas-http` | Packagist | All versions | 2.14.2 |
| `zendframework/zendframework` | Packagist | All versions to 3.0.0 | None |
| `zendframework/zendframework` | Packagist | All versions to 3.0.0 | None |

Products: Getlaminas Laminas-Http, Zend Zend Framework.

## How do I fix CVE-2021-3007?

Upgrade laminas/laminas-http to 2.14.2 or later.

## Is CVE-2021-3007 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2021-3007 exists.

Public exploit code:

- ZendFramework_CVE-2021-3007 PoC (github_poc): https://github.com/Vulnmachines/ZF3_CVE-2021-3007
- https://github.com/yunus-a1i/CVE-2021-3007-docker-poc (github_poc): https://github.com/yunus-a1i/CVE-2021-3007-docker-poc
- CVE-2021-3007 Vulnerable Test Environment - Laminas/Zend Framework Deserialization RCE (github_poc): https://github.com/KrE80r/cve-2021-3007-vulnerable
- Laminas Project laminas-http - Remote Code Execution (nuclei): http/cves/2021/CVE-2021-3007.yaml

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-3007 and fix it if it is affected.

What it is: CVE-2021-3007 is a critical unsafe deserialization vulnerability in n/a, published on 4 Jan 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2021-3007 exists.

Affected packages and fixed versions:
- laminas/laminas-http (Packagist): affected all versions; fixed in 2.14.2
- laminas/laminas-http (Packagist): affected all versions; fixed in 2.14.2
- zendframework/zendframework (Packagist): affected all versions up to 3.0.0; no fix listed
- zendframework/zendframework (Packagist): affected all versions up to 3.0.0; no fix listed

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

## Sources

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

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