Skip to content

NimbusJwtDecoder silently accepts unknown values for spring.security.oauth2.resourceserver.jwt.jws-algorithms#50118

Open
vinhhieu21 wants to merge 2 commits intospring-projects:3.5.xfrom
vinhhieu21:fix-jws-algorithm-null-add
Open

NimbusJwtDecoder silently accepts unknown values for spring.security.oauth2.resourceserver.jwt.jws-algorithms#50118
vinhhieu21 wants to merge 2 commits intospring-projects:3.5.xfrom
vinhhieu21:fix-jws-algorithm-null-add

Conversation

@vinhhieu21
Copy link
Copy Markdown

OAuth2ResourceServerJwtConfiguration.jwsAlgorithms(Set) and its reactive counterpart map each configured value through SignatureAlgorithm.from(String) and add the result directly to the set. SignatureAlgorithm.from returns null for unknown names, so a misconfiguration such as RS265 (instead of RS256) is silently accepted and only surfaces later as a confusing verification-time failure.

Both methods now reject unknown algorithms with an InvalidConfigurationPropertyValueException, matching the behaviour already used by exactlyOneAlgorithm() for the public-key path.

Closes gh-50116

Signed-off-by: Hieu Bui Vinh <buivinhhieu217@gmail.com>
See spring-projectsgh-50116

Signed-off-by: Hieu Bui Vinh <buivinhhieu217@gmail.com>
@wilkinsona
Copy link
Copy Markdown
Member

When reviewing this, we should consider 8e5ae84. It was triggered by nullability changes in Spring Security and has a similar end result but was only relevant to main. Getting things aligned across all three branches might save us a bit of merge pain in the future.

@snicoll snicoll self-assigned this Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants