Repository navigation
fix(service-accounts): Refuse service account tokens when starting Seer runs - #131251
Merged
skaasten merged 3 commits intoNov 17, 2026
Merged
Conversation
…er runs Starting Autofix or a Seer Agent chat hands Seer a viewer context that names the service account, not the token. Seer's callbacks then get the account's full scopes, so a narrow token could start a run that acts with more than it holds. POST to GroupAutofixEndpoint and OrganizationSeerAgentChatEndpoint now returns 403 user-required for a service account token. Service-account viewer contexts, which Seer itself uses, keep working, and GET is unchanged. Fixes ENG-9057 Co-Authored-By: Shaun Kaasten <[email protected]>
skaasten
marked this pull request as ready for review
November 16, 2026 15:34
…57-block-service-accounts-from-starting # Conflicts: # src/sentry/seer/endpoints/utils.py
gricha
approved these changes
Nov 16, 2026
…57-block-service-accounts-from-starting # Conflicts: # src/sentry/seer/endpoints/group_ai_autofix.py
skaasten
deleted the
shaunkaasten/eng-9057-block-service-accounts-from-starting
branch
November 17, 2026 15:09
skaasten
added a commit
that referenced
this pull request
Nov 17, 2026
…h matrix (#131473) Re-lands #131441, which was reverted in c7135e47542 because it collided with #131251. Service accounts can authenticate with a bearer token (#130914) as well as a viewer context. Before GA, both need to follow the same authorization rules. This adds a `service_account_token` column next to the viewer-context column in the service account auth matrix, so every service account row also runs with a bearer token for the same account. #131251 makes POST to `GroupAutofixEndpoint` return 403 `user-required` for service account tokens. So the token is refused there, but the viewer context isn't: - `SERVICE_ACCOUNT_TOKEN_USER_REQUIRED` lists rows that refuse only the token. Right now that's only `GroupAutofix_post`. - `_assert_service_account_outcome` takes the authentication. For those rows it expects `user-required` with token auth, and the viewer context still has to match the oracle. - `OrganizationSeerAgentChatEndpoint` refuses tokens the same way, but it isn't in the public matrix, so it isn't listed. Test-only change. Refs ENG-9059 <!-- junior-request-attribution:start --> via @skaasten. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent-dispatch%3Adispatch_1a2399a01a018d2d2e0b438397a5e72d --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent-dispatch%3Adispatch_1a2399a01a018d2d2e0b438397a5e72d) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent-dispatch%3Adispatch_1a2399a01a018d2d2e0b438397a5e72d/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Shaun Kaasten <[email protected]>
This branch was successfully deployed
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.
These 2 seer endpoints create viewer contexts based on the service account scopes, not the service account token (which isn't passed in here), so we should block them from service account token auth until we've fixed viewer context to be limited to the token scopes (follow-up).
Starting Autofix or a Seer Agent chat hands Seer a signed viewer context through
get_proxy_headers(). That context names the service account but not the token, so Seer's callbacks get the account's full current scopes. A token limited toevent:writecould start a run whose callbacks act with everything the account holds. Since #130507 tokens can be created, so this path is now reachable for orgs withorganizations:service-accounts.With this change, POST to
GroupAutofixEndpointandOrganizationSeerAgentChatEndpointreturns 403user-requiredwhen the request was authenticated byServiceAccountTokenAuthentication. The check lives in a sharedrefuse_service_account_token()helper inseer/endpoints/utils.py.What stays the same:
requires_user/require_user: they would also turn away userless API keys (401), and Seer's own service-account viewer contexts (403).Open decision. This closes the gap at the two endpoints we know about. Any new endpoint that starts Seer work with proxy headers needs the same call. The broader fix is to carry the token ID or its narrowed scopes in the viewer context and intersect against them on callback. That covers user tokens too, which widen the same way today, so it's left for a follow-up.
Fixes ENG-9057
via @skaasten.
--
View Session [Sentry]