type-juggling

Identify and exploit PHP loose comparison and magic hash bypass patterns.

5|1|Updated Apr 20, 2026
One-click install
npx skills add https://github.com/Yliken/ai4 --skill type-juggling
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: type-juggling
Source: https://github.com/Yliken/ai4/tree/main/skills/type-juggling
Command: npx skills add https://github.com/Yliken/ai4 --skill type-juggling

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PHP type juggling and weak comparisons allow bypasses in authentication and signature checks. This skill helps identify and understand these patterns so you can defend or test code paths that rely on loose equality rather than strict types.

Core Features & Use Cases

  • Understand how PHP's loose comparison operates across types, including numeric strings, arrays, and nulls, and how this can lead to bypasses in login, token validation, and HMAC checks.
  • Recognize and exploit magic hash collisions (0e… patterns) and related pitfalls to test the robustness of authorization logic.
  • Provide defensive guidance: prefer strict comparisons and timing-safe checks (hash_equals) to mitigate these risks in PHP applications.

Quick Start

Test a PHP snippet that compares two values with loose equality to observe how different inputs can be treated as equal and reproduced by magic-hash patterns.

Frequently Asked Questions about type-juggling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does PHP loose comparison lead to authentication bypass?

PHP loose comparison leads to authentication bypass when code uses == to validate tokens or HMACs, allowing disparate types like numeric strings and arrays to evaluate as equal and grant unauthorized access.

What is a magic hash collision and how do I exploit it in CTF challenges?

A magic hash collision exploits PHP loose comparison by using strings starting with 0e that PHP interprets as scientific notation, making two different hashes compare equal under == and bypassing signature checks.

How do I fix PHP type juggling vulnerabilities in my code?

Fix PHP type juggling vulnerabilities by replacing loose == comparisons with strict === equality checks and using hash_equals for timing-safe validation of tokens, HMACs, and signatures.

Why does my PHP token validation accept incorrect passwords or signatures?

Your PHP token validation likely uses loose comparison operators, causing type juggling where unexpected variable types are cast and evaluated as equal, bypassing your intended authorization logic.

Do I need to know specific PHP versions to test type juggling vulnerabilities?

Testing type juggling vulnerabilities requires knowledge of PHP type juggling behavior across versions, as loose comparison rules for numeric strings, arrays, and nulls vary between legacy and modern PHP releases.

When should I avoid using loose comparison for security checks in PHP?

Avoid loose comparison for security checks in PHP whenever validating authentication tokens, HMACs, or signatures, as type juggling allows crafted inputs to bypass authorization logic and compromise application security.