The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(studio): oauth impersonation warning on authorize (#48162)
Danny Whitef7454cf94ee2
diff --git a/apps/design-system/content/docs/ui-patterns/connect-interstitials.mdx b/apps/design-system/content/docs/ui-patterns/connect-interstitials.mdxindex 4457f7ef69c..0ef1e2da938 100644--- a/apps/design-system/content/docs/ui-patterns/connect-interstitials.mdx+++ b/apps/design-system/content/docs/ui-patterns/connect-interstitials.mdx@@ -165,12 +165,17 @@ the pair should use the dark set together.**Where logos come from on `/authorize`**-- Curated partner logos resolve from allowlisted `redirect_uri` hosts only,- not from self-asserted `name` or `website`. Those pairs may use theme tiles- and dark assets when the partner has them.+- Curated partner logos resolve from allowlisted `redirect_uri` hosts, or from+ a trusted partner name when `redirect_uri` is localhost / loopback (local MCP+ clients). Do not resolve curated logos from self-asserted `name` or `website`+ on a remote host. Those pairs may use theme tiles and dark assets when the+ partner has them.- Published organisation OAuth app icons uploaded in Studio remain trustedremote images, paired with forced-light tiles on both sides.- Everything else falls back to `SupabaseLogo` alone.+- If the requester name looks like a known partner but `redirect_uri` is a+ remote host outside that partner's allowlist, show a caution admonition.+ Localhost MCP redirects are excluded.## Account rowdiff --git a/apps/studio/components/interfaces/ApiAuthorization/ApiAuthorization.Form.tsx b/apps/studio/components/interfaces/ApiAuthorization/ApiAuthorization.Form.tsxindex 8a858ec839d..c5269d6ecfb 100644--- a/apps/studio/components/interfaces/ApiAuthorization/ApiAuthorization.Form.tsx+++ b/apps/studio/components/interfaces/ApiAuthorization/ApiAuthorization.Form.tsx@@ -21,8 +21,10 @@ import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'import type { ApprovalState, IApprovalFormSchema } from './ApiAuthorization.Schema'import {AuthorizeConnectLogo,+ AuthorizeImpersonationWarning,AuthorizeRequesterDetails,} from '@/components/interfaces/Organization/OAuthApps/AuthorizeRequesterDetails'+import { getOAuthImpersonationWarning } from '@/components/interfaces/Organization/OAuthApps/OAuthApps.utils'import {InterstitialActionError,InterstitialLayout,@@ -115,6 +117,10 @@ export function ApiAuthorizationMainView({<ExpiredNotice />) : (<>+ <AuthorizeImpersonationWarning+ name={requester.name}+ redirectUri={requester.redirect_uri}+ />{organizations._tag === 'loading' && <OrganizationsLoader />}{organizations._tag === 'error' && (<OrganizationsErrorNotice error={organizations.error} />@@ -312,6 +318,13 @@ function FormFooter({onDecline,onApprove,}: FormFooterProps): ReactNode {+ const hasImpersonationWarning = Boolean(+ getOAuthImpersonationWarning({+ name: requester.name,+ redirectUri: requester.redirect_uri,+ })+ )+return (<div className="flex flex-col gap-2"><ApprovalButton@@ -333,7 +346,10 @@ function FormFooter({{!actionError && redirectUrl && (<div className="mt-3 border-t border-muted pt-5"><p className="text-center text-xs text-foreground-lighter text-balance">- Authorizing will redirect you to <span className="text-foreground">{redirectUrl}</span>+ Authorizing will redirect you to{' '}+ <span className={hasImpersonationWarning ? 'text-warning' : 'text-foreground'}>+ {redirectUrl}+ </span></p></div>)}diff --git a/apps/studio/components/interfaces/Organization/OAuthApps/AuthorizeRequesterDetails.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/AuthorizeRequesterDetails.tsxindex ddff1416f86..ea477f87494 100644--- a/apps/studio/components/interfaces/Organization/OAuthApps/AuthorizeRequesterDetails.tsx+++ b/apps/studio/components/interfaces/Organization/OAuthApps/AuthorizeRequesterDetails.tsx@@ -11,10 +11,11 @@ import {CollapsibleContent,CollapsibleTrigger,} from 'ui'+import { Admonition } from 'ui-patterns/Admonition'import { InfoTooltip } from 'ui-patterns/info-tooltip'import { PERMISSIONS_DESCRIPTIONS } from './OAuthApps.constants'-import { getRequesterLogo } from './OAuthApps.utils'+import { getOAuthImpersonationWarning, getRequesterLogo } from './OAuthApps.utils'import {CONNECT_LOGO_LIGHT_TILE_CLASSNAME,LogoBox,@@ -196,10 +197,11 @@ export const AuthorizeConnectLogo = ({() =>getRequesterLogo({icon,+ name,redirectUri,useDarkVariant: resolvedTheme === 'dark',}),- [icon, redirectUri, resolvedTheme]+ [icon, name, redirectUri, resolvedTheme])const hasUsableLogo = Boolean(logo.src) && failedIcon !== logo.src@@ -227,6 +229,25 @@ export const AuthorizeConnectLogo = ({)}+export const AuthorizeImpersonationWarning = ({+ name,+ redirectUri,+}: {+ name: string+ redirectUri?: string | null+}) => {+ const warning = getOAuthImpersonationWarning({ name, redirectUri })+ if (!warning) return null++ return (+ <Admonition+ type="caution"+ title="Check this redirect before authorizing"+ description={`This request uses the name ${warning.brandDisplayName}, but after you authorize you will be redirected to ${warning.redirectHost}, not ${warning.brandDisplayName}.`}+ />+ )+}+export const AuthorizeRequesterDetails = ({name,scopes,diff --git a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.utils.test.ts b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.utils.test.tsindex cce0b1b7fe9..46f5f78ceeb 100644--- a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.utils.test.ts+++ b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.utils.test.ts@@ -3,6 +3,7 @@ import { describe, expect, test } from 'vitest'import {findTrustedPartnerByRedirectUri,+ getOAuthImpersonationWarning,getRedirectHostname,getRequesterLogo,hostMatchesAllowlist,@@ -60,9 +61,10 @@ describe('findTrustedPartnerByRedirectUri', () => {})describe('getRequesterLogo', () => {- test('uses curated assets only when redirect host is allowlisted', () => {+ test('uses curated assets when redirect host is allowlisted', () => {const trusted = getRequesterLogo({icon: null,+ name: 'Claude',redirectUri: 'https://claude.ai/api/mcp/auth_callback',useDarkVariant: false,})@@ -70,22 +72,97 @@ describe('getRequesterLogo', () => {src: getMcpClientIconSrc({ icon: 'claude', useDarkVariant: false }),isKnownClient: true,})+ })- const namedOnly = getRequesterLogo({- icon: null,- redirectUri: 'https://evil.com/callback',- useDarkVariant: false,+ test('uses curated assets for localhost when the name matches a trusted partner', () => {+ expect(+ getRequesterLogo({+ icon: null,+ name: 'Claude',+ redirectUri: 'http://127.0.0.1:42813/callback',+ useDarkVariant: false,+ })+ ).toEqual({+ src: getMcpClientIconSrc({ icon: 'claude', useDarkVariant: false }),+ isKnownClient: true,})- expect(namedOnly).toEqual({ src: '', isKnownClient: false })+ })++ test('does not use curated assets from name alone on a remote host', () => {+ expect(+ getRequesterLogo({+ icon: null,+ name: 'Claude',+ redirectUri: 'https://evil.com/callback',+ useDarkVariant: false,+ })+ ).toEqual({ src: '', isKnownClient: false })})test('falls back to the supplied icon URL when redirect is not trusted', () => {expect(getRequesterLogo({icon: 'https://example.com/icon.png',+ name: 'Acme',redirectUri: 'https://evil.com/callback',useDarkVariant: false,})).toEqual({ src: 'https://example.com/icon.png', isKnownClient: false })})})++describe('getOAuthImpersonationWarning', () => {+ test('warns when a trusted name redirects to a remote non-allowlisted host', () => {+ expect(+ getOAuthImpersonationWarning({+ name: 'Claude Desktop',+ redirectUri: 'https://evil.com/callback',+ })+ ).toEqual({+ brandDisplayName: 'Claude',+ redirectHost: 'evil.com',+ })+ })++ test('skips localhost MCP redirects', () => {+ expect(+ getOAuthImpersonationWarning({+ name: 'Claude',+ redirectUri: 'http://127.0.0.1:42813/callback',+ })+ ).toBe(null)+ })++ test('skips when redirect host matches the named partner', () => {+ expect(+ getOAuthImpersonationWarning({+ name: 'Claude',+ redirectUri: 'https://claude.ai/api/mcp/auth_callback',+ })+ ).toBe(null)+ })++ test('skips when the name does not match a trusted partner', () => {+ expect(+ getOAuthImpersonationWarning({+ name: 'Acme Tools',+ redirectUri: 'https://evil.com/callback',+ })+ ).toBe(null)+ })++ test('skips missing or unparsable redirect URIs', () => {+ expect(+ getOAuthImpersonationWarning({+ name: 'Claude',+ redirectUri: null,+ })+ ).toBe(null)+ expect(+ getOAuthImpersonationWarning({+ name: 'Claude',+ redirectUri: 'not-a-url',+ })+ ).toBe(null)+ })+})diff --git a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.utils.ts b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.utils.tsindex bc0df5ef05e..e8f942cf7a0 100644--- a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.utils.ts+++ b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.utils.ts@@ -1,6 +1,8 @@import { getMcpClientIconSrc } from 'ui-patterns/McpUrlBuilder'export type TrustedOAuthPartner = {+ /** Substrings matched against the requester name (case-insensitive). */+ nameMatchers: readonly string[]displayName: stringicon: stringhasDistinctDarkIcon: boolean@@ -10,28 +12,34 @@ export type TrustedOAuthPartner = {/*** High-traffic MCP / OAuth partners with curated Connect logos.- * Logos resolve from redirect_uri host only — never from self-asserted name/website.+ * Logos resolve from allowlisted redirect_uri hosts, or from a trusted name when+ * redirect_uri is localhost / loopback (common for local MCP clients).+ * Never from self-asserted name alone on a remote host.*/export const TRUSTED_OAUTH_PARTNERS: readonly TrustedOAuthPartner[] = [{+ nameMatchers: ['claude'],displayName: 'Claude',icon: 'claude',hasDistinctDarkIcon: false,redirectHosts: ['claude.ai', 'anthropic.com'],},{+ nameMatchers: ['cursor'],displayName: 'Cursor',icon: 'cursor',hasDistinctDarkIcon: true,redirectHosts: ['cursor.com', 'cursor.sh'],},{+ nameMatchers: ['chatgpt', 'openai'],displayName: 'ChatGPT',icon: 'openai',hasDistinctDarkIcon: true,redirectHosts: ['chatgpt.com', 'openai.com'],},{+ nameMatchers: ['perplexity'],displayName: 'Perplexity',icon: 'perplexity',hasDistinctDarkIcon: true,@@ -78,24 +86,89 @@ export function findTrustedPartnerByRedirectUri()}+export function findTrustedPartnerByName(name: string): TrustedOAuthPartner | null {+ const searchable = name.toLowerCase()+ return (+ TRUSTED_OAUTH_PARTNERS.find((partner) =>+ partner.nameMatchers.some((matcher) => searchable.includes(matcher))+ ) ?? null+ )+}++function curatedLogoForPartner(+ partner: TrustedOAuthPartner,+ useDarkVariant: boolean+): { src: string; isKnownClient: boolean } | null {+ const customLogoUrl = getMcpClientIconSrc({+ icon: partner.icon,+ useDarkVariant,+ hasDistinctDarkIcon: partner.hasDistinctDarkIcon,+ })+ if (!customLogoUrl) return null+ return { src: customLogoUrl, isKnownClient: true }+}+export function getRequesterLogo({icon,+ name,redirectUri,useDarkVariant,}: {icon: string | null+ name?: string | nullredirectUri: string | null | undefineduseDarkVariant: boolean}): { src: string; isKnownClient: boolean } {- const trusted = findTrustedPartnerByRedirectUri(redirectUri)- if (trusted) {- const customLogoUrl = getMcpClientIconSrc({- icon: trusted.icon,- useDarkVariant,- hasDistinctDarkIcon: trusted.hasDistinctDarkIcon,- })- if (customLogoUrl) return { src: customLogoUrl, isKnownClient: true }+ const byRedirect = findTrustedPartnerByRedirectUri(redirectUri)+ if (byRedirect) {+ const curated = curatedLogoForPartner(byRedirect, useDarkVariant)+ if (curated) return curated+ }++ // Local MCP clients (Claude Desktop, Cursor, etc.) use loopback redirects.+ // Name match is enough there — remote hosts still require the allowlist.+ const hostname = getRedirectHostname(redirectUri)+ if (hostname && isLocalRedirectHost(hostname) && name) {+ const byName = findTrustedPartnerByName(name)+ if (byName) {+ const curated = curatedLogoForPartner(byName, useDarkVariant)+ if (curated) return curated+ }}return { src: icon || '', isKnownClient: false }}++export type OAuthImpersonationWarning = {+ /** Trusted partner label used in the caution copy. */+ brandDisplayName: string+ redirectHost: string+}++/**+ * Warn when the requester name looks like a known partner but redirect_uri is a+ * remote host outside that partner's allowlist. Localhost redirects are skipped+ * (common for local MCP clients). Missing or malformed redirect URIs are skipped.+ */+export function getOAuthImpersonationWarning({+ name,+ redirectUri,+}: {+ name: string+ redirectUri: string | null | undefined+}): OAuthImpersonationWarning | null {+ const namedPartner = findTrustedPartnerByName(name)+ if (!namedPartner) return null++ const hostname = getRedirectHostname(redirectUri)+ if (!hostname || isLocalRedirectHost(hostname)) return null++ if (hostMatchesAllowlist(hostname, namedPartner.redirectHosts)) {+ return null+ }++ return {+ brandDisplayName: namedPartner.displayName,+ redirectHost: hostname,+ }+}diff --git a/apps/studio/tests/components/ApiAuthorization.test.tsx b/apps/studio/tests/components/ApiAuthorization.test.tsxindex 4f88fadf43e..c1046c17aa3 100644--- a/apps/studio/tests/components/ApiAuthorization.test.tsx+++ b/apps/studio/tests/components/ApiAuthorization.test.tsx@@ -148,6 +148,22 @@ describe('AuthorizeConnectLogo', () => {expect(screen.queryByAltText('Claude')).not.toBeInTheDocument()})+ test('pairs curated logos for localhost when the name matches a trusted partner', () => {+ customRender(+ <AuthorizeConnectLogo+ icon={null}+ name="Claude"+ redirectUri="http://127.0.0.1:42813/callback"+ />+ )++ expect(screen.getByAltText('Claude')).toHaveAttribute(+ 'src',+ getMcpClientIconSrc({ icon: 'claude', useDarkVariant: false })+ )+ expect(screen.getByAltText('Supabase')).toBeInTheDocument()+ })+test('shows Supabase alone when the requester has no icon', () => {customRender(<AuthorizeConnectLogo icon={null} name="Acme" />)@@ -346,9 +362,12 @@ describe('ApiAuthorizationScreen', () => {await screen.findByText('Authorize API access for Cursor')expect(screen.getByAltText('Cursor')).toBeInTheDocument()expect(screen.getByAltText('Supabase')).toBeInTheDocument()+ expect(+ screen.queryByText('Check this redirect before authorizing')+ ).not.toBeInTheDocument()})- test('shows Supabase alone when name looks trusted but redirect host is not allowlisted', async () => {+ test('warns when a trusted name redirects to a non-allowlisted host', async () => {mockBothEndpoints(createMockAuthResponse({name: 'Claude',@@ -357,7 +376,14 @@ describe('ApiAuthorizationScreen', () => {}))renderScreen()- await screen.findByText('Authorize API access for Claude')+ expect(+ await screen.findByText('Check this redirect before authorizing')+ ).toBeInTheDocument()+ expect(+ screen.getByText(+ 'This request uses the name Claude, but after you authorize you will be redirected to evil.com, not Claude.'+ )+ ).toBeInTheDocument()expect(screen.queryByAltText('Claude')).not.toBeInTheDocument()expect(screen.getByAltText('Supabase')).toBeInTheDocument()})@@ -382,14 +408,19 @@ describe('ApiAuthorizationScreen', () => {describe('expiration', () => {test('shows expiration warning and hides action buttons when request has expired', async () => {mockBothEndpoints(- createMockAuthResponse({ expires_at: dayjs().subtract(1, 'hour').toISOString() })+ createMockAuthResponse({+ name: 'Claude',+ redirect_uri: 'https://evil.com/callback',+ expires_at: dayjs().subtract(1, 'hour').toISOString(),+ }))renderScreen()await screen.findByText('Authorization request expired')- expect(screen.queryByRole('button', { name: 'Cancel' })).not.toBeInTheDocument()expect(- screen.queryByRole('button', { name: /Authorize Test App/ })+ screen.queryByText('Check this redirect before authorizing')).not.toBeInTheDocument()+ expect(screen.queryByRole('button', { name: 'Cancel' })).not.toBeInTheDocument()+ expect(screen.queryByRole('button', { name: /Authorize Claude/ })).not.toBeInTheDocument()})test('does not show expiration warning when request has not expired', async () => {