Skip to content

chore(sentryapps): Add exp validation and requriement for jwts - #121673

Merged
michelletran-sentry merged 7 commits into
masterfrom
fix/require-exp-client-secret-jwt
Oct 19, 2026
Merged

michelletran-sentry merged 7 commits into
masterfrom
fix/require-exp-client-secret-jwt

Conversation

@Christinarlong

Copy link
Copy Markdown
Contributor

Per VULN-2518

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 10, 2026
@Christinarlong
Christinarlong requested a review from oioki August 10, 2026 22:35
@Christinarlong
Christinarlong marked this pull request as ready for review August 10, 2026 23:47
@Christinarlong
Christinarlong requested review from a team as code owners August 10, 2026 23:47
Comment thread src/sentry/utils/jwt.py
Comment on lines 64 to 65
:param audience: Set this to the audience you expect to be present in the claims. Set
this to ``False`` to disable verifying the audience.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The new options parameter in jwt.decode can be used to pass {"verify_aud": False}, which bypasses audience verification even when an audience is specified.
Severity: MEDIUM

Suggested Fix

The jwt.decode function should be modified to ensure its internal audience verification logic cannot be overridden by the options parameter. When an audience is provided, explicitly set decode_options["verify_aud"] = True. Alternatively, disallow the verify_aud key from being passed in the options dictionary.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/sentry/utils/jwt.py#L64-L65

Potential issue: The introduction of the `options` parameter to the
`sentry.utils.jwt.decode` function allows a caller to bypass audience verification. If a
caller passes `options={"verify_aud": False}` along with a specific `audience`
parameter, the `verify_aud` setting in `options` takes precedence within the underlying
`pyjwt.decode` call. This disables the audience check, creating a latent security
vulnerability. While no current production code exploits this pattern, it enables a
bypass that was not possible before this change and could be inadvertently used in the
future.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment thread src/sentry/api/authentication.py Outdated
encoded_jwt,
client_secret,
algorithms=["HS256"],
options={"require": ["exp"], "verify_exp": True},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on making this option a default configuration in decode? The clanker tells me that there is only one place where exp is potentially missing (Jira Server Webhoks). Making this a default config would harden existing uses of decode and make it easier to do the right thing for any future uses of this method.

@Christinarlong
Christinarlong requested a review from a team as a code owner August 21, 2026 18:17
@Christinarlong
Christinarlong requested a review from a team as a code owner August 24, 2026 19:00
@getsantry

getsantry Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry Bot added the Stale label Sep 16, 2026
@getsantry getsantry Bot closed this Sep 24, 2026
@getsantry getsantry Bot removed the Stale label Sep 26, 2026
@getsantry

getsantry Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry Bot added the Stale label Oct 18, 2026
Christinarlong and others added 5 commits October 19, 2026 09:14
JWT decoding now requires an exp claim by default, so test tokens must include one.

Co-Authored-By: Claude <noreply@anthropic.com>
Reject client-secret JWTs that expire more than an hour in the future, and keep each jti in the replay cache until its JWT expires instead of for a fixed 60 seconds.

Co-Authored-By: Claude <noreply@anthropic.com>
@michelletran-sentry
michelletran-sentry force-pushed the fix/require-exp-client-secret-jwt branch from e4e2d69 to b8e4004 Compare October 19, 2026 14:55
@michelletran-sentry
michelletran-sentry requested a review from a team as a code owner October 19, 2026 14:55
Comment thread src/sentry/api/authentication.py Outdated
Comment thread src/sentry/api/authentication.py Outdated
Comment thread src/sentry/api/authentication.py
…tomically

Lower the maximum client-secret JWT lifetime to 5 minutes, and use cache.add so checking and recording a jti is a single atomic operation.

Co-Authored-By: Claude <noreply@anthropic.com>
@michelletran-sentry
michelletran-sentry requested a review from a team as a code owner October 19, 2026 16:03
Log a warning when a client-secret JWT is rejected for a missing required claim, an expiration too far in the future, or a reused jti, so we can see how many integrations the new checks affect.

Co-Authored-By: Claude <noreply@anthropic.com>
@michelletran-sentry
michelletran-sentry merged commit 2654dee into master Oct 19, 2026
88 checks passed
@michelletran-sentry
michelletran-sentry deleted the fix/require-exp-client-secret-jwt branch October 19, 2026 16:44
RudraPatel2003 pushed a commit that referenced this pull request Oct 19, 2026
Per VULN-2518

---------

Co-authored-by: Michelle Tran <michelle.tran@sentry.io>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants