π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix(security): add ownership validation to MCP token operations (GHSA-p9x3-w98f-7j3q)
mertmit4e736ee40951
diff --git a/packages/nocodb/src/controllers/internal/modules/McpGet.operations.ts b/packages/nocodb/src/controllers/internal/modules/McpGet.operations.tsindex 1dd5e6eff6..d0405a19cb 100644--- a/packages/nocodb/src/controllers/internal/modules/McpGet.operations.ts+++ b/packages/nocodb/src/controllers/internal/modules/McpGet.operations.ts@@ -32,7 +32,7 @@ export class McpGetOperationscase 'mcpList':return await this.mcpService.list(context, req);case 'mcpGet':- return await this.mcpService.get(context, req.query.tokenId as string);+ return await this.mcpService.get(context, req.query.tokenId as string, req);case 'mcpRootList':return await this.mcpService.listByUserId(context, req);}diff --git a/packages/nocodb/src/controllers/internal/modules/McpPost.operations.ts b/packages/nocodb/src/controllers/internal/modules/McpPost.operations.tsindex af7296c3fa..57d91fa2f8 100644--- a/packages/nocodb/src/controllers/internal/modules/McpPost.operations.ts+++ b/packages/nocodb/src/controllers/internal/modules/McpPost.operations.ts@@ -41,9 +41,10 @@ export class McpPostOperationscontext,payload.tokenId,payload,+ req,);case 'mcpDelete':- return await this.mcpService.delete(context, payload.tokenId);+ return await this.mcpService.delete(context, payload.tokenId, req);}}}diff --git a/packages/nocodb/src/services/mcp.service.ts b/packages/nocodb/src/services/mcp.service.tsindex 3922684272..882446cf32 100644--- a/packages/nocodb/src/services/mcp.service.ts+++ b/packages/nocodb/src/services/mcp.service.ts@@ -41,13 +41,17 @@ export class McpTokenService {context: NcContext,tokenId: string,payload: Pick<MCPTokenType, 'token'>,+ req: NcRequest,) {- // Verify token existsconst token = await MCPToken.get(context, tokenId);if (!token) {NcError.get(context).notFound('MCP token not found');}+ if (token.fk_user_id !== req.user.id) {+ NcError.get(context).forbidden('Not authorized to modify this token');+ }+payload.token = nanoid(32);const mcp = await MCPToken.update(context, tokenId, payload);@@ -59,11 +63,15 @@ export class McpTokenService {};}- async delete(context: NcContext, tokenId: string) {+ async delete(context: NcContext, tokenId: string, req: NcRequest) {const token = await MCPToken.get(context, tokenId);if (!token) {- NcError.notFound('MCP token not found');+ NcError.get(context).notFound('MCP token not found');+ }++ if (token.fk_user_id !== req.user.id) {+ NcError.get(context).forbidden('Not authorized to delete this token');}const success = await MCPToken.delete(context, tokenId);@@ -74,10 +82,14 @@ export class McpTokenService {return true;}- async get(context: NcContext, tokenId: string) {+ async get(context: NcContext, tokenId: string, req: NcRequest) {const token = await MCPToken.get(context, tokenId);if (!token) {- NcError.notFound('MCP token not found');+ NcError.get(context).notFound('MCP token not found');+ }++ if (token.fk_user_id !== req.user.id) {+ NcError.get(context).forbidden('Not authorized to access this token');}return {