Uninitialized lookup entry in PHP FILTER_SANITIZE_ENCODED filter
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- None
- Attack complexity
- High
- Impact type
- —
- Confidentiality · integrity · availability
- Low · None · None
- Fix status
- Fixed
Attack profile from CVSS 3.1 · GHSA-ch8v-r6jh-4vvr. Fix status from GitHub.
Summary
The ext/filter extension in PHP is affected before 8.2.34, before 8.3.35, before 8.4.25 and before 8.5.10. The percent-encoding lookup table built in php_filter_encode_url leaves its entry for byte 0xFF uninitialized, so FILTER_SANITIZE_ENCODED either encodes that byte or passes it through depending on stack contents. A remote, unauthenticated attacker can reach this with high attack complexity, but the flaw causes only inconsistent sanitizing, with no crash or memory corruption.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
Description from the GitHub advisory
### 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 ```php <?php $out = filter_var("\xff\xfeabc", FILTER_SANITIZE_ENCODED); echo "in : ", bin2hex("\xff\xfeabc"), "\n"; echo "out: ", bin2hex($out), "\n"; ``` ``` in : fffe616263 out: ff254645616263 ``` `0xFE` is percent-encoded as `%FE` while `0xFF` is passed through raw, showing that `tmp[255]` was read uninitialised. ### Impact The impact is low. There is no crash and no memory corruption; the only effect is that the `0xFF` byte is sanitised inconsistently, depending on uninitialised stack contents. A downstream consumer that relies on `FILTER_SANITIZE_ENCODED` producing fully percent-encoded output could in principle be affected as part of a longer chain, but the filter provides no such guarantee on its own. This issue was fixed publicly in 8.4.25 and 8.5.10 before it was recognised as security relevant, and is backported here to the branches that receive security fixes only.
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | ext-filter | <8.2.34 | 8.2.34 | Patch available | GHSA-ch8v-r6jh-4vvr |
| — | ext-filter | <8.3.35 | 8.3.35 | Patch available | GHSA-ch8v-r6jh-4vvr |
| — | ext-filter | <8.4.25 | 8.4.25 | Patch available | GHSA-ch8v-r6jh-4vvr |
| — | ext-filter | <8.5.10 | 8.5.10 | Patch available | GHSA-ch8v-r6jh-4vvr |
- ext-filter Vendor— Affected <8.2.34 Fixed in 8.2.34 Patch available GHSA-ch8v-r6jh-4vvr
- ext-filter Vendor— Affected <8.3.35 Fixed in 8.3.35 Patch available GHSA-ch8v-r6jh-4vvr
- ext-filter Vendor— Affected <8.4.25 Fixed in 8.4.25 Patch available GHSA-ch8v-r6jh-4vvr
- ext-filter Vendor— Affected <8.5.10 Fixed in 8.5.10 Patch available GHSA-ch8v-r6jh-4vvr
Remediation
Upgrade PHP ext-filter to 8.2.34, 8.3.35, 8.4.25 or 8.5.10, depending on the branch in use.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
- Fix · GHSA-ch8v-r6jh-4vvr ext-filter Fixed in 8.2.34 Advisory →
- Fix · GHSA-ch8v-r6jh-4vvr ext-filter Fixed in 8.3.35 Advisory →
- Fix · GHSA-ch8v-r6jh-4vvr ext-filter Fixed in 8.4.25 Advisory →
- Fix · GHSA-ch8v-r6jh-4vvr ext-filter Fixed in 8.5.10 Advisory →
Timeline
- 2026-11-12 Threatist record created from GHSA-ch8v-r6jh-4vvr
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences