Skip to content

Conversation

@echobt
Copy link
Contributor

@echobt echobt commented Jan 20, 2026

This PR mitigates a potential Denial of Service (DoS) vulnerability by enforcing limits on the /embed_batch and /embed API endpoints.

Changes

  • Added MAX_BATCH_SIZE = 100 for /embed_batch requests.
  • Added MAX_TEXT_LENGTH = 8192 (characters) for individual text items in both /embed and /embed_batch.
  • Requests exceeding these limits now return 400 Bad Request immediately, preventing memory exhaustion and server unresponsiveness.

Verification

  • Verified with a reproduction script sending 10,000 items, which was correctly rejected with 400 Bad Request.
  • Verified that requests with over-sized text are rejected.
  • Verified that valid requests still pass.
  • Ran existing tests to ensure no regressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants