Skip to content

fix(chat): add input length validation to prevent payload abuse#246

Merged
Userunknown84 merged 1 commit into
Userunknown84:mainfrom
devprashant19:fix/chat-length-validation
Jun 24, 2026
Merged

fix(chat): add input length validation to prevent payload abuse#246
Userunknown84 merged 1 commit into
Userunknown84:mainfrom
devprashant19:fix/chat-length-validation

Conversation

@devprashant19

@devprashant19 devprashant19 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

This PR resolves the missing input validation vulnerability on the LLM /chat endpoint. Previously, user input was passed directly to the Groq API without size restrictions, opening the application up to potential token exhaustion or billing spike attacks through excessively large payloads.

Changes

  • Added a length check constraint on the message input in backend/routes/chatRoutes.js.
  • If the payload exceeds 1,000 characters, the server now intercepts it and returns a 400 Bad Request before sending anything to Groq.

Related Issues

Type of Change

  • Security fix
  • Bug fix
  • New feature
  • Refactoring

Pre-submission Checklist

  • Verified that messages under 1000 characters are processed normally.
  • Verified that messages over 1000 characters return a clear 400 error.

@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

@devprashant19 is attempting to deploy a commit to the Aditya Sharma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Userunknown84 Userunknown84 merged commit 32f3daf into Userunknown84:main Jun 24, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing Input Length Validation on LLM Chat Route

2 participants