Skip to content

Commit 43e497d

Browse files
fix(tables): restore the workspace ownership check on copilot row deletes
Switching deleteRow/deleteRowsByIds to take a TableDefinition dropped the workspaceId argument that previously scoped the query, and the two branches I added loaded the table without the ownership comparison every other operation in the tool performs — letting a caller delete rows from a table in another workspace. Both now reject a foreign table as not found.
1 parent fca76b0 commit 43e497d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

apps/sim/lib/copilot/tools/server/table/user-table.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,10 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
775775
const requestId = generateId().slice(0, 8)
776776
assertNotAborted()
777777
const deleteRowTable = await getTableById(args.tableId)
778-
if (!deleteRowTable) {
778+
// The old signature passed `workspaceId` into `deleteRow`, which scoped
779+
// the query; taking a TableDefinition instead means the ownership check
780+
// has to happen here, as every other operation in this tool does.
781+
if (!deleteRowTable || deleteRowTable.workspaceId !== workspaceId) {
779782
return { success: false, message: `Table ${args.tableId} not found` }
780783
}
781784
await deleteRow(deleteRowTable, args.rowId, requestId)
@@ -1101,7 +1104,7 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
11011104
const requestId = generateId().slice(0, 8)
11021105
assertNotAborted()
11031106
const batchDeleteTable = await getTableById(args.tableId)
1104-
if (!batchDeleteTable) {
1107+
if (!batchDeleteTable || batchDeleteTable.workspaceId !== workspaceId) {
11051108
return { success: false, message: `Table ${args.tableId} not found` }
11061109
}
11071110
const result = await deleteRowsByIds(

0 commit comments

Comments
 (0)