JWT No Validation (ARCH7126)
Esta página aún no está disponible en tu idioma.
Key php.security.jwt-no-validation · Severity error · Category security · CWE CWE-347
Decoding a JWT without verifying its signature (reading the payload directly or accepting alg: none) lets an attacker forge a token with any claims they want.
Incorrect
Section titled “Incorrect”<?php[$header, $payload, $sig] = explode('.', $token);$claims = json_decode(base64_decode($payload), true); // signature not verified$userId = $claims['sub'];Correct
Section titled “Correct”<?php$claims = JWT::decode($token, new Key(getenv('JWT_KEY'), 'HS256')); // signature verified$userId = $claims->sub;Always verify JWTs with the expected algorithm and key; reject the none algorithm and unverified decoding.