Skip to content

🛡️ Sentinel: Fix Mass Assignment in calendar notes#521

Open
ngoiyaeric wants to merge 1 commit intomainfrom
sentinel/fix-mass-assignment-calendar-12587019390571781091
Open

🛡️ Sentinel: Fix Mass Assignment in calendar notes#521
ngoiyaeric wants to merge 1 commit intomainfrom
sentinel/fix-mass-assignment-calendar-12587019390571781091

Conversation

@ngoiyaeric
Copy link
Collaborator

This PR fixes a Mass Assignment (Overposting) vulnerability in the saveNote server action within lib/actions/calendar.ts. By explicitly listing the fields allowed for update and insert, we prevent potential data corruption or privilege escalation where a user could change the owner of a note or overwrite other protected fields.


PR created automatically by Jules for task 12587019390571781091 started by @ngoiyaeric

Refactor the `saveNote` server action to explicitly list columns for `insert` and `update` operations. This prevents malicious users from overwriting protected fields like `userId` by providing unexpected keys in the JSON payload.

- Removed object spreads (`...noteData`) in database calls.
- Ensured `userId` is strictly taken from the authenticated session.
- Added explicit mapping for allowed fields: `chatId`, `date`, `content`, `locationTags`, `userTags`, and `mapFeatureId`.

Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel
Copy link
Contributor

vercel bot commented Feb 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
qcx Ready Ready Preview, Comment Feb 15, 2026 9:53am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

Warning

Rate limit exceeded

@ngoiyaeric has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 20 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between be08900 and 8ddf804.

📒 Files selected for processing (2)
  • .jules/sentinel.md
  • lib/actions/calendar.ts
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sentinel/fix-mass-assignment-calendar-12587019390571781091

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mass-assignment mitigation is solid, but the update mapping may unintentionally overwrite columns with undefined if partial payloads are ever sent. Additionally, the insert path still appears to trust client-provided chatId without an explicit authorization check, which can enable cross-tenant associations depending on the data model. Addressing these will make the security fix more robust and prevent subtle data corruption.

Additional notes (1)
  • Security | lib/actions/calendar.ts:94-106
    Insert uses userId: userId explicitly (good), but the insert payload still directly trusts client-provided chatId. If notes are supposed to be scoped to chats the user belongs to, this allows a user to attach a note to an arbitrary chatId they can guess, which is a cross-tenant association risk unless there is an external authorization check elsewhere.

The update path does scope by userId, but the insert path doesn’t validate that the provided chatId belongs to the current user.

Summary of changes

What changed

  • Added a short security note in .jules/sentinel.md documenting a Mass Assignment / Overposting pattern and prevention guidance.
  • Hardened saveNote in lib/actions/calendar.ts by removing object spreads (...noteData) from Drizzle .set() and .values() calls.
  • Explicitly whitelisted persisted fields for both operations:
    • Update: chatId, date, content, locationTags, userTags, mapFeatureId, plus updatedAt: new Date()
    • Insert: userId (from session), and the same note fields
  • Preserved the update guard by scoping the update query to where ... id = noteData.id AND userId = sessionUserId.

@charliecreates charliecreates bot removed the request for review from CharlieHelps February 15, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants