Imagine you are reviewing an API endpoint that checks a shared secret:
$payload = json_decode ( file_get_contents ( 'php://input' ) ) ;
if ( $payload -> token == 'SECRET_API_TOKEN' ) { $session -> grantAdmin ( ) ; }
Enter fullscreen mode
Exit fullscreen mode
At first glance, this looks like normal authentication code. But because it uses the loose == operator, an attacker who sends {"token": true} will pass the check. In PHP, any non-empty string other than '0' loosely evaluates to boolean true Zend Engine type rules . The caller gains administrative access without ever knowing the secret.
Spotting vulnerabilities in a PHP codebase requires understanding how the engine handles data types, superglobals, and input streams.
Type Juggling Across PHP Versions
Loose comparisons have caused authentication bypasses for years.…