Skip to content

Missing Input Length Validation on LLM Chat Route #243

Description

@devprashant19

Component: Node.js Backend / Groq Integration
Files Affected: backend/routes/chatRoutes.js

Description

The user's message input provided to the /chat route is passed directly to the Groq API without any string length validation or truncation. An attacker or malicious bot could send an excessively large string (e.g., millions of characters) in a single payload. This forces the Node server to parse a massive JSON body and forwards excessive input tokens to the Groq LLM, potentially causing rapid API quota exhaustion and unexpected billing spikes.

Proposed Fix

  1. Add input validation at the top of the /chat POST route.
  2. Check message.length and reject payloads that exceed a reasonable bound (e.g., > 1000 characters) with a 400 Bad Request.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions