🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(ai-team): explicit CORS allowlist and documented public discovery (#3556)
ruv91d203302400
diff --git a/plugins/ruflo-ai-team/.claude-plugin/plugin.json b/plugins/ruflo-ai-team/.claude-plugin/plugin.jsonindex 0eebc6ec39..d08d2ebd5c 100644--- a/plugins/ruflo-ai-team/.claude-plugin/plugin.json+++ b/plugins/ruflo-ai-team/.claude-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "ruflo-ai-team","description": "Give Claude a tenant-isolated AI team that divides work, coordinates progress, recalls approved context, and returns evidence-backed results.",- "version": "0.1.4",+ "version": "0.1.5","author": { "name": "ruvnet", "url": "https://github.com/ruvnet" },"homepage": "https://team.ruv.io","privacyPolicyUrl": "https://team.ruv.io/privacy",diff --git a/plugins/ruflo-ai-team/README.md b/plugins/ruflo-ai-team/README.mdindex d4bf57bda7..2ad7fb10c3 100644--- a/plugins/ruflo-ai-team/README.md+++ b/plugins/ruflo-ai-team/README.md@@ -15,6 +15,20 @@ The public v0.1 surface coordinates work; it does not silently send messages, deThe read-only `team_board` tool opens one compact ruOS-style workspace in ChatGPT. Its Teams, Runs, Tasks, and Evidence rail navigates inside the same card; selecting a run or pressing Refresh calls the same scoped tool through the MCP Apps bridge without asking ChatGPT to render another board. Evidence shows a private run summary; `evidence_export` provides the full bundle in chat. Its public HTML resource contains no tenant data; the tool requires `team:read`. Other tools remain data-only. Historical chat cards are immutable, so open a fresh chat after refreshing tools to see the current UI. `run_complete` requires `team:run` and refuses to complete a run until it has at least one task and every task is complete.+## Public and protected surface++Discovery is deliberately public, so MCP clients and directory reviewers can list the service before a user signs in. Anything tenant-scoped requires OAuth.++| Anonymous (no token) | Requires OAuth (`401` challenge with RFC 9728 metadata otherwise) |+|---|---|+| `initialize`, `ping`, `tools/list`, `prompts/list`, `resources/list` | every `tools/call` |+| `resources/read` of the static board UI (`ui://ruflo-ai-team/board-v4.html`) | every other `resources/read`, including `ruv://team/templates` |+| `/health`, `/.well-known/oauth-protected-resource[/mcp]`, `/privacy`, `/terms`, `/support` | |++The anonymous methods return only static definitions: tool schemas, prompt text, and the two static resource descriptors. They never return team, run, task, memory or evidence data. A bearer token that fails verification is treated as anonymous for these discovery methods only; it never downgrades a protected call.++Cross-origin (browser) reads are limited to an explicit allowlist. By default it covers `https://chatgpt.com`, `https://chat.openai.com` and `https://claude.ai`; set `ALLOWED_ORIGINS` (comma-separated origins) to replace it. The request origin is echoed back only when it is on the list, with `Vary: Origin`. No `access-control-allow-origin` header is sent for any other origin. ChatGPT and Claude call the endpoint server-to-server and the board UI makes no network requests, so the allowlist governs browser-based MCP clients only. Requests without an `Origin` header are unaffected.+Memory search reports `lexical-degraded` unless a compatible native RuVector binding passes the startup probe. The pinned `@ruvector/core` 0.1.32 package with its 0.1.30 optional native binding fails that probe in local validation with a dimension mismatch. Do not set `RUFLO_AI_TEAM_VECTOR=native` in production until a compatible binary is verified.## Local verificationdiff --git a/plugins/ruflo-ai-team/RELEASE_NOTES.md b/plugins/ruflo-ai-team/RELEASE_NOTES.mdindex c431c88032..aaa49b95b0 100644--- a/plugins/ruflo-ai-team/RELEASE_NOTES.md+++ b/plugins/ruflo-ai-team/RELEASE_NOTES.md@@ -1,3 +1,9 @@+# 0.1.5 — Explicit CORS allowlist, documented public discovery (#3556)++- Replaced `access-control-allow-origin: *` with an explicit allowlist: `https://chatgpt.com`, `https://chat.openai.com` and `https://claude.ai` by default, or `ALLOWED_ORIGINS` to replace it. Only an allowlisted request origin is echoed, with `Vary: Origin`; any other origin gets no ACAO header, including on `401` responses.+- Kept MCP discovery (`initialize`, `ping`, `tools/list`, `prompts/list`, `resources/list`) anonymous on purpose, and documented exactly which methods are public and why in the README. `tools/call` and non-UI `resources/read` still require OAuth.+- Added tests: allowlisted and disallowed origins, preflight, server-to-server calls without `Origin`, the env override, protected calls from an allowlisted origin, and anonymous `resources/list` never carrying tenant data.+# 0.1.4 — Larger, clickable workspace rail- Increased the outside gutter around the single ChatGPT workspace and enlarged the sidebar hit targets with hover/focus states.diff --git a/plugins/ruflo-ai-team/deploy/cloud-run.yaml b/plugins/ruflo-ai-team/deploy/cloud-run.yamlindex bc0e221516..f3ac45272e 100644--- a/plugins/ruflo-ai-team/deploy/cloud-run.yaml+++ b/plugins/ruflo-ai-team/deploy/cloud-run.yaml@@ -13,7 +13,7 @@ spec:timeoutSeconds: 60serviceAccountName: ruflo-ai-team@PROJECT_ID.iam.gserviceaccount.comcontainers:- - image: REGION-docker.pkg.dev/PROJECT_ID/ruflo/ruflo-ai-team:0.1.4+ - image: REGION-docker.pkg.dev/PROJECT_ID/ruflo/ruflo-ai-team:0.1.5ports: [{ containerPort: 8080 }]resources:limits: { cpu: "1", memory: 1Gi }@@ -22,3 +22,5 @@ spec:- { name: RUFLO_AI_TEAM_STORE, value: "firestore" }- { name: RUFLO_AI_TEAM_OAUTH_ISSUER, value: "https://auth.cognitum.one" }- { name: RUFLO_AI_TEAM_OAUTH_AUDIENCE, value: "https://team.ruv.io/mcp" }+ # Optional: ALLOWED_ORIGINS replaces the browser CORS allowlist+ # (default: https://chatgpt.com,https://chat.openai.com,https://claude.ai).diff --git a/plugins/ruflo-ai-team/package-lock.json b/plugins/ruflo-ai-team/package-lock.jsonindex 893b43fb3c..3f2012cd5a 100644--- a/plugins/ruflo-ai-team/package-lock.json+++ b/plugins/ruflo-ai-team/package-lock.json@@ -1,12 +1,12 @@{"name": "@ruflo/ai-team-service",- "version": "0.1.4",+ "version": "0.1.5","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@ruflo/ai-team-service",- "version": "0.1.4",+ "version": "0.1.5","license": "MIT","dependencies": {"@google-cloud/firestore": "^9.2.0",diff --git a/plugins/ruflo-ai-team/package.json b/plugins/ruflo-ai-team/package.jsonindex c39dc84b25..3a3795a4d7 100644--- a/plugins/ruflo-ai-team/package.json+++ b/plugins/ruflo-ai-team/package.json@@ -1,6 +1,6 @@{"name": "@ruflo/ai-team-service",- "version": "0.1.4",+ "version": "0.1.5","private": true,"type": "module","description": "Multi-tenant MCP control plane and Claude plugin for coordinated AI teams.",diff --git a/plugins/ruflo-ai-team/src/server.mjs b/plugins/ruflo-ai-team/src/server.mjsindex 5a69e65402..aee0c815b9 100644--- a/plugins/ruflo-ai-team/src/server.mjs+++ b/plugins/ruflo-ai-team/src/server.mjs@@ -14,6 +14,19 @@ export const VERSION = JSON.parse(readFileSync(new URL('../package.json', importconst TEAM_BOARD_URI = 'ui://ruflo-ai-team/board-v4.html';const TEAM_BOARD_HTML = readFileSync(new URL('../ui/team-board.html', import.meta.url), 'utf8');const MAX_BODY = 512 * 1024;+// Browser origins allowed to read responses cross-origin. ChatGPT and Claude+// call the MCP endpoint server-side and the board UI makes no network requests,+// so this only governs browser-based MCP clients. ALLOWED_ORIGINS (comma+// separated) replaces the default list.+export const DEFAULT_ALLOWED_ORIGINS = Object.freeze(['https://chatgpt.com', 'https://chat.openai.com', 'https://claude.ai']);+export function parseAllowedOrigins(value) {+ const list = value == null || String(value).trim() === '' ? DEFAULT_ALLOWED_ORIGINS : String(value).split(',');+ const origins = new Set();+ for (const raw of list) {+ try { const u = new URL(String(raw).trim()); if (u.protocol === 'https:' || u.hostname === 'localhost' || u.hostname === '127.0.0.1') origins.add(u.origin); } catch { /* ignore malformed entries */ }+ }+ return origins;+}const TOOL_SCOPES = Object.freeze({team_templates_list: SCOPES.read, team_list: SCOPES.read, team_get: SCOPES.read, team_board: SCOPES.read,task_list: SCOPES.read, memory_search: SCOPES.read, evidence_export: SCOPES.read,@@ -32,7 +45,8 @@ async function readBody(req) {return Buffer.concat(chunks).toString('utf8');}-export async function createAiTeamService({ store, vectorMemory, verifyToken, port } = {}) {+export async function createAiTeamService({ store, vectorMemory, verifyToken, port, allowedOrigins: allowedOriginsOption } = {}) {+ const allowedOrigins = allowedOriginsOption ? parseAllowedOrigins(allowedOriginsOption.join(',')) : parseAllowedOrigins(process.env.ALLOWED_ORIGINS);store ||= await storeFromEnv();vectorMemory ||= await vectorMemoryFromEnv(store);const publicUrl = (process.env.RUFLO_AI_TEAM_PUBLIC_URL || 'https://team.ruv.io').replace(/\/$/, '');@@ -110,7 +124,9 @@ export async function createAiTeamService({ store, vectorMemory, verifyToken, poconst server = createServer(async (req,res) => {res.setHeader('x-content-type-options','nosniff'); res.setHeader('referrer-policy','no-referrer'); res.setHeader('content-security-policy',"default-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; frame-ancestors 'none'");- res.setHeader('access-control-allow-origin','*'); res.setHeader('access-control-expose-headers','www-authenticate,mcp-session-id,mcp-protocol-version');+ res.setHeader('vary','Origin');+ const origin=req.headers.origin;+ if(origin&&allowedOrigins.has(origin)){res.setHeader('access-control-allow-origin',origin);res.setHeader('access-control-expose-headers','www-authenticate,mcp-session-id,mcp-protocol-version');}const url=new URL(req.url,`http://${req.headers.host||'localhost'}`);if(req.method==='OPTIONS'){res.setHeader('access-control-allow-methods','GET,POST,OPTIONS');res.setHeader('access-control-allow-headers','content-type,authorization,mcp-session-id,mcp-protocol-version,accept');return res.writeHead(204).end();}if(url.pathname==='/health')return res.writeHead(200,{'content-type':'application/json'}).end(JSON.stringify({ok:true,service:'ruflo-ai-team',version:VERSION}));diff --git a/plugins/ruflo-ai-team/test/service.node.mjs b/plugins/ruflo-ai-team/test/service.node.mjsindex 26a0963a79..8932680ed1 100644--- a/plugins/ruflo-ai-team/test/service.node.mjs+++ b/plugins/ruflo-ai-team/test/service.node.mjs@@ -150,3 +150,65 @@ test('prompt-injection memory is rejected before indexing', async (t) => {const search=value(await call(f.base,'memory_search',{teamId:team.id,query:'system prompt',limit:10},'alpha:all'));assert.doesNotMatch(search.data,/Ignore previous instructions/);});++// #3556: discovery stays public on purpose, but cross-origin reads are limited+// to an explicit allowlist instead of `access-control-allow-origin: *`.+const post=(base,body,{origin,token}={})=>fetch(`${base}/mcp`,{method:'POST',headers:{'content-type':'application/json','accept':'application/json, text/event-stream',...(origin?{origin}:{}),...(token?{authorization:`Bearer ${token}`}:{})},body:JSON.stringify(body)});+const listBody={jsonrpc:'2.0',id:1,method:'tools/list',params:{}};++test('an allowlisted origin gets ACAO equal to that origin, never a wildcard', async (t) => {+ const f=await fixture(); t.after(()=>f.server.close());+ for(const origin of ['https://chatgpt.com','https://chat.openai.com','https://claude.ai']){+ const r=await post(f.base,listBody,{origin});+ assert.equal(r.status,200);+ assert.equal(r.headers.get('access-control-allow-origin'),origin);+ assert.match(r.headers.get('vary')||'',/Origin/);+ const pre=await fetch(`${f.base}/mcp`,{method:'OPTIONS',headers:{origin,'access-control-request-method':'POST'}});+ assert.equal(pre.status,204); assert.equal(pre.headers.get('access-control-allow-origin'),origin);+ }+});++test('a disallowed origin gets no ACAO on discovery, preflight or 401 responses', async (t) => {+ const f=await fixture(); t.after(()=>f.server.close());+ const origin='https://evil.example';+ const listed=await post(f.base,listBody,{origin});+ assert.equal(listed.status,200); assert.equal(listed.headers.get('access-control-allow-origin'),null);+ const pre=await fetch(`${f.base}/mcp`,{method:'OPTIONS',headers:{origin,'access-control-request-method':'POST'}});+ assert.equal(pre.headers.get('access-control-allow-origin'),null);+ const denied=await post(f.base,{jsonrpc:'2.0',id:2,method:'tools/call',params:{name:'team_list',arguments:{}}},{origin});+ assert.equal(denied.status,401); assert.equal(denied.headers.get('access-control-allow-origin'),null);+});++test('server-to-server calls without an Origin header keep working', async (t) => {+ const f=await fixture(); t.after(()=>f.server.close());+ const r=await post(f.base,listBody);+ assert.equal(r.status,200); assert.equal(r.headers.get('access-control-allow-origin'),null);+ assert.equal(JSON.parse((await r.text()).split('\n').find(x=>x.startsWith('data: ')).slice(6)).result.tools.length,14);+});++test('tools/call and resources/read still require a token even from an allowlisted origin', async (t) => {+ const f=await fixture(); t.after(()=>f.server.close());+ const origin='https://chatgpt.com';+ const callR=await post(f.base,{jsonrpc:'2.0',id:2,method:'tools/call',params:{name:'team_list',arguments:{}}},{origin});+ assert.equal(callR.status,401); assert.match(callR.headers.get('www-authenticate'),/invalid_token/);+ const readR=await post(f.base,{jsonrpc:'2.0',id:3,method:'resources/read',params:{uri:'ruv://team/templates'}},{origin});+ assert.equal(readR.status,401);+});++test('ALLOWED_ORIGINS replaces the default list; malformed entries are ignored', async (t) => {+ const store=new InMemoryStore(); const vectorMemory=new TenantVectorMemory(store);+ const service=await createAiTeamService({store,vectorMemory,verifyToken:fakeVerify,port:0,allowedOrigins:['https://app.example.com','not a url']});+ const port=await service.listen(0); t.after(()=>service.server.close()); const base=`http://127.0.0.1:${port}`;+ assert.equal((await post(base,listBody,{origin:'https://app.example.com'})).headers.get('access-control-allow-origin'),'https://app.example.com');+ assert.equal((await post(base,listBody,{origin:'https://chatgpt.com'})).headers.get('access-control-allow-origin'),null);+});++test('anonymous resources/list exposes only static resources, never tenant data', async (t) => {+ const f=await fixture(); t.after(()=>f.server.close());+ await call(f.base,'team_create',{name:'Secret Tenant Team',objective:'Private objective xyzzy'},'alpha:all');+ const r=await rpc(f.base,{jsonrpc:'2.0',id:4,method:'resources/list',params:{}});+ assert.equal(r.status,200);+ const uris=r.body.result.resources.map(x=>x.uri).sort();+ assert.deepEqual(uris,['ruv://team/templates','ui://ruflo-ai-team/board-v4.html']);+ assert.doesNotMatch(JSON.stringify(r.body),/Secret Tenant Team|xyzzy/);+});