Skip to content

Redact sensitive parameter options in AccessToken initialize error description - #776

Merged
pboling merged 1 commit into
ruby-oauth:mainfrom
Huge:fix/access-token-error-leak
Oct 25, 2026
Merged

pboling merged 1 commit into
ruby-oauth:mainfrom
Huge:fix/access-token-error-leak

Conversation

@Huge

@Huge Huge commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When OAuth2::AccessToken.new is initialized without token or refresh token values and @client.options[:raise_errors] is true, OAuth2::AccessToken#initialize raises OAuth2::Error with error_description: "Options are: #{opts.inspect}".

At this point, opts retains unconsumed response parameters from the token endpoint (such as OpenID Connect id_token JWTs, 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

  • Added sanitize_opts and sensitive_opts_key? to sanitize opts before inspecting them in OAuth2::Error.
  • Replaced values of sensitive keys (id_token, client_secret, password, assertion, token aliases) with [FILTERED] (using OAuth2::AUTH_SANITIZER.filtered_label).
  • Added regression specs in spec/oauth2/access_token_spec.rb verifying that sensitive parameters in opts are redacted and not exposed in the error message.

Vulnerability identified by BudgetScan static analysis.

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
@pboling

pboling commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

@Huge This is pretty good. I'm releasing a new auth-sanitizer that will have a tool you can use to simplify this.

Auth::Sanitizer.sanitize(value, filtered_keys:, label:)

ruby-oauth/auth-sanitizer#27

Also - I have the CI issues resolved separately. I'll have that into main shortly as well.

@pboling
pboling merged commit 65a21fc into ruby-oauth:main Oct 25, 2026
30 of 40 checks passed
@Huge

Huge commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @pboling for the quick review, merge, and for adding the sanitizer helper in auth-sanitizer#27! Really appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants