ext/filter: encode 0xFF in FILTER_SANITIZE_ENCODED

Kurzinfo

Metadaten

  • Original (extern): Link oeffnen
  • Veroeffentlicht: 2026-09-24 10:07 UTC
  • Importiert: 2026-10-07 06:38 UTC
  • Quelle-ID: php_sec
  • uid_hash: 8e5dae5ce20b4f7089ea7e8e6ea23d913eb7152f7b645e8122ac92848b1f1b02

Inhalt

Summary

php_filter_encode_url() builds a 256-entry lookup table that decides which bytes FILTER_SANITIZE_ENCODED percent-encodes, but initialises only the first 255 entries. Entry 255 is read uninitialised, so whether the byte 0xFF is encoded or passed through depends on whatever happened to be on the stack.

Details

The table is filled with memset(tmp, 1, sizeof(tmp) - 1), which leaves tmp[255] untouched:

https://github.com/php/php-src/blob/php-8.5.9/ext/filter/sanitizing_filters.c#L73

The filter then consults tmp[*s] for every input byte, so for 0xFF the decision comes from uninitialised stack memory. Every other byte is handled deterministically.

The fix changes the memset() length to sizeof(tmp) so the whole table is initialised.

PoC

No data

Quellen-Details

Bezeichnung Name Kategorie Tags Zielgruppe Sprache Feed-URL
PHP Security (php/php-src GHSA)

php_sec

vendor_advisory php, runtime - de https://github.com/php/php-src/security/advisories