fix(shared): pin Google OAuth redirect_uri to decocms.com/deco.site allowlist
0X
3mo ago+159+159+012345678901234567890123456789-0-0-0123456789
Summary
createGoogleOAuth()(shared/google-oauth.ts) forwarded the runtime-supplied callback URL verbatim asredirect_urito Google's authorize endpoint and token endpoint. Google delivers the auth code to that host, so an attacker-influenced origin could hijack the code/token — same vuln class fixed for github MCP in #453.- Adds
shared/redirect-allowlist.ts(assertAllowedRedirectUri/isAllowedRedirectUri), allowing hosts underdecocms.comordeco.site(plus their subdomains) over https, and loopback over http for local dev. - Checked
app.jsonacross the 17 MCPs usingcreateGoogleOAuth— most are hosted ondeco.site(sites-<name>.deco.site), onlygoogle-gmailusesdecocms.com, hence both suffixes are allowlisted. - One shared fix covers all active consumers: google-docs, google-analytics, google-meet, google-tag-manager, google-apps-script, google-forms, youtube-channel-admin, google-calendar, google-big-query, google-gmail, google-sheets, google-drive, google-workspace, google-slides, google-search-console. (
grafana/template-minimalhave the oauth block commented out, unaffected.)
Test plan
-
bun test shared/redirect-allowlist.test.ts— 9 pass (canonical origins, subdomains, loopback dev, non-loopback http rejection, look-alike/suffix-confusion hosts, other schemes, case-insensitivity) -
bun run fmt/ pre-commit lint pass - Smoke-test an actual OAuth connect flow for one Google MCP in staging
🤖 Generated with Claude Code
Summary by cubic
Pins Google OAuth redirect_uri to an allowlist under *.decocms.com, *.deco.site, and *.deco.host to prevent auth code/token hijack. Previously createGoogleOAuth forwarded the callback verbatim; now both authorization URL creation and token exchange validate and reject disallowed hosts. Requires https except loopback over http; deco.host is allowed for tunnel-based local dev.
- Adds shared redirect allowlist with
assertAllowedRedirectUri/isAllowedRedirectUriand tests; used by all Google-based MCPs.
Required actions
- Use https callbacks under
*.deco.site,*.decocms.com, or*.deco.host. For local dev, usehttp://localhost/http://127.0.0.1, or an https*.deco.hosttunnel. - Update any custom-domain callbacks; disallowed hosts will throw “Refusing OAuth redirect_uri …”. Smoke-test one Google OAuth flow in staging.