Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(oauth): allow client redirect_uri origin in consent CSP form-action

oversteppingc2f5882802c1
diff --git a/api/oauth/[action].js b/api/oauth/[action].js
index d19f9758a..c84cef0f4 100644
--- a/api/oauth/[action].js
+++ b/api/oauth/[action].js
@@ -50,7 +50,15 @@ function renderConsent(res, { client, user, params, csrf }) {
res.statusCode = 200;
res.setHeader('content-type', 'text/html; charset=utf-8');
res.setHeader('cache-control', 'no-store');
- res.setHeader('content-security-policy', "default-src 'none'; style-src 'unsafe-inline'; form-action 'self'; frame-ancestors 'none'; base-uri 'none'");
+ // form-action governs the WHOLE submission redirect chain, not just the POST
+ // target. The form posts to /api/oauth/authorize ('self'), which then 302s to
+ // the client's redirect_uri (e.g. https://claude.ai/...). Without the client
+ // origin here, that cross-origin hop is blocked and the OAuth code never
+ // reaches the client. redirect_uri is already validated against the client's
+ // registered URIs before we render, so trusting its origin is safe.
+ let redirectOrigin = '';
+ try { redirectOrigin = ` ${new URL(params.redirect_uri).origin}`; } catch { /* validated upstream */ }
+ res.setHeader('content-security-policy', `default-src 'none'; style-src 'unsafe-inline'; form-action 'self'${redirectOrigin}; frame-ancestors 'none'; base-uri 'none'`);
res.setHeader('x-frame-options', 'DENY');
res.setHeader('x-content-type-options', 'nosniff');
res.setHeader('referrer-policy', 'strict-origin-when-cross-origin');
diff --git a/tests/api/oauth-authorize.test.js b/tests/api/oauth-authorize.test.js
index 14c910745..3e577cc80 100644
--- a/tests/api/oauth-authorize.test.js
+++ b/tests/api/oauth-authorize.test.js
@@ -270,6 +270,10 @@ describe('GET /api/oauth/authorize — consent page render', () => {
// Frame protections present.
expect(res.headers['x-frame-options']).toBe('DENY');
expect(res.headers['content-security-policy']).toMatch(/frame-ancestors 'none'/);
+ // form-action must allow the validated client origin so the post-consent
+ // 302 to the client's redirect_uri isn't blocked by CSP (the bug that
+ // stopped claude.ai connecting). 'self' alone breaks the cross-origin hop.
+ expect(res.headers['content-security-policy']).toMatch(/form-action 'self' https:\/\/client\.test/);
});
});