Repository navigation
Redact sensitive parameter options in AccessToken initialize error description - #776
Merged
Merged
Conversation
When no access or refresh token is present and raise_errors is true, sanitize opts before inspecting them into OAuth2::Error to prevent leaking sensitive values such as id_token, client_secret, or other credentials. Reported-by: BS.ehlas.cz
Member
|
@Huge This is pretty good. I'm releasing a new Auth::Sanitizer.sanitize(value, filtered_keys:, label:)Also - I have the CI issues resolved separately. I'll have that into main shortly as well. |
Contributor
Author
|
Thanks @pboling for the quick review, merge, and for adding the sanitizer helper in |
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
When
OAuth2::AccessToken.newis initialized without token or refresh token values and@client.options[:raise_errors]is true,OAuth2::AccessToken#initializeraisesOAuth2::Errorwitherror_description: "Options are: #{opts.inspect}".At this point,
optsretains unconsumed response parameters from the token endpoint (such as OpenID Connectid_tokenJWTs, client credentials, or alternative token values). When the exception is logged or inspected by application error trackers, these sensitive values are serialized into the exception message.Changes
sanitize_optsandsensitive_opts_key?to sanitizeoptsbefore inspecting them inOAuth2::Error.id_token,client_secret,password,assertion, token aliases) with[FILTERED](usingOAuth2::AUTH_SANITIZER.filtered_label).spec/oauth2/access_token_spec.rbverifying that sensitive parameters inoptsare redacted and not exposed in the error message.Vulnerability identified by BudgetScan static analysis.