Skip to content

Commit edc9d0e

Browse files
fix: prevent mass assignment of userId in updateTask (closes #1373) (#1374)
Co-authored-by: Aryan Das <122392506+aryandas2911@users.noreply.github.com>
1 parent f85cffb commit edc9d0e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

backend/controllers/taskController.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ export const updateTask = async (req, res) => {
200200
});
201201
}
202202

203-
// fetch update task details
204-
const updates = req.body;
203+
// fetch update task details, strip protected fields to prevent mass assignment
204+
const { userId: _ignored, _id: __ignored, ...safeUpdates } = req.body;
205+
const updates = safeUpdates;
205206

206207
// validate title length if title is being updated
207208
if (updates.title && updates.title.trim().length > 50) {

0 commit comments

Comments
 (0)