Repository navigation
fix(cli): Send custom headers on unauthenticated requests only to logged-in hosts - #2548
Merged
Merged
Conversation
…ged-in hosts The share lookup (`getSharedIssue`) and the OAuth device and setup-code exchanges go out without a credential guard, so the custom-header trust check fell back to the active credential's host. For an env token, and an rc `sntrys_` token, that host comes from boot-time `SENTRY_URL`/`SENTRY_HOST`, which a CI step that can write `$GITHUB_ENV` sets without reading the token. Trust only this invocation's `auth login --url` anchor or a stored login on the request's server. Authenticated requests keep checking the credential that `assertCredentialScope` matched. Fixes #2545 Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…s-unauth-login-only # Conflicts: # packages/cli/src/lib/token-host.ts
BYK
approved these changes
Nov 27, 2026
BYK
added a commit
that referenced
this pull request
Nov 27, 2026
…in (#2559) #2548 removed `isRequestOriginTrusted` while #2519 still used it in the wizard's login check, so `main` no longer builds. This uses `isRequestOriginTrustedForContext` with `getCredentialContext()`, the same check the removed helper did. Behaviour doesn't change. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A2b65e7fbe80bb65b0774094cf19fc343 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A2b65e7fbe80bb65b0774094cf19fc343) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A2b65e7fbe80bb65b0774094cf19fc343/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <126780+BYK@users.noreply.github.com>
BYK
added a commit
that referenced
this pull request
Nov 27, 2026
Gets `main` ready for a GitHub merge queue. #2548 removed `isRequestOriginTrusted`, then #2519 merged still importing it and broke `main`. Each PR was fine on its own; a merge queue tests them together. Same approach as getsentry/junior#4469 and getsentry/junior#4533. Merge queue entries skip the per-project matrix. The `quality` job typechecks, builds, and policy-checks the whole workspace instead, which is what two PRs can break together. The `test` aggregator already accepts the skipped jobs. `SENTRY_AUTH_TOKEN` stays off the `quality` job on purpose: when it's set, `@sentry/mcp-cloudflare`'s Vite plugin creates a Sentry release. ## Follow-up (admin) After this merges, a toolkit admin adds a `merge_queue` rule to the repo's `Default` ruleset (id 5058262), with Junior's values: SQUASH, max 5 entries to build, 1 to 5 entries to merge, 5 minute wait, ALLGREEN grouping, 60 minute check timeout, and `test` as the required status. First, confirm the Craft release bot (`sentry-release-bot`) is in the ruleset's `bypass_actors`, because it pushes merge-backs straight to `main`. No getsentry/security-as-code change is needed. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A3843e79a6a769b421c483201d98d7d4e --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A3843e79a6a769b421c483201d98d7d4e) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A3843e79a6a769b421c483201d98d7d4e/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <126780+BYK@users.noreply.github.com>
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.
Fixes #2545.
getSharedIssuesends no bearer token, soassertCredentialScopenever runs on it. Its custom-header check (isRequestOriginTrustedForCustomHeaders) fell back to the active credential's host. For an env token, and for an rcsntrys_token, that host is the boot-timeSENTRY_URL/SENTRY_HOST. A CI step that can write$GITHUB_ENVcan set that without reading the token, so a latersentry issue view <share-url>for its host would send itSENTRY_CUSTOM_HEADERS.isRequestOriginTrustedForCustomHeadersis now the check for every request that has no credential guard. It trusts only:sentry auth login --url), orhasStoredAccountForHost).It no longer looks at the active credential, so env and rc tokens are both covered.
isRequestOriginTrustedwas only used by the old branch, so this removes it.Paths that use this check (all callers of
applyCustomHeadersthat don't pass their own trust):getSharedIssue(lib/api/issues.ts): the reported path.lib/oauth.ts), when there's no--urlanchor. These were already behind the login host guard (isLoginHostTrusted/isAutoLoginHostTrusted). Withauth login --url, the anchor still trusts the host.sentry apipagination (commands/api.ts) calls it only to build a cache-key fingerprint. Nothing is sent there. The real request goes through the authenticated transport.Not changed: authenticated requests (
sentry-client.tsprepareHeaders) still pass trust from the credential thatassertCredentialScopematched, through #2538'sisRequestOriginTrustedForCustomHeadersInContext, so rcsntrys_tokens keep its boot-host rule there. Token refresh (refreshAccessToken) still trusts the stored credential host. Agent handoff still uses its own host guard (isAutoLoginHostTrusted).Behavior change: if you're behind IAP or a proxy and only set
SENTRY_URL/SENTRY_HOSTwith an env or.sentryclirctoken, the share-link lookup insentry issue view <share-url>no longer gets custom headers. To get them, runsentry auth login --url <your-url>once. The self-hosted docs now say this. Authenticated commands against the token's host still send the headers.The docs change went into
apps/cli-docs/src/content/docs/self-hosted.md, the hand-written IAP section, because neither file underapps/cli-docs/src/fragments/covers custom headers.via @BYK.
--
View Session [Sentry]