# GHSA-jq87-2wxp-8349: ZendFramework Route Parameter Injection Via Query String in `Zend\Mvc`

> Attackers can bypass routing constraints and execute unintended controllers by injecting query parameters, potentially accessing restricted functionality.

- **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:** 7 Jun 2024

## What is GHSA-jq87-2wxp-8349?

GHSA-jq87-2wxp-8349 is a missing authorization vulnerability in zendframework/zendframework, published on 7 Jun 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

In Zend Framework 2, `Zend\Mvc\Router\Http\Query` is used primarily to allow appending query strings to URLs when assembled. However, due to the fact that it captures any query parameters into the RouteMatch, and the fact that RouteMatch parameters are merged with any parent routes, this can lead to overriding already captured routing parameters, bypassing constraints defined in the parents.

As an example, consider the following route definition:
```
array(
    'user' => array(
        'type' => 'segment',
        'options' => array(
            'route' => '/user/:key',
            'defaults' => array(
                'controller' => 'UserController',
                'action'     => 'show-action',
            ),
            'constraints' => array(
                'key' => '[a-z0-9]+',
            ),
        ),
        'child_routes' => array(
            'query' => array('type' => 'query'),
        ),
    ),
)
```
If the request URI was /user/foo/?controller=SecretController&key=invalid_value, the RouteMatch returned after routing would contain the following:
```
array(
    'controller' => 'SecretController',
    'action'     => 'show-action',
    'key'        => 'invalid_value',
)
```
This would lead to execution of a different controller than intended, with a value for the key parameter that bypassed the constraints outlined in the parent route.

## Which versions are affected by GHSA-jq87-2wxp-8349?

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-jq87-2wxp-8349?

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

## Is GHSA-jq87-2wxp-8349 being exploited?

There is no known exploitation of GHSA-jq87-2wxp-8349 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-jq87-2wxp-8349 and fix it if it is affected.

What it is: GHSA-jq87-2wxp-8349 is a missing authorization vulnerability in zendframework/zendframework, published on 7 Jun 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-jq87-2wxp-8349 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-jq87-2wxp-8349/ (Markdown: https://insights.sbomify.com/GHSA-jq87-2wxp-8349/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-jq87-2wxp-8349

---
From sbomify Insights: https://insights.sbomify.com/GHSA-jq87-2wxp-8349/
Summaries are generated and may contain mistakes; the official description above is the record.
