PHP Type Juggling
What is PHP Type Juggling?
Key Concepts:
"123" == 123 // true
"0" == false // true
null == "" // true
var_dump(0 == 'test'); // true, because 'test' is converted to 0
var_dump('0' == 0); // true, both are treated as integers"10" + 5 // 15
"10abc" + 5 // 15if ("0") {.....} // Evaluates to false
if (0) {......} // Evaluates to false
if ("foo") {.....} // Evaluates to true
if (bool(False)) {} // Evaluates to false
if (bool(None)) {} // Evaluates to false
if (bool(0)) {} // Evaluates to false
if (bool("")) {} // Evaluates to false
if (bool(())) {} // Evaluates to false
if (bool([])) {} // Evaluates to false
if (bool({})) {} // Evaluates to falseHow Type Juggling Works
Identifying Type Juggling
Why Did This Happen?
External Testing and Observation
Exploiting Type Juggling
Mitigation Strategies
Last updated