Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2025-05-22 - [Mass Assignment in Server Actions]
**Vulnerability:** Use of object spreads (...data) in Drizzle .set() and .values() methods within Next.js Server Actions.
**Learning:** Server Actions can receive any JSON payload from the client. Using spreads directly on these inputs can allow attackers to overwrite protected fields like 'userId' or 'id', leading to data corruption or privilege escalation.
**Prevention:** Always explicitly map allowed fields from client-provided objects when performing database operations in Server Actions.
20 changes: 18 additions & 2 deletions lib/actions/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ export async function saveNote(noteData: NewCalendarNote | CalendarNote): Promis
try {
const [updatedNote] = await db
.update(calendarNotes)
.set({ ...noteData, updatedAt: new Date() })
.set({
chatId: noteData.chatId,
date: noteData.date,
content: noteData.content,
locationTags: noteData.locationTags,
userTags: noteData.userTags,
mapFeatureId: noteData.mapFeatureId,
updatedAt: new Date()
})
.where(and(eq(calendarNotes.id, noteData.id), eq(calendarNotes.userId, userId)))
.returning();
return updatedNote;
Expand All @@ -86,7 +94,15 @@ export async function saveNote(noteData: NewCalendarNote | CalendarNote): Promis
try {
const [newNote] = await db
.insert(calendarNotes)
.values({ ...noteData, userId })
.values({
userId: userId,
chatId: noteData.chatId,
date: noteData.date,
content: noteData.content,
locationTags: noteData.locationTags,
userTags: noteData.userTags,
mapFeatureId: noteData.mapFeatureId,
})
.returning();

if (newNote && newNote.chatId) {
Expand Down