phpsafe 𝕏 GitHub
Official CA 421DTkQ3TSG3n7F9SkNZj9NxvdFGbypwkctPd2uupump This is the only official address.

unserialize() on untrusted data

Severity: Critical CWE-502 OWASP A08:2021 Software and Data Integrity Failures rule: unserialize

Why it matters

unserialize() can create any object, and attackers chain existing classes (gadgets) to delete files or run code. JSON only ever produces plain data.

βœ• Vulnerable
$prefs = unserialize($_COOKIE['prefs']);
βœ“ Secure
$prefs = json_decode($_COOKIE['prefs'] ?? '{}', true) ?: [];

How to fix

Use json_decode() instead. If you must unserialize, pass ['allowed_classes' => false].

Scan my code

Paste a file and PHP Safe points to every line that matches this rule.

Scan my code β†’