fix(tasks): add input validation to createTask to prevent oversized data [NSoC'26]#145
Open
anshul23102 wants to merge 1 commit into
Open
fix(tasks): add input validation to createTask to prevent oversized data [NSoC'26]#145anshul23102 wants to merge 1 commit into
anshul23102 wants to merge 1 commit into
Conversation
…tion [NSoC'26] createTask accepted title and description from the request body and inserted them directly into Supabase with no validation. An authenticated user could create tasks with empty titles, 1 MB descriptions, or titles containing control characters, corrupting data visible to all team members and inflating API response sizes. Added validation: - title must be a non-empty string of at most 200 characters (required) - description, if provided, must be a string of at most 5000 characters Both checks return 400 with a descriptive message before any Supabase call is made. Closes Shriii19#140
|
@anshul23102 is attempting to deploy a commit to the shreemp194-gmailcom's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
👋 Thank you for opening this pull request! I will review your changes and assist you soon. |
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
createTaskacceptedtitleanddescriptionfrom the request body and inserted them directly into Supabase with no validation. An authenticated user could create tasks with empty titles, megabyte-length descriptions, or control characters in any field, corrupting data visible to all team members and degrading performance.Related Issue
Closes #140
Type of Change
Root Cause
The function destructured
{ title, description, status, position }fromreq.bodyand passed them directly tosupabase.from("tasks").insert(...)without checking the type, emptiness, or length of any field.Changes Made
backend/controllers/tasks.controller.jstitlemust be a non-empty string; returns 400 if missing or emptybackend/controllers/tasks.controller.jstitlemust not exceed 200 characters; returns 400 if too longbackend/controllers/tasks.controller.jsdescription, if provided, must be a string and must not exceed 5000 charactersAll checks run before the Supabase insert call.
Screenshots or Demo
Not applicable (backend-only change).
Testing Done
POST /api/taskswith notitlereturns400 Task title is required.POST /api/taskswithtitle: ""returns400 Task title is required.POST /api/taskswithtitle: "a".repeat(201)returns400 Task title must not exceed 200 characters.POST /api/taskswith validtitleand nodescriptioncreates the task normally.POST /api/taskswithdescription: "a".repeat(5001)returns400 Task description must not exceed 5000 characters.Checklist
NSoC Label Request
@Shriii19 could you please add the appropriate NSoC '26 label to this PR? Thank you!