fix: resolve adaptiveSettings schema bug and task ownership BOLA vulnerability#1485
Open
Pratik-kr21 wants to merge 3 commits into
Open
fix: resolve adaptiveSettings schema bug and task ownership BOLA vulnerability#1485Pratik-kr21 wants to merge 3 commits into
Pratik-kr21 wants to merge 3 commits into
Conversation
Author
|
Hi maintainers 👋 Resolves the adaptiveSettings schema nesting bug that was preventing adaptive tracking data from being saved correctly. The changes have been tested and are backward compatible. I would appreciate a review when you have time. Thank you! 🙌 |
Owner
|
there are duplicates in the code fix that |
aryandas2911
approved these changes
Jun 16, 2026
Owner
|
lint pls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses two critical issues within the Routine management system: a major feature-breaking schema bug and a high-severity security vulnerability.
1. Adaptive Settings Schema Bug
Root Cause: In
backend/src/models/Routine.js, theadaptiveSettingsobject was accidentally defined inside the configuration options of thedayfield due to a misplaced brace. Mongoose's strict mode dropped this unmapped object silently.Solution: Moved the
adaptiveSettingsblock out of theitemsarray and placed it at the root level of theroutineSchema.User Impact: Completely restores the app's flagship "Interactive Contribution Heatmap" and adaptive tracking features. Without this fix, all routines save with a 0 burnout and consistency score.
2. Routine Task Ownership (BOLA) Vulnerability
Root Cause: The
createRoutineandupdateRoutineendpoints inbackend/controllers/routineController.jsaccepted an array of tasks without verifying if thetaskIds provided actually belonged to the authenticated user.Solution: Imported the
Taskmodel and implemented a strict security checkpoint. The controller now counts the valid tasks owned by theuserIdusingTask.countDocuments()and matches it against the uniquetaskIds requested. It rejects unowned tasks with a403 Forbidden.User Impact: Prevents malicious actors from mapping foreign task IDs to their routines to leak private task descriptions and statuses belonging to other users.
Files Modified
backend/src/models/Routine.jsbackend/controllers/routineController.jsRelated Issue
Closes #1484
Testing Checklist
fix/*)adaptiveSettings(burnout score, consistency score) successfully saves to the root of the MongoDB document.taskIdor one belonging to a different user, and verified the server explicitly rejects the request with a403 Forbiddenstatus.