Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
docs(auth): OAuth connection security page (good-docs-writing voice)
Anshu Gargd9b7ec54b794
diff --git a/docs/agent/instructions/context.md b/docs/agent/instructions/context.mdindex e0a39e040..5f3e5b577 100644--- a/docs/agent/instructions/context.md+++ b/docs/agent/instructions/context.md@@ -24,6 +24,7 @@ This is your always-on map of Composio's concepts and the canonical page for eac- **Manual auth** — generate Connect Links yourself with `session.authorize()`. → [Manually authenticating users](/docs/authenticating-users/manually-authenticating)- **Managed vs custom auth** — use Composio's managed OAuth apps, or bring your own for branding/scopes. → [Managed vs custom auth](/docs/custom-app-vs-managed-app)- **White-labeling** — remove Composio branding from the auth flow. → [White-labeling authentication](/docs/white-labeling-authentication)+- **OAuth connection security** — two controls against OAuth session fixation: same-browser binding (managed apps; the `This connection was started from a different browser or device` rejection and the in-app-browser limitation) and callback identity verification (custom auth configs; verifier URL + `complete_auth`). This is the page for "connections from the dashboard stopped completing" and "a real `user_id` is now required". → [OAuth connection security](/docs/oauth-connection-security)- **Importing existing connections** — pass in API keys or bearer tokens you already hold. → [Importing existing connections](/docs/importing-existing-connections)- **Multiple accounts per user** — e.g. work and personal Gmail. → [Managing multiple connected accounts](/docs/managing-multiple-connected-accounts)- **Shared connections** — share one connected account across users via an ACL. → [Shared connections](/docs/authenticating-users/shared-connections)diff --git a/docs/content/changelog/07-30-26-oauth-connection-binding.mdx b/docs/content/changelog/07-30-26-oauth-connection-binding.mdxnew file mode 100644index 000000000..78ec3d2b7--- /dev/null+++ b/docs/content/changelog/07-30-26-oauth-connection-binding.mdx@@ -0,0 +1,23 @@+---+title: "OAuth connection security: same-browser binding and callback identity verification"+date: "2026-07-30"+description: "Stop an OAuth connection from being completed by another party: same-browser binding on Composio-managed apps, and opt-in, per-project callback identity verification."+---++Composio now stops an OAuth connection from being completed by someone other than the person who+started it. On Composio-managed apps this is enforced automatically, bound to the browser that+started the flow. Any project can also opt into callback identity verification, which ties activation+to the user — the durable way to secure your own OAuth apps.++### What shipped++- **Same-browser binding** — for **Composio-managed apps** (default auth configs). Because Composio+ owns the OAuth app here, it enforces this automatically: a Connect Link must be completed in the+ browser that started it, and a callback from a different browser is rejected. It stays on for every+ managed connection, including where identity verification is also enabled. No setup required.+ [Learn more](/docs/oauth-connection-security#same-browser-binding)+- **Callback identity verification** — an opt-in, per-project identity check, and the most reliable+ way to secure your **own OAuth apps**. Set a verifier URL, and Composio holds every OAuth connection+ in the project — managed and custom alike — until your server confirms the returning user matches+ the one it was created for. Enable it in Settings → General.+ [Learn more](/docs/oauth-connection-security#callback-identity-verification)diff --git a/docs/content/docs/meta.json b/docs/content/docs/meta.jsonindex 05214a485..7e89d31e4 100644--- a/docs/content/docs/meta.json+++ b/docs/content/docs/meta.json@@ -13,6 +13,7 @@"---Authenticate users---","authentication","manually-authenticating",+ "oauth-connection-security","managing-multiple-connected-accounts","shared-connections","importing-existing-connections",diff --git a/docs/content/docs/oauth-connection-security.mdx b/docs/content/docs/oauth-connection-security.mdxnew file mode 100644index 000000000..0da48ae25--- /dev/null+++ b/docs/content/docs/oauth-connection-security.mdx@@ -0,0 +1,163 @@+---+title: OAuth connection security+description: "Protect an OAuth connection from being completed by another party: same-browser binding on Composio managed apps, and opt-in callback identity verification per project."+keywords: [oauth session fixation, same-browser binding, callback identity verification, user verification, connect link, verifier url, complete_auth]+---++On its own, a Connect Link or provider authorization URL is enough to complete an OAuth connection:+whoever opens it and consents becomes the account attached to the flow. That is exploitable. Someone+starts a connection under their own Composio user, copies the authorization URL before consenting,+and gets a different person to finish it. The victim's provider account ends up attached to the+attacker's identity.++This is **OAuth session fixation**. Composio stops it two ways.++**[Same-browser binding](#same-browser-binding)** runs automatically on Composio managed apps, with+no setup from you. These apps are shared across every Composio user, so anyone can start a connection+with one. Binding ties each authorization attempt to the browser that began it, so a flow one person+starts can't be finished in another browser.++**[Callback identity verification](#callback-identity-verification)** is how you secure connections+on your own OAuth apps. Composio holds each connection until your server confirms the user who came+back, and activates it only when that user matches the one the flow was created for. It checks the+user rather than the browser, so it holds however the user returns from the provider, with none of+the same-browser edge cases. It's opt-in per project, and once you turn it on it covers every OAuth+connection in that project, managed and custom alike.++## Same-browser binding++On Composio managed apps, a connection has to be finished in the same browser that started it. When+the Connect Link is submitted, Composio sets a secure cookie in that browser and checks it when the+provider returns, so a link can't be carried to another browser and completed there. This runs+automatically, with nothing to configure.++<Callout type="warn">+**This check can block some of your real users.** If someone opens the Connect Link in one browser+but the provider sends them back to another, the connection is rejected with *"This connection was+started from a different browser or device"*. It usually happens with in-app browsers (Instagram,+LinkedIn, and similar) that hand the provider step off to the system browser, or when cookies are+blocked. Reopening the link and finishing it in one browser gets them through.++You can't turn this check off on managed apps. Composio's OAuth app is shared across every Composio+user, so without it a connection one person starts could be finished by another. If it's blocking+your users, bring your own OAuth app and turn on+[callback identity verification](#callback-identity-verification). That binds each connection to your+signed-in user instead of the browser, so it holds however the user returns from the provider.+</Callout>++## Callback identity verification++Set a verifier URL on a project, and Composio stops activating OAuth connections there until your+server confirms who came back. After the provider callback, Composio redirects the browser to an+endpoint you host. Your server returns the signed-in `user_id`, and Composio activates the connection+only if it matches the user the connection was created for.++### Roles++- **Your server asserts identity.** It reads its own session and returns the signed-in `user_id`.+- **Composio verifies it.** It compares that `user_id` against the user the connection was created+ for, then activates or rejects.++The endpoint you host stays small: read a session, call one Composio API, and redirect the user+onward.++### How it works++<Steps>+<Step>+<StepTitle>The user consents at the provider</StepTitle>++Create the connection as usual, passing the `user_id` you're connecting for.+</Step>++<Step>+<StepTitle>Composio redirects to your verifier URL</StepTitle>++Instead of activating the connection, Composio redirects the browser to the URL you configured,+whatever path you set, with one query parameter appended: `session_uri`. For a configured URL of+`https://your-app.com/oauth/return`:++```+https://your-app.com/oauth/return?session_uri=session_8Ff2...+```++`session_uri` is the only parameter Composio sends. It carries no connection id, user id, or toolkit+name.+</Step>++<Step>+<StepTitle>Your server identifies the user</StepTitle>++Read your session from the incoming request and determine the signed-in `user_id`.+</Step>++<Step>+<StepTitle>Redeem the session</StepTitle>++This call runs from your server, authenticates with your project API key, and must not run in the+browser. `POST` the `session_uri` and `user_id` to `complete_auth`:++```bash+curl -X POST https://backend.composio.dev/api/v3.1/connected_accounts/complete_auth \+ -H "x-api-key: $COMPOSIO_API_KEY" \+ -H "Content-Type: application/json" \+ -d '{+ "session_uri": "session_8Ff2...",+ "user_id": "your-signed-in-user"+ }'+```++On a match, the connection activates and the response returns `connected_account_id` and+`toolkit_slug`. A `200` comes back only once the connection is `ACTIVE`, so there's nothing to poll.+If the `user_id` doesn't match, the request returns `400` and the connection moves to `FAILED`;+restart the flow if you need to. See the+[API reference](/reference/api-reference/connected-accounts/postConnectedAccountsCompleteAuth) for+the full response contract.+</Step>++<Step>+<StepTitle>Redirect the user</StepTitle>++The browser ends at your endpoint. Your server owns the redirect on success and the failure page on+rejection.+</Step>+</Steps>++### How to enable it++Set the verifier URL in **Settings → General → Configuration**. The URL must be public HTTPS.+Composio validates it on save and rejects private and reserved addresses, so local development needs a+tunnel rather than `localhost`. The presence of the URL is the switch: remove it to disable+verification.++<Callout type="warn">+A verifier URL takes effect immediately for every OAuth connection in the project. There's no staged+rollout and no per-connection opt-out. Review the constraints below and deploy your endpoint before+you set the URL.+</Callout>++### What to expect once it's on++**Dashboard connections can't complete.** The dashboard still creates a pending connection and opens+the provider consent screen, but on the callback Composio redirects the browser to your verifier URL+instead of back to the dashboard. Your endpoint reports the user signed into your app, and Composio+activates only if that matches the connection's owner. A dashboard connection is owned by a Composio+dashboard user: not one of your app's users, and not disclosed to your endpoint, so your app can't+report a match, and the connection never activates. To test a connection, run the flow from your own+app, or clear the verifier URL while you work in the dashboard.++**Verification covers the connections you create.** It applies to every OAuth connection in the+project that goes through a provider redirect, whether you start it from the API or a hosted Connect+Link.++**Managed connections keep their browser binding.** On a managed connection, a verifier URL adds+identity verification on top of same-browser binding; it doesn't switch the binding off. Composio's+managed OAuth app is shared across every Composio user, so Composio enforces that binding itself+rather than handing the guarantee to any one project. A managed connection with a verifier URL set is+covered by both checks.++### Session lifetime++`session_uri` is valid for ten minutes and can be redeemed once, so redeem it on the incoming request+rather than later. A second redemption of the same value returns `404`. Activation always requires a+matching `user_id`, so a connection can never complete for the wrong user.