# GHSA-c8rp-cgf4-937w: mezzio-swoole Applications Using Diactoros Vulnerable to HTTP Host Header Attack

> Attackers can manipulate HTTP headers to cause XSS or URL poisoning in mezzio-swoole apps using Diactoros without trusted proxies.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 29 Jul 2022

## What is GHSA-c8rp-cgf4-937w?

GHSA-c8rp-cgf4-937w is a cross-site scripting vulnerability in mezzio/mezzio-swoole, published on 29 Jul 2022. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

### Impact

mezzio-swoole applications using Diactoros for their PSR-7 implementation, and which are either not behind a proxy, or can be accessed via untrusted proxies, can potentially have the host, protocol, and/or port of a `Laminas\Diactoros\Uri` instance associated with the incoming server request modified to reflect values from `X-Forwarded-*` headers. Such changes can potentially lead to XSS attacks (if a fully-qualified URL is used in links) and/or URL poisoning.

### Patches

3.7.0, and 4.3.0 and later.

The patches present in these versions update the `SwooleServerRequestFactory` to filter out `X-Forwarded-*` headers when creating the initial request. They then by default pass that instance through a `Laminas\Diactoros\ServerRequestFilter\FilterUsingXForwardedHeaders` instance created from the `trustReservedSubnet()` constructor, ensuring that the request only honors the `X-Forwarded-*` headers for private reserved subnets.

Users can define the `Laminas\Diactoros\ServerRequestFilter\FilterServerRequestInterface` service if they wish to provide a different implementation, or configure the `FilterUsingXForwardedHeaders` instance differently. When defined, that instance will be used to filter the generated request instance.

### Workarounds

Infrastructure or DevOps can place a trusted reverse proxy in front of the mezzio-swoole server.

### References

- [HTTP Host Header Attacks](https://portswigger.net/web-security/host-header)

### For more information

If you have any questions or comments about this advisory:

- Open an issue in [mezzio/mezzio-swoole](https://github.com/mezzio/mezzio-swoole/)
- [Email us](mailto:security@getlaminas.org)

## Which versions are affected by GHSA-c8rp-cgf4-937w?

4 open source packages ship an affected version, including mezzio/mezzio-swoole.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `mezzio/mezzio-swoole` | Packagist | All versions | 3.7.0 |
| `mezzio/mezzio-swoole` | Packagist | All versions | 3.7.0 |
| `mezzio/mezzio-swoole` | Packagist | From 4.0.0 | 4.3.0 |
| `mezzio/mezzio-swoole` | Packagist | From 4.0.0 | 4.3.0 |

## How do I fix GHSA-c8rp-cgf4-937w?

Upgrade mezzio/mezzio-swoole to a fixed version for your release line: 3.7.0 or 4.3.0.

## Is GHSA-c8rp-cgf4-937w being exploited?

There is no known exploitation of GHSA-c8rp-cgf4-937w in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-c8rp-cgf4-937w and fix it if it is affected.

What it is: GHSA-c8rp-cgf4-937w is a cross-site scripting vulnerability in mezzio/mezzio-swoole, published on 29 Jul 2022. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-c8rp-cgf4-937w in the wild and no public exploit code.

Affected packages and fixed versions:
- mezzio/mezzio-swoole (Packagist): affected all versions; fixed in 3.7.0
- mezzio/mezzio-swoole (Packagist): affected all versions; fixed in 3.7.0
- mezzio/mezzio-swoole (Packagist): affected from 4.0.0; fixed in 4.3.0
- mezzio/mezzio-swoole (Packagist): affected from 4.0.0; fixed in 4.3.0

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-c8rp-cgf4-937w/ (Markdown: https://insights.sbomify.com/GHSA-c8rp-cgf4-937w/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-c8rp-cgf4-937w

---
From sbomify Insights: https://insights.sbomify.com/GHSA-c8rp-cgf4-937w/
Summaries are generated and may contain mistakes; the official description above is the record.
