phpsafe 𝕏 GitHub
Official CA 421DTkQ3TSG3n7F9SkNZj9NxvdFGbypwkctPd2uupump This is the only official address.

preg_replace with the /e modifier

Severity: Critical CWE-95 OWASP A03:2021 Injection rule: preg_e

Why it matters

The /e modifier evaluated the replacement as PHP code. It was removed in PHP 7, so code that still uses it is dangerous on old servers and broken on new ones.

βœ• Vulnerable
$out = preg_replace('/(\w+)/e', 'strtoupper("$1")', $text);
βœ“ Secure
$out = preg_replace_callback('/(\w+)/', fn($m) => strtoupper($m[1]), $text);

How to fix

The /e modifier runs code. Use preg_replace_callback() instead.

Scan my code

Paste a file and PHP Safe points to every line that matches this rule.

Scan my code β†’