TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.
TypeScript graphviewkanban-boardnodejsproductivityproject-managementself-hostedtasktask-managementtask-managertodoapp
fix: whitelist columns in task and list update
Nikolai Gimanb2414eaf3756
diff --git a/api/package.json b/api/package.jsonindex 94d8d61..80c0cb8 100644--- a/api/package.json+++ b/api/package.json@@ -1,6 +1,6 @@{"name": "taskview-ce-api-server",- "version": "1.54.0",+ "version": "1.55.0","scripts": {"dev": "bun run --watch ./server.ts","start": "NODE_ENV=production node ./dist/taskview-server.js",diff --git a/api/src/tv-modules/auth/__tests__/Auth.spec.ts b/api/src/tv-modules/auth/__tests__/Auth.spec.tsindex 81be594..2714a12 100644--- a/api/src/tv-modules/auth/__tests__/Auth.spec.ts+++ b/api/src/tv-modules/auth/__tests__/Auth.spec.ts@@ -14,6 +14,7 @@ const url = `http://localhost:${port}`;let server: http.Server;let deleteTestUserEmail: string = '';+const registeredEmails: string[] = [];describe('Login API', () => {vi.mock('emailjs', () => ({@@ -35,7 +36,10 @@ describe('Login API', () => {afterAll(async () => {server.close();const db = Database.getInstance();- await db.query("delete from tv_auth.users where login not in ('user', 'user1', 'user3')");+ // Only this file's users: auth specs run in parallel against one database+ if (registeredEmails.length) {+ await db.query('delete from tv_auth.users where email = any($1::text[])', [registeredEmails]);+ }});it('should send a login request and receive a tokens', async () => {@@ -76,6 +80,7 @@ describe('Login API', () => {it('Registration', async () => {deleteTestUserEmail = `${Date.now()}[email protected]`;+ registeredEmails.push(deleteTestUserEmail);const email = deleteTestUserEmail;const password = 'user1!#Q';const passwordRepeat = 'user1!#Q';@@ -97,6 +102,7 @@ describe('Login API', () => {const userModel = new AuthModel();deleteTestUserEmail = `${Date.now()}[email protected]`;+ registeredEmails.push(deleteTestUserEmail);const email = deleteTestUserEmail;const password = 'user1!#Q';const passwordRepeat = 'user1!#Q';@@ -120,6 +126,7 @@ describe('Login API', () => {it('remindPassword', async () => {deleteTestUserEmail = `${Date.now()}[email protected]`;+ registeredEmails.push(deleteTestUserEmail);const email = deleteTestUserEmail;const password = 'user1!#Q';const passwordRepeat = 'user1!#Q';@@ -139,6 +146,7 @@ describe('Login API', () => {it('changeRemindedPassword', async () => {deleteTestUserEmail = `${Date.now()}[email protected]`;+ registeredEmails.push(deleteTestUserEmail);const email = deleteTestUserEmail;const password = 'user1!#Q';const passwordRepeat = 'user1!#Q';@@ -182,6 +190,7 @@ describe('Login API', () => {it('logout', async () => {deleteTestUserEmail = `${Date.now()}[email protected]`;+ registeredEmails.push(deleteTestUserEmail);const email = deleteTestUserEmail;const password = 'user1!#Q';const passwordRepeat = 'user1!#Q';@@ -218,11 +227,12 @@ describe('Login API', () => {});- expect(response3.status).toBe(200);+ expect(response3.status).toBe(204);});it('logout without token', async () => {deleteTestUserEmail = `${Date.now()}[email protected]`;+ registeredEmails.push(deleteTestUserEmail);const email = deleteTestUserEmail;const password = 'user1!#Q';const passwordRepeat = 'user1!#Q';@@ -268,6 +278,7 @@ describe('Login API', () => {it('refreshToken', async () => {deleteTestUserEmail = `${Date.now()}[email protected]`;+ registeredEmails.push(deleteTestUserEmail);const email = deleteTestUserEmail;const password = 'user1!#Q';const passwordRepeat = 'user1!#Q';@@ -317,6 +328,7 @@ describe('Login API', () => {it('Send delete code to email', async () => {deleteTestUserEmail = `${Date.now()}[email protected]`;+ registeredEmails.push(deleteTestUserEmail);const email = deleteTestUserEmail;const password = 'user1!#Q';const passwordRepeat = 'user1!#Q';@@ -358,6 +370,7 @@ describe('Login API', () => {it('Send delete code to email NO AUTH', async () => {deleteTestUserEmail = `${Date.now()}[email protected]`;+ registeredEmails.push(deleteTestUserEmail);const email = deleteTestUserEmail;const password = 'user1!#Q';const passwordRepeat = 'user1!#Q';@@ -395,6 +408,7 @@ describe('Login API', () => {it('Account deletion', async () => {deleteTestUserEmail = `${Date.now()}[email protected]`;+ registeredEmails.push(deleteTestUserEmail);const email = deleteTestUserEmail;const password = 'user1!#Q';const passwordRepeat = 'user1!#Q';@@ -459,6 +473,7 @@ describe('Login API', () => {it('Account deletion NO AUTH', async () => {deleteTestUserEmail = `${Date.now()}[email protected]`;+ registeredEmails.push(deleteTestUserEmail);const email = deleteTestUserEmail;const password = 'user1!#Q';const passwordRepeat = 'user1!#Q';@@ -515,6 +530,7 @@ describe('Login API', () => {it('loginByCode confirms and admits a blocked-unconfirmed account', async () => {deleteTestUserEmail = `${Date.now()}[email protected]`;+ registeredEmails.push(deleteTestUserEmail);const email = deleteTestUserEmail;await axios.post(`${url}/module/auth/registration`, {@@ -545,6 +561,7 @@ describe('Login API', () => {it('loginByCode rejects a banned account (blocked, no confirm code)', async () => {deleteTestUserEmail = `${Date.now()}[email protected]`;+ registeredEmails.push(deleteTestUserEmail);const email = deleteTestUserEmail;await axios.post(`${url}/module/auth/registration`, {diff --git a/api/src/tv-modules/auth/__tests__/AuthModel.spec.ts b/api/src/tv-modules/auth/__tests__/AuthModel.spec.tsindex 702c12d..ddc4ccd 100644--- a/api/src/tv-modules/auth/__tests__/AuthModel.spec.ts+++ b/api/src/tv-modules/auth/__tests__/AuthModel.spec.ts@@ -1,4 +1,4 @@-import { beforeEach, describe, expect, it } from 'vitest';+import { afterAll, beforeEach, describe, expect, it } from 'vitest';import { Database } from '../../../modules/db';import type { RegisterUserInDb } from '../../../types/auth.types';import AuthModel from '../AuthModel';@@ -7,9 +7,17 @@ describe('AuthModel Integration Tests', () => {let authModel: AuthModel;let emailNum: number;+ const prefixes: string[] = [];+beforeEach(async () => {authModel = new AuthModel();emailNum = Date.now();+ prefixes.push(String(emailNum));+ });++ afterAll(async () => {+ const logins = prefixes.flatMap((prefix) => [`${prefix}testuser`, `${prefix}testuser2`]);+ await Database.getInstance().query('delete from tv_auth.users where login = any($1::text[])', [logins]);});it('registerUserInDb', async () => {diff --git a/api/src/tv-modules/auth/__tests__/JwtStorage.spec.ts b/api/src/tv-modules/auth/__tests__/JwtStorage.spec.tsindex ba148f6..e555eba 100644--- a/api/src/tv-modules/auth/__tests__/JwtStorage.spec.ts+++ b/api/src/tv-modules/auth/__tests__/JwtStorage.spec.ts@@ -10,6 +10,7 @@ describe('SessionStorage Integration Tests', () => {let emailNum: number;let userId: number;let sessionId: number;+ const createdUserIds: number[] = [];beforeEach(async () => {sessionStorage = new SessionStorage();@@ -24,12 +25,15 @@ describe('SessionStorage Integration Tests', () => {block: 0,};userId = (await authModel.registerUserInDb(userData)) as number;+ createdUserIds.push(userId);sessionId = (await sessionStorage.createSession(userId, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Chrome/120')) as number;});afterAll(async () => {const db = Database.getInstance();- await db.query("delete from tv_auth.users where login not in ('user', 'user1', 'user3')");+ if (createdUserIds.length) {+ await db.query('delete from tv_auth.users where id = any($1::int[])', [createdUserIds]);+ }});it('createSession', async () => {diff --git a/api/src/tv-modules/invoices/__tests__/Invoices.integration.spec.ts b/api/src/tv-modules/invoices/__tests__/Invoices.integration.spec.tsindex c4fe24c..aaf7046 100644--- a/api/src/tv-modules/invoices/__tests__/Invoices.integration.spec.ts+++ b/api/src/tv-modules/invoices/__tests__/Invoices.integration.spec.ts@@ -3,7 +3,7 @@ import type http from 'http'import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'import App from '../../../App'-const port = 1811+const port = 1814const api = axios.create({ baseURL: `http://localhost:${port}`, validateStatus: () => true })const LOGIN = '[email protected]'diff --git a/api/src/tv-modules/lists/GoalListsRepository.ts b/api/src/tv-modules/lists/GoalListsRepository.tsindex 8bd0c08..bf3a306 100644--- a/api/src/tv-modules/lists/GoalListsRepository.ts+++ b/api/src/tv-modules/lists/GoalListsRepository.ts@@ -97,8 +97,19 @@ export class GoalListsRepository {}async updateListNew(data: GoalListArgUpdate): Promise<GoalsListSchemaTypeForSelect[]> {+ const updates: Partial<typeof GoalsListSchema.$inferInsert> = {};+ if (data.name !== undefined && data.name !== null) updates.name = data.name;+ if (data.description !== undefined) updates.description = data.description;++ if (Object.keys(updates).length === 0) {+ const current = await callWithCatch(() =>+ this.db.dbDrizzle.select().from(GoalsListSchema).where(eq(GoalsListSchema.id, data.id)).limit(1)+ );+ return current ?? [];+ }+const result = await callWithCatch(() =>- this.db.dbDrizzle.update(GoalsListSchema).set(data).where(eq(GoalsListSchema.id, data.id)).returning()+ this.db.dbDrizzle.update(GoalsListSchema).set(updates).where(eq(GoalsListSchema.id, data.id)).returning());if (!result) {return [];diff --git a/api/src/tv-modules/lists/__tests__/GoalListsMassAssignment.spec.ts b/api/src/tv-modules/lists/__tests__/GoalListsMassAssignment.spec.tsnew file mode 100644index 0000000..517f514--- /dev/null+++ b/api/src/tv-modules/lists/__tests__/GoalListsMassAssignment.spec.ts@@ -0,0 +1,74 @@+import { afterEach, describe, expect, it, vi } from 'vitest';+import { Database } from '../../../modules/db';+import { GoalListsRepository } from '../GoalListsRepository';++vi.mock('../../../modules/db', () => ({+ Database: {+ getInstance: vi.fn(),+ },+}));++function mockUpdateChain(returningRow: object = {}) {+ const set = vi.fn((_values: Record<string, unknown>) => ({ where: () => ({ returning: async () => [returningRow] }) }));+ const update = vi.fn(() => ({ set }));+ // where() is awaited directly by the task lookup and .limit()-ed by the list lookup+ const whereResult = Object.assign(Promise.resolve([returningRow]), { limit: async () => [returningRow] });+ const select = vi.fn(() => ({ from: () => ({ where: () => whereResult }) }));+ vi.mocked(Database.getInstance).mockReturnValue({ dbDrizzle: { update, select } } as any);+ return { set, update, select };+}++describe('GoalListsRepository.updateListNew mass-assignment guard', () => {+ afterEach(() => {+ vi.clearAllMocks();+ });++ it('drops goalId, owner, creatorId and archive injected next to a legitimate field', async () => {+ const { set } = mockUpdateChain();+ const repository = new GoalListsRepository();++ await repository.updateListNew({+ id: 1,+ name: 'renamed',+ goalId: 3,+ owner: 9,+ creatorId: 9,+ archive: 1,+ someOther: 1+ } as any);++ expect(set).toHaveBeenCalledTimes(1);+ expect(set.mock.calls[0][0]).toEqual({ name: 'renamed' });+ });++ it('still writes name and description', async () => {+ const { set } = mockUpdateChain();+ const repository = new GoalListsRepository();++ await repository.updateListNew({ id: 1, name: 'n', description: null });++ expect(set.mock.calls[0][0]).toEqual({ name: 'n', description: null });+ });++ it('does not issue an UPDATE when only server-managed columns were sent', async () => {+ const row = { id: 1, goalId: 2, name: 'untouched' };+ const { set, update, select } = mockUpdateChain(row);+ const repository = new GoalListsRepository();++ const result = await repository.updateListNew({ id: 1, goalId: 3 } as any);++ expect(update).not.toHaveBeenCalled();+ expect(set).not.toHaveBeenCalled();+ expect(select).toHaveBeenCalledTimes(1);+ expect(result).toEqual([row]);+ });++ it('ignores a null name, since the column is NOT NULL', async () => {+ const { set } = mockUpdateChain();+ const repository = new GoalListsRepository();++ await repository.updateListNew({ id: 1, name: null, description: 'd' });++ expect(set.mock.calls[0][0]).toEqual({ description: 'd' });+ });+});diff --git a/api/src/tv-modules/organizations/__tests__/TokenScope.integration.spec.ts b/api/src/tv-modules/organizations/__tests__/TokenScope.integration.spec.tsindex 9e185cc..de97c93 100644--- a/api/src/tv-modules/organizations/__tests__/TokenScope.integration.spec.ts+++ b/api/src/tv-modules/organizations/__tests__/TokenScope.integration.spec.ts@@ -87,7 +87,7 @@ describe('API token scope on organization-level surfaces', () => {'SELECT name FROM tv_auth.permissions WHERE permission_group = 6 ORDER BY name',);expect(result?.rows.map((row) => row.name)).toEqual([- 'org_can_manage', 'org_can_manage_members', 'org_can_view', 'sso_can_manage', 'webhooks_can_manage',+ 'billing_can_manage', 'org_can_manage', 'org_can_manage_members', 'org_can_view', 'sso_can_manage', 'webhooks_can_manage',]);});diff --git a/api/src/tv-modules/tasks/TasksRepository.ts b/api/src/tv-modules/tasks/TasksRepository.tsindex 1795a7c..7a23894 100644--- a/api/src/tv-modules/tasks/TasksRepository.ts+++ b/api/src/tv-modules/tasks/TasksRepository.ts@@ -23,12 +23,13 @@ import {import { logError } from '../../utils/api';import { updateQuery } from '../../utils/db-helper';import { callWithCatch, isNotNullable } from '../../utils/helpers';-import type {- TaskArgAdd,- TaskArgDelete,- TaskArgFetchTasksNew,- TaskArgUpdate,- TasksArgToggleTaskUsers,+import {+ type TaskArgAdd,+ type TaskArgDelete,+ type TaskArgFetchTasksNew,+ type TaskArgUpdate,+ TASK_UPDATABLE_COLUMNS,+ type TasksArgToggleTaskUsers,} from './tasks.server.types';import type { KanbanArgFilters } from '../kanban/types';@@ -524,8 +525,19 @@ export class TasksRepository {}async updateTask(data: TaskArgUpdate): Promise<TasksSchemaTypeForSelect | null> {+ const updates: Partial<typeof TasksSchema.$inferInsert> = {};+ for (const column of TASK_UPDATABLE_COLUMNS) {+ if (data[column] !== undefined) {+ updates[column] = data[column] as never;+ }+ }++ if (Object.keys(updates).length === 0) {+ return this.fetchTaskByIdNew(data.id);+ }+const result = await callWithCatch(() =>- this.db.dbDrizzle.update(TasksSchema).set(data).where(eq(TasksSchema.id, data.id)).returning()+ this.db.dbDrizzle.update(TasksSchema).set(updates).where(eq(TasksSchema.id, data.id)).returning());return result?.[0] ?? null;}diff --git a/api/src/tv-modules/tasks/__tests__/TaskMassAssignment.integration.spec.ts b/api/src/tv-modules/tasks/__tests__/TaskMassAssignment.integration.spec.tsnew file mode 100644index 0000000..5b443c1--- /dev/null+++ b/api/src/tv-modules/tasks/__tests__/TaskMassAssignment.integration.spec.ts@@ -0,0 +1,183 @@+import axios from 'axios';+import type http from 'http';+import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';+import App from '../../../App';+import { Database } from '../../../modules/db';+import AuthModel from '../../auth/AuthModel';+import { ALL_TASKS_LIST_ID } from '../../../types/tasks.types';++// End-to-end reproduction of the mass-assignment report: an authenticated user who may+// edit their own task injects goalId / creatorId / sprintId into PATCH /module/tasks and+// tries to move the task into another user's goal. Runs through the real middleware,+// controller, ORM and DB triggers, so it needs the vitest PostgreSQL (see vitest.config.ts).++const port = 1813;+const url = `http://localhost:${port}`;+const PASSWORD = 'user1!#Q';+const VICTIM_LOGIN = '[email protected]';++const api = axios.create({ baseURL: url, validateStatus: () => true });+const auth = (jwt: string) => ({ headers: { Authorization: `Bearer ${jwt}` } });++let server: http.Server;+let victimJwt = '';+let victimUserId = 0;+let attackerJwt = '';+let attackerEmail = '';+let victimGoalId = 0;+let victimTaskId = 0;+let attackerGoalId = 0;+let attackerTaskId = 0;+let attackerListId = 0;++async function taskRow(id: number) {+ const result = await Database.getInstance().query<{ goal_id: number; creator_id: number | null; sprint_id: number | null; description: string }>(+ 'SELECT goal_id, creator_id, sprint_id, description FROM tasks.tasks WHERE id = $1',+ [id],+ );+ return result.rows[0];+}++async function listRow(id: number) {+ const result = await Database.getInstance().query<{ goal_id: number; owner: number | null; archive: number; name: string }>(+ 'SELECT goal_id, owner, archive, name FROM tasks.goal_lists WHERE id = $1',+ [id],+ );+ return result.rows[0];+}++async function registerAndLogin(email: string): Promise<string> {+ const registration = await api.post('/module/auth/registration', { email, password: PASSWORD, passwordRepeat: PASSWORD });+ expect(registration.status).toBe(200);++ const user = await new AuthModel().getUserByLogin(email, true);+ if (!user) throw new Error(`registered user ${email} not found`);+ const confirm = await api.get(`/module/auth/confirm/email/${user.confirm_email_code}/login/${user.login}`);+ expect(confirm.status).toBe(200);++ const login = await api.post('/module/auth/login', { login: email, password: PASSWORD });+ expect(login.status).toBe(200);+ return login.data.access as string;+}++async function createGoal(jwt: string, name: string): Promise<number> {+ const response = await api.post('/module/goals', { name }, auth(jwt));+ expect(response.status).toBe(200);+ return response.data.response.id as number;+}++async function createTask(jwt: string, goalId: number, description: string): Promise<number> {+ const response = await api.post('/module/tasks', { goalId, description }, auth(jwt));+ expect(response.status).toBe(200);+ return response.data.response.id as number;+}++describe('PATCH /module/tasks and /module/goal_lists mass assignment (integration)', () => {+ vi.mock('emailjs', () => ({+ SMTPClient: vi.fn().mockImplementation(() => ({ sendAsync: vi.fn().mockResolvedValue(true) })),+ }));+ vi.mock('../../../core/Email', () => ({+ Email: { send: vi.fn().mockResolvedValue(true) },+ }));++ beforeAll(async () => {+ server = new App(port).listen();++ const victimLogin = await api.post('/module/auth/login', { login: VICTIM_LOGIN, password: PASSWORD });+ expect(victimLogin.status).toBe(200);+ victimJwt = victimLogin.data.access;+ victimUserId = victimLogin.data.userData.id;++ attackerEmail = `${Date.now()}[email protected]`;+ attackerJwt = await registerAndLogin(attackerEmail);++ victimGoalId = await createGoal(victimJwt, `victim-goal-${Date.now()}`);+ victimTaskId = await createTask(victimJwt, victimGoalId, 'victim-owned task');++ attackerGoalId = await createGoal(attackerJwt, `attacker-goal-${Date.now()}`);+ attackerTaskId = await createTask(attackerJwt, attackerGoalId, 'attacker task');++ const list = await api.post('/module/goal_lists', { name: 'attacker list', goalId: attackerGoalId }, auth(attackerJwt));+ expect(list.status).toBe(200);+ attackerListId = list.data.response.id;+ });++ afterAll(async () => {+ if (attackerGoalId) await api.delete('/module/goals', { ...auth(attackerJwt), data: { goalId: attackerGoalId } });+ if (victimGoalId) await api.delete('/module/goals', { ...auth(victimJwt), data: { goalId: victimGoalId } });+ if (attackerEmail) await Database.getInstance().query('DELETE FROM tv_auth.users WHERE email = $1', [attackerEmail]);+ server?.close();+ });++ it('control: the attacker can edit a declared field on their own task', async () => {+ const response = await api.patch('/module/tasks', { id: attackerTaskId, description: 'neg-control-no-goalid' }, auth(attackerJwt));++ expect(response.status).toBe(200);+ const row = await taskRow(attackerTaskId);+ expect(row.description).toBe('neg-control-no-goalid');+ expect(row.goal_id).toBe(attackerGoalId);+ });++ it("control: the attacker cannot edit the victim's task at all", async () => {+ const response = await api.patch('/module/tasks', { id: victimTaskId, description: 'alice-hijack-attempt' }, auth(attackerJwt));++ expect(response.status).toBe(403);+ expect((await taskRow(victimTaskId)).description).toBe('victim-owned task');+ });++ it("attack: injected goalId / creatorId / sprintId do not move the task into the victim's goal", async () => {+ const before = await taskRow(attackerTaskId);++ const response = await api.patch(+ '/module/tasks',+ {+ id: attackerTaskId,+ description: 'pwned-cross-org',+ kanbanOrder: 500000,+ goalId: victimGoalId,+ creatorId: victimUserId,+ sprintId: 424242,+ },+ auth(attackerJwt),+ );++ expect(response.status).toBe(200);+ expect(response.data.response.goalId).toBe(attackerGoalId);++ const after = await taskRow(attackerTaskId);+ expect(after.goal_id).toBe(attackerGoalId);+ expect(after.creator_id).toBe(before.creator_id);+ expect(after.sprint_id).toBe(before.sprint_id);+ expect(after.description).toBe('pwned-cross-org');+ });++ it("victim's task list does not contain the attacker's task", async () => {+ const response = await api.get('/module/tasks', {+ ...auth(victimJwt),+ params: { goalId: victimGoalId, componentId: ALL_TASKS_LIST_ID, page: 0, showCompleted: 0, firstNew: 0 },+ });++ expect(response.status).toBe(200);+ const body = response.data.response;+ const tasks: { id: number }[] = Array.isArray(body) ? body : (body?.tasks ?? []);+ expect(tasks.map((task) => task.id)).toContain(victimTaskId);+ expect(tasks.map((task) => task.id)).not.toContain(attackerTaskId);+ });++ it("attack: injected goalId / owner / archive do not move the list into the victim's goal", async () => {+ const before = await listRow(attackerListId);++ const response = await api.patch(+ '/module/goal_lists',+ { id: attackerListId, name: 'pwned list', goalId: victimGoalId, owner: victimUserId, archive: 1 },+ auth(attackerJwt),+ );++ expect(response.status).toBe(200);+ const after = await listRow(attackerListId);+ expect(after.goal_id).toBe(attackerGoalId);+ expect(after.owner).toBe(before.owner);+ expect(after.archive).toBe(before.archive);+ expect(after.name).toBe('pwned list');+ });+});diff --git a/api/src/tv-modules/tasks/__tests__/TasksMassAssignment.spec.ts b/api/src/tv-modules/tasks/__tests__/TasksMassAssignment.spec.tsnew file mode 100644index 0000000..793308c--- /dev/null+++ b/api/src/tv-modules/tasks/__tests__/TasksMassAssignment.spec.ts@@ -0,0 +1,130 @@+import { afterEach, describe, expect, it, vi } from 'vitest';+import { Database } from '../../../modules/db';+import { TasksRepository } from '../TasksRepository';+import { TASK_UPDATABLE_COLUMNS, TaskArkTypeUpdate } from '../tasks.server.types';++vi.mock('../../../modules/db', () => ({+ Database: {+ getInstance: vi.fn(),+ },+}));++// Captures what reaches Drizzle's .set() so the test can assert which columns the+// repository is willing to write, without a database.+function mockUpdateChain(returningRow: object = {}) {+ const set = vi.fn((_values: Record<string, unknown>) => ({ where: () => ({ returning: async () => [returningRow] }) }));+ const update = vi.fn(() => ({ set }));+ // where() is awaited directly by the task lookup and .limit()-ed by the list lookup+ const whereResult = Object.assign(Promise.resolve([returningRow]), { limit: async () => [returningRow] });+ const select = vi.fn(() => ({ from: () => ({ where: () => whereResult }) }));+ vi.mocked(Database.getInstance).mockReturnValue({ dbDrizzle: { update, select } } as any);+ return { set, update, select };+}++// Mass assignment (CWE-915): ArkType keeps undeclared keys, so anything the client+// sends alongside the declared fields used to be spread straight into .set().+describe('TasksRepository.updateTask mass-assignment guard', () => {+ afterEach(() => {+ vi.clearAllMocks();+ });++ it('drops server-managed columns injected next to a legitimate field', async () => {+ const { set } = mockUpdateChain();+ const repository = new TasksRepository();++ await repository.updateTask({+ id: 1,+ description: 'pwned-cross-org',+ kanbanOrder: 500000,+ goalId: 3,+ creatorId: 9,+ sprintId: 7,+ owner: 9,+ recurrenceRuleId: 4,+ sourceUrl: 'https://evil.test',+ dateComplete: '2026-01-01',+ } as any);++ expect(set).toHaveBeenCalledTimes(1);+ const written = set.mock.calls[0][0];+ expect(written).toEqual({ description: 'pwned-cross-org', kanbanOrder: 500000 });+ expect(written).not.toHaveProperty('goalId');+ expect(written).not.toHaveProperty('creatorId');+ expect(written).not.toHaveProperty('sprintId');+ expect(written).not.toHaveProperty('owner');+ expect(written).not.toHaveProperty('id');+ });++ it('still writes every declared editable field', async () => {+ const { set } = mockUpdateChain();+ const repository = new TasksRepository();++ await repository.updateTask({+ id: 1,+ parentId: null,+ description: 'd',+ complete: true,+ goalListId: 2,+ note: 'n',+ priorityId: 2,+ startDate: '2026-01-01',+ endDate: '2026-01-02',+ startTime: '10:00',+ endTime: '11:00',+ statusId: 5,+ taskOrder: 1,+ kanbanOrder: 2,+ amount: '10.00',+ transactionType: 1,+ nodeGraphPosition: { x: 1, y: 2 },+ estimateValue: 3,+ });++ expect(set.mock.calls[0][0]).toEqual({+ parentId: null,+ description: 'd',+ complete: true,+ goalListId: 2,+ note: 'n',+ priorityId: 2,+ startDate: '2026-01-01',+ endDate: '2026-01-02',+ startTime: '10:00',+ endTime: '11:00',+ statusId: 5,+ taskOrder: 1,+ kanbanOrder: 2,+ amount: '10.00',+ transactionType: 1,+ nodeGraphPosition: { x: 1, y: 2 },+ estimateValue: 3,+ });+ });++ it('does not issue an UPDATE when only server-managed columns were sent', async () => {+ const row = { id: 1, goalId: 2, description: 'untouched' };+ const { set, update, select } = mockUpdateChain(row);+ const repository = new TasksRepository();++ const result = await repository.updateTask({ id: 1, goalId: 3, creatorId: 9 } as any);++ expect(update).not.toHaveBeenCalled();+ expect(set).not.toHaveBeenCalled();+ expect(select).toHaveBeenCalledTimes(1);+ expect(result).toEqual(row);+ });++ it('keeps the kanban move payload (kanbanOrder + statusId) writable', async () => {+ const { set } = mockUpdateChain();+ const repository = new TasksRepository();++ await repository.updateTask({ id: 1, kanbanOrder: 42, statusId: 7 });++ expect(set.mock.calls[0][0]).toEqual({ kanbanOrder: 42, statusId: 7 });+ });++ it('allowlist covers every field the update schema declares, and nothing else', () => {+ const declared = TaskArkTypeUpdate.props.map((prop) => String(prop.key)).filter((key) => key !== 'id').sort();+ expect([...TASK_UPDATABLE_COLUMNS].sort()).toEqual(declared);+ });+});diff --git a/api/src/tv-modules/tasks/tasks.server.types.ts b/api/src/tv-modules/tasks/tasks.server.types.tsindex dbcdff8..9fb3686 100644--- a/api/src/tv-modules/tasks/tasks.server.types.ts+++ b/api/src/tv-modules/tasks/tasks.server.types.ts@@ -74,6 +74,26 @@ export type TaskArgFetchTasksNew = typeof TaskArkTypeFetchTasksNew.infer;export type TaskArgUpdate = typeof TaskArkTypeUpdate.infer;+export const TASK_UPDATABLE_COLUMNS = [+ 'parentId',+ 'description',+ 'complete',+ 'goalListId',+ 'note',+ 'priorityId',+ 'startDate',+ 'endDate',+ 'startTime',+ 'endTime',+ 'statusId',+ 'taskOrder',+ 'kanbanOrder',+ 'amount',+ 'transactionType',+ 'nodeGraphPosition',+ 'estimateValue',+] as const satisfies ReadonlyArray<Exclude<keyof TaskArgUpdate, 'id'>>;+/*** We can add task only with these fields* Other fields like (tags, assignedUsers)@@ -115,9 +135,9 @@ export const TaskFieldPermissionsForEditOrCreation = {startTime: GoalPermissions.TASKS_CAN_EDIT_DEADLINE,endTime: GoalPermissions.TASKS_CAN_EDIT_DEADLINE,-- parentId: GoalPermissions.TASKS_CAN_ADD_SUBTASKS,- statusId: GoalPermissions.TASKS_CAN_DELETE,++ parentId: GoalPermissions.TASKS_CAN_ADD_SUBTASKS,+ statusId: GoalPermissions.TASKS_CAN_DELETE,taskOrder: GoalPermissions.TASKS_CAN_DELETE,kanbanOrder: GoalPermissions.TASKS_CAN_DELETE,amount: GoalPermissions.TASKS_CAN_DELETE,@@ -138,7 +158,7 @@ export const TaskFieldPermissionsForWatching = {startTime: GoalPermissions.COMPONENT_CAN_WATCH_CONTENT,endTime: GoalPermissions.COMPONENT_CAN_WATCH_CONTENT,-+parentId: GoalPermissions.TASKS_CAN_WATCH_SUBTASKS,statusId: GoalPermissions.COMPONENT_CAN_WATCH_CONTENT,taskOrder: GoalPermissions.COMPONENT_CAN_WATCH_CONTENT,diff --git a/package.json b/package.jsonindex d4a1139..08f3615 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "taskview-ce-monorepo",- "version": "1.54.0",+ "version": "1.55.0","private": true,"description": "TaskView CE monorepo containing web, API, and packages","workspaces": [diff --git a/taskview-packages/taskview-mcp/package.json b/taskview-packages/taskview-mcp/package.jsonindex b53d005..15261a0 100644--- a/taskview-packages/taskview-mcp/package.json+++ b/taskview-packages/taskview-mcp/package.json@@ -1,6 +1,6 @@{"name": "taskview-mcp",- "version": "1.54.0",+ "version": "1.55.0","description": "MCP (Model Context Protocol) server for TaskView — lets AI assistants (Claude Code, Claude Desktop, etc.) manage projects and tasks via the TaskView API","type": "module","bin": {diff --git a/web/package.json b/web/package.jsonindex f979d7c..642a94a 100644--- a/web/package.json+++ b/web/package.json@@ -2,7 +2,7 @@"name": "web-nuxt-ui","private": true,"type": "module",- "version": "1.54.0",+ "version": "1.55.0","scripts": {"dev": "vite","build:packages": "pnpm --filter taskview-db-schemas build && pnpm --filter taskview-api build && pnpm --filter capacitor-widget-bridge build",