← PHP / Laravel 목차

PHP-064 / 기초

PHP 느슨한 비교(==)와 타입 저글링

A07:2021 Identification and Authentication Failures · CWE-697 Incorrect Comparison

왜 문제가 될까요?

PHP 7 이하에서 "0e123" == "0e456" 가 참이 되는 등 비교가 우회된다.

이렇게 수정하세요

php
if (is_string($code) && hash_equals($expected, $code)) { ... }

더 읽기