fix(googlechat): validate sub claim for Chat issuer tokens to prevent auth bypass - #3
Open
cubic-dev-ai[bot] wants to merge 1 commit into
Open
fix(googlechat): validate sub claim for Chat issuer tokens to prevent auth bypass#3cubic-dev-ai[bot] wants to merge 1 commit into
cubic-dev-ai[bot] wants to merge 1 commit into
Conversation
… auth bypass The app-url token verification returned ok immediately for the Chat issuer (chat@system.gserviceaccount.com) without checking the sub claim. This allowed tokens from any Google Chat app to authenticate, since Google signs them with the victim's webhook URL as the audience. Require the sub claim (Project Number/App ID) to match the configured appPrincipal for all token types, not only Add-on tokens. Rename the param from expectedAddOnPrincipal to expectedPrincipal to reflect its broader scope. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
app-urltoken verification accepted tokens from any Google Chat app, not just the configured one. Whenemail === CHAT_ISSUER, the function returned{ ok: true }immediately without checking thesubclaim (Project Number/App ID).aud. The token would pass verification because onlyaudandemailwere checked.subclaim to match the configuredappPrincipalfor all token types (both standard Chat issuer and Add-on issuer), not only Add-on tokens.expectedAddOnPrincipal→expectedPrincipalto reflect its broader scope.Changes
extensions/googlechat/src/auth.ts— Unified principal validation: checksubclaim againstexpectedPrincipalfor both Chat issuer and Add-on issuer tokens before returningok: true.extensions/googlechat/src/monitor-webhook.ts— Updated call sites to use renamedexpectedPrincipalparam.extensions/googlechat/src/targets.test.ts— Added tests for Chat issuer principal validation (match, missing, mismatch); updated existing Add-on tests for renamed param and error messages.extensions/googlechat/src/monitor-webhook.test.ts— Updated assertion to use renamed param.Test plan
pnpm test -- extensions/googlechat/src/targets.test.ts— 19 tests pass (includes 3 new Chat issuer principal validation tests)pnpm test -- extensions/googlechat/src/monitor-webhook.test.ts— 2 tests passpnpm test -- extensions/googlechat/src/monitor.webhook-routing.test.ts— 5 tests passpnpm check— lint/format/type-check all passBreaking change note
Deployments using
audienceType: "app-url"must now configureappPrincipal(the GCP Project Number) for their Google Chat account. Without it, webhook verification will reject all incoming tokens with"missing principal binding (appPrincipal config required)".🤖 Generated with Claude Code