Skip to content

Php 8.1 security backport#1

Draft
andypost wants to merge 7 commits intoPHP-8.1from
PHP-8.1-security-backport
Draft

Php 8.1 security backport#1
andypost wants to merge 7 commits intoPHP-8.1from
PHP-8.1-security-backport

Conversation

@andypost
Copy link
Copy Markdown

@andypost andypost commented May 5, 2026

WIP for Alpinelinux

iluuu1994 and others added 7 commits May 5, 2026 20:40
…array offset

Fixes GHSA-96wq-48vp-hh57
Fixes CVE-2026-7568

(cherry picked from commit dd77cfe)
…b_check_encoding() via mb_ereg_search_init()

Fixes GHSA-wm6j-2649-pv75
Fixes CVE-2026-7259

(cherry picked from commit df8ae9c)
Fixes GHSA-7qg2-v9fj-4mwv
Fixes CVE-2026-6735

(cherry picked from commit 13e72d1)
…ailure with SOAP_PERSISTENCE_SESSION

Fixes GHSA-m33r-qmcv-p97q
Fixes CVE-2026-7261

(cherry picked from commit b9f81de)
…th Apache Map

Fixes GHSA-85c2-q967-79q5
Fixes CVE-2026-6722

(cherry picked from commit 84e3004)
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements extensive security hardening and bug fixes across the PHP core and various extensions. The primary change involves casting arguments to unsigned char for character classification and transformation functions to avoid undefined behavior. It also addresses several critical vulnerabilities, including null pointer dereferences in mbstring and SOAP, use-after-free and reference counting issues in SOAP, integer overflows in metaphone, and an XSS vulnerability in the FPM status page. Feedback indicates that several calls to isxdigit, isspace, and isdigit in ext/standard/filters.c and ext/standard/strnatcmp.c were missed and should be updated with the appropriate casts for consistency.

Comment thread ext/standard/filters.c
}

if (!isxdigit((int) *ps)) {
if (!isxdigit(*ps)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The isxdigit() function expects an int that is representable as an unsigned char or is EOF. Passing a signed char directly can lead to undefined behavior if the value is negative. To be consistent with the rest of the changes in this pull request, this should be cast to unsigned char.

				if (!isxdigit((unsigned char)*ps)) {

Comment thread ext/standard/strnatcmp.c

/* Skip consecutive whitespace */
while (isspace((int)(unsigned char)ca)) {
while (isspace(ca)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The isspace() function expects an int that is representable as an unsigned char or is EOF. Since ca is a char, it should be cast to unsigned char before being passed to isspace(). This is inconsistent with the correct changes made on lines 106 and 110 of this same file.

		while (isspace((unsigned char)ca)) {

Comment thread ext/standard/strnatcmp.c
}

while (isspace((int)(unsigned char)cb)) {
while (isspace(cb)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The isspace() function expects an int that is representable as an unsigned char or is EOF. Since cb is a char, it should be cast to unsigned char before being passed to isspace().

		while (isspace((unsigned char)cb)) {

Comment thread ext/standard/strnatcmp.c

/* process run of digits */
if (isdigit((int)(unsigned char)ca) && isdigit((int)(unsigned char)cb)) {
if (isdigit(ca) && isdigit(cb)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The isdigit() function expects an int that is representable as an unsigned char or is EOF. Since ca and cb are chars, they should be cast to unsigned char before being passed to isdigit().

		if (isdigit((unsigned char)ca)  &&  isdigit((unsigned char)cb)) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants