fix: Enforce organization validation in HS256 token fallback path#1603
Open
harshinsecurity wants to merge 1 commit intoauth0:masterfrom
Open
fix: Enforce organization validation in HS256 token fallback path#1603harshinsecurity wants to merge 1 commit intoauth0:masterfrom
harshinsecurity wants to merge 1 commit intoauth0:masterfrom
Conversation
The HS256 fallback path in validateAuthenticationResponse skips the organization (org_id/org_name) check that is enforced in the RS256 path. After the /userinfo call returns a profile, the code now validates the profile's org_id or org_name against transactionOrganization before accepting the response. Added test coverage for org_id and org_name validation in the HS256 fallback path, including match, mismatch, and missing claim scenarios.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The HS256 fallback path in
validateAuthenticationResponse(src/web-auth/index.js) skips organization validation entirely, while the RS256 path correctly enforces it. This means when an HS256-signed ID token is processed and the/userinfoendpoint is used to build the payload, theorg_id/org_nameclaims from the/userinforesponse are never checked against thetransactionOrganizationvalue stored during the/authorizerequest.Root Cause
In
WebAuth.prototype.validateAuthenticationResponse, there are two branches:payload.org_idorpayload.org_nameagainsttransactionOrganizationbefore accepting the token./userinfo, and then pass the/userinfoprofile directly tocallback(null, profile)without any organization check.The organization check was added to the RS256 path but was never replicated in the HS256 fallback path.
Impact
When all of the following conditions are met:
organizationduring authenticationresponseTypeincludes bothtokenandid_token...the SDK will accept a
/userinforesponse without verifying that the user's organization matches the organization the application expected. This is a defense-in-depth gap — the server-side/authorizeendpoint does enforce organization constraints, but the client-side SDK should also validate as a second layer.Fix
Added the same
transactionOrganizationvalidation logic (checkingorg_idfor IDs starting withorg_, andorg_namefor organization names with case-insensitive comparison) to the HS256 fallback path, executed after/userinforeturns successfully and before accepting the profile.Tests Added
5 new test cases under "Organization validation with HS256 tokens":
All 107 tests pass.
Files Changed
src/web-auth/index.js— Added organization validation after/userinfocallback in HS256 pathtest/web-auth/web-auth.test.js— Added 5 test cases for HS256 organization validationSecurity Contact
Reported by: hi@harshinsecurity.in