Repository navigation
Conversation
|
Thanks for this, and sorry for the wait. Part of it overlapped with a security fix that was under embargo until today, so I couldn't comment earlier. The So this PR will now conflict in If you'd rather I push the rebase to your branch, let me know and I'll do that and keep you as the author. Posted by Claude on behalf of @anakinj. |
The iss, aud, sub and jti verifiers indexed the payload directly, so a correctly signed token whose payload is a JSON array, number, string or null raised TypeError or NoMethodError from JWT.decode. Neither is a JWT::Error, so callers rescuing JWT::DecodeError did not catch them. Treat a payload that is not a Hash as the claim being absent, so each verifier raises its own ClaimValidationError, as Claims::Required already does. Payloads that are not JSON objects still decode when no verified claim needs one. Fixes jwt#793
d245f9c to
15fece0
Compare
JWT::ClaimValidationError for a non-numeric exp/nbf or a payload that is not a JSON objectJWT::ClaimValidationError for a payload that is not a JSON object
JWT::ClaimValidationError for a payload that is not a JSON objectJWT::ClaimValidationError for a payload that is not a JSON object
|
Thanks @anakinj, so rebased. 👍 |
|
FYI: I removed the changelog entry from the pr, as it looks like you'll use release-please in future. |
|
Thanks for your attention. Im trying to lighten the manual steps in the release yes so squeezing in changes to that at some point. Lets see when i have time to continue:) |
Description
JWT.decodelets plain Ruby errors escape for a correctly signed token whose payload is a JSON array, number, string ornullwhenverify_iss,verify_aud,verify_suborverify_jtiis on.JWT::Claims::Issuer,JWT::Claims::Audience,JWT::Claims::SubjectandJWT::Claims::JwtIdindex the payload directly and raiseTypeErrororNoMethodError. Neither is aJWT::Error, so a caller that rescuesJWT::DecodeErrorto reject the token gets an unhandled error instead.This PR has those four verifiers treat a payload that is not a Hash as the claim being absent, so each raises its own
JWT::ClaimValidationError(Invalid issuer ... received <none>,Missing jti, and so on). This followsJWT::Claims::Required, which already handles non-Hash payloads this way. Ajtivalidator proc is still called, with a niljti. Encoding array and string payloads remains supported, and such tokens still decode when no verified claim needs a JSON object.The non-numeric
exp/nbfhalf of #793 shipped in 3.3.1 as GHSA-gp6v-qjfx-hrxc, so this PR no longer touches it. There is no CHANGELOG row:mainhas no section for the next version, and #800 moves the changelog to release-please, which generates it from PR titles.Fixes #793
Checklist
Before the PR can be merged be sure the following are checked: