🔒 Fix mass assignment vulnerabilities in blog and job controllers#16
🔒 Fix mass assignment vulnerabilities in blog and job controllers#16Adityavanjre wants to merge 3 commits into
Conversation
Co-authored-by: Adityavanjre <66417028+Adityavanjre@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR adds mass-assignment protection to blog and job update endpoints by introducing field whitelists that restrict which request-body properties can be modified. The controllers now conditionally assign only explicitly allowed fields from ChangesMass-Assignment Protections
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment Tip You can enable review details to help with troubleshooting, context usage and more.Enable the |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62820fb9f7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "nodemailer": "^8.0.2" | ||
| }, | ||
| "devDependencies": { | ||
| "jest": "^30.4.0", |
There was a problem hiding this comment.
Update the server lockfile for Jest
When this package is installed from a clean checkout using the tracked agency/server/package-lock.json, the new test script depends on jest but the lockfile still has only nodemon in the server devDependencies and no Jest entries. That leaves the new tests unreproducible and can make lockfile-based installs or dependency verification for agency/server fail or omit the test runner; update the corresponding lockfile alongside this added dependency.
Useful? React with 👍 / 👎.
Co-authored-by: Adityavanjre <66417028+Adityavanjre@users.noreply.github.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Co-authored-by: Adityavanjre <66417028+Adityavanjre@users.noreply.github.com>
🎯 What:
Mass assignment vulnerabilities existed in
blogController.jsandjobController.jsdue to the unsafe usage ofObject.assign(doc, req.body)when updating entities.Attackers could potentially inject unexpected and unauthorized fields during updates (e.g., overriding system fields, modifying timestamps, toggling
isAdminor other internal-only states), leading to privilege escalation, data corruption, or application logic bypass.🛡️ Solution:
Replaced
Object.assign()with explicit field assignment loops. We defined strict lists ofallowedFieldsin both controllers based on the Mongoose models' schemas. New tests were also added (massAssignment.test.js) verifying that explicitly allowed fields update successfully while injected vulnerable fields (e.g.,isAdmin,_id) are safely ignored.PR created automatically by Jules for task 3297366078245988208 started by @Adityavanjre
Summary by CodeRabbit
Bug Fixes
Tests
Chores