Skip to content

__Host-/__Secure- cookie bypass due to partial CVE-2022-31629 fix

Moderate
bukka published GHSA-wpj3-hf5j-x4v4 Apr 11, 2024

Package

No package listed

Affected versions

> 8.1.11, < 8.1.28
< 8.2.18
< 8.3.5

Patched versions

8.1.28
8.2.18
8.3.6

Description

Summary

Due to an incomplete fix to CVE-2022-31629, network and same-site attackers can set a standard insecure cookie in the victim's browser which is treated as a __Host- or __Secure- cookie by PHP applications.

Details

The vulnerability is identical to one previously described in https://bugs.php.net/bug.php?id=81727. Unfortunatly, since CVE-2022-31629 got only partially fixed in PHP >8.1.11, cookies starting with _[Host- are parsed by PHP applications as __Host-. Notice that I reported this vulnerability multiple times via email after the fix for CVE-2022-31629 landed (I am the original reporter of that CVE), but I guess that the message got lost.

PoC

$ echo '<?php echo(json_encode($_COOKIE)); ?>' > x

$ docker run -p 8080:8080 --rm -v $(pwd):$(pwd) php:latest php -S 0.0.0.0:8080 $(pwd)/x

$ curl -b '_[Host-x=y' localhost:8080/x
{"__Host-x":"y"}

Severity

Moderate

CVE ID

CVE-2024-2756

Weaknesses

Improper Input Validation

The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. Learn more on MITRE.

Credits