← PHP / Laravel · Contents

PHP-066 / Advanced

Bypassing extension checks with a null byte (%00)

A01:2021 Broken Access Control · CWE-158 Improper Neutralization of Null Byte

Why is this a problem?

Older PHP or file functions ignore content after %00, allowing file.php%00.jpg to be executed or included.

How to fix it

php
$map = ['home' => 'home.php', 'about' => 'about.php'];   // Allowlist mapping
include $map[$request->input('page')] ?? 'home.php';

Further reading