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

extract() on request data

Severity: High CWE-621 OWASP A03:2021 Injection rule: extract

Why it matters

extract() turns every request field into a variable, so an attacker can overwrite variables such as $is_admin just by adding a field to the form.

βœ• Vulnerable
extract($_POST);
if ($is_admin) {
    show_admin_panel();
}
βœ“ Secure
$name  = trim((string)($_POST['name'] ?? ''));
$email = filter_var($_POST['email'] ?? '', FILTER_VALIDATE_EMAIL);

How to fix

Read only the fields you need, one by one. extract() lets attackers overwrite your variables.

Scan my code

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

Scan my code β†’