← PHP / Laravel 목차

PHP-027 / 고급

JWT 검증 시 알고리즘 미고정 (alg none / 키 혼동)

A07:2021 Identification and Authentication Failures · CWE-347 Improper Verification of Cryptographic Signature

왜 문제가 될까요?

헤더의 alg를 신뢰하면 서명 검사가 무력화되거나 공개키를 HMAC 키로 사용당한다.

이렇게 수정하세요

php
$payload = JWT::decode($token, new Key($publicKey, 'RS256'));  // 허용 알고리즘 고정

더 읽기