fix(chat): replace raw Supabase error.message with generic client response [NSoC'26]#143
Open
anshul23102 wants to merge 1 commit into
Open
fix(chat): replace raw Supabase error.message with generic client response [NSoC'26]#143anshul23102 wants to merge 1 commit into
anshul23102 wants to merge 1 commit into
Conversation
…ponse [NSoC'26] Both getMessages and sendMessage forwarded the raw Supabase error.message directly to HTTP clients. Supabase errors can contain PostgreSQL details including table names, column names, and constraint names, helping attackers enumerate the database schema. Replaced error.message in both responses with a fixed generic string and moved the full error object to console.error so it is captured in server logs but never exposed to clients. Closes Shriii19#138
|
@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
Both
getMessagesandsendMessageinchat.controller.jsforwarded the rawerror.messagefrom Supabase directly to HTTP clients. Supabase errors can include PostgreSQL-level details: table names, column names, constraint names, and error codes. Exposing these helps attackers map the database schema for targeted injection or enumeration attacks.Related Issue
Closes #138
Type of Change
Root Cause
res.status(500).json({ error: error.message })was used in both handlers without any sanitization. The full error object was not logged server-side in either case.Changes Made
backend/controllers/chat.controller.jsgetMessages: replacederror.messagewith"Failed to retrieve messages."and addedconsole.errorfor server-side loggingbackend/controllers/chat.controller.jssendMessage: replacederror.messagewith"Failed to send message."and updated the log labelScreenshots or Demo
Not applicable (backend-only change).
Testing Done
getMessagesreturns{ error: "Failed to retrieve messages." }to the client; the full error appears in server logs.sendMessagereturns{ error: "Failed to send message." }to the client.Checklist
NSoC Label Request
@Shriii19 could you please add the appropriate NSoC '26 label to this PR? Thank you!