Skip to content

fix(jira): Add a 'key_id' block list for JIRA installed webhook endpoint #87086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 14, 2025

Conversation

Christinarlong
Copy link
Contributor

@Christinarlong Christinarlong commented Mar 14, 2025

Our Jira installation SLO was failing, because Atlassian sends bots/scanners to "test" their integrators and check if they're working. Some of these bots were hitting our installed webhook endpoint and providing JWTs with a bad key_id(kid) (relevant Sentry issue with details). We would then reach out to Atlassian using the bad kid for the public key and we would get back some 403 Unauthorized HTML. The JWT module would then raise an ValueError when we tried to verify the token using the 403 HTML and cause our metric/SLO to fail.

We're just adding a blocklist, since 1. This module is going to get nuked soon with the Atlassian forge changes and 2. so we only filter out the atlassian bots since they all use the same kid.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 14, 2025
Copy link

codecov bot commented Mar 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #87086    +/-   ##
========================================
  Coverage   87.74%   87.75%            
========================================
  Files        9828     9835     +7     
  Lines      556309   556577   +268     
  Branches    21945    21945            
========================================
+ Hits       488127   488406   +279     
+ Misses      67752    67741    -11     
  Partials      430      430            

@Christinarlong Christinarlong marked this pull request as ready for review March 14, 2025 16:01
@Christinarlong Christinarlong requested review from a team as code owners March 14, 2025 16:01
Comment on lines +59 to +63
if key_id in INVALID_KEY_IDS:
lifecycle.record_halt(halt_reason="JWT contained invalid key_id (kid)")
return self.respond(
{"detail": "Invalid key id"}, status=status.HTTP_400_BAD_REQUEST
)
Copy link
Member

@cathteng cathteng Mar 14, 2025

Choose a reason for hiding this comment

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

i wonder if instead of this, we have a try/except to verify the JWT. if we encounter a ValueError while decoding AND the key is in invalid ids, we should record halt

the reason being we should still allow the decoding to happen as that is the expected behavior, we just don't want the exception to be counted as a failure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this was another option I talked with @GabeVillalobos about, but we went this method as it was easiest and the installation webhook module will get rewritten soon(TM) as Jira Forge uses a different authentication method/doesn't need this JWT verification part.

@Christinarlong Christinarlong merged commit 72ede63 into master Mar 14, 2025
51 checks passed
@Christinarlong Christinarlong deleted the crl/fix-jira-install-slo branch March 14, 2025 20:56
@github-actions github-actions bot locked and limited conversation to collaborators Mar 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants