CVE-2022-31109 HTTP Host Header Attack Vulnerability in laminas-diactoros

High 7.2 Published Updated

Attackers can inject malicious headers to modify URLs, leading to XSS or URL poisoning in applications using this PHP library without proper proxy configuration.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2022-31109?

CVE-2022-31109 is a high-severity cross-site scripting vulnerability in laminas-diactoros, published on 1 Aug 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

laminas-diactoros is a PHP package containing implementations of the PSR-7 HTTP message interfaces and PSR-17 HTTP message factory interfaces. Applications that use Diactoros, and 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. Since the `X-Forwarded-*` headers do have valid use cases, particularly in clustered environments using a load balancer, the library offers mitigation measures only in the v2 releases, as doing otherwise would break these use cases immediately. Users of v2 releases from 2.11.1 can provide an additional argument to `Laminas\Diactoros\ServerRequestFactory::fromGlobals()` in the form of a `Laminas\Diactoros\RequestFilter\RequestFilterInterface` instance, including the shipped `Laminas\Diactoros\RequestFilter\NoOpRequestFilter` implementation which ignores the `X-Forwarded-*` headers. Starting in version 3.0, the library will reverse behavior to use the `NoOpRequestFilter` by default, and require users to opt-in to `X-Forwarded-*` header usage via a configured `Laminas\Diactoros\RequestFilter\LegacyXForwardedHeaderFilter` instance. Users are advised to upgrade to version 2.11.1 or later to resolve this issue. Users unable to upgrade may configure web servers to reject `X-Forwarded-*` headers at the web server level.

Weakness: CWE-79, CWE-444

Which versions are affected by CVE-2022-31109?

2 open source packages ship an affected version, including laminas/laminas-diactoros. It affects 1 product.

PackageAffectedFixed in
laminas/laminas-diactoros PackagistAll versions2.11.1
laminas/laminas-diactoros PackagistAll versions2.11.1

Products include Getlaminas Laminas-Diactoros.

How do I fix CVE-2022-31109?

Upgrade laminas/laminas-diactoros to 2.11.1 or later.

Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.

Is CVE-2022-31109 being exploited?

There is no known exploitation of CVE-2022-31109 in the wild and no public exploit code.

Sources

Also known as GHSA-8274-h5jp-97vr.

Is CVE-2022-31109 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free