Problem
OpenAiCompatibleLlmClient reads successful LLM responses with ReadAsStringAsync, and the error path reads the entire body before truncating it for logs. A malicious, misconfigured, or broken endpoint can return an arbitrarily large body.
Impact
A single draft request can force large memory allocations and destabilize the API process.
References
api/ApplyTrack.Api/Llm/OpenAiCompatibleLlmClient.cs
Acceptance criteria
- Use
HttpCompletionOption.ResponseHeadersRead.
- Reject responses with
Content-Length over a configured/default cap.
- Stream response bodies with a hard byte cap before JSON parsing/logging.
- Tests cover oversized success and error responses.
Problem
OpenAiCompatibleLlmClientreads successful LLM responses withReadAsStringAsync, and the error path reads the entire body before truncating it for logs. A malicious, misconfigured, or broken endpoint can return an arbitrarily large body.Impact
A single draft request can force large memory allocations and destabilize the API process.
References
api/ApplyTrack.Api/Llm/OpenAiCompatibleLlmClient.csAcceptance criteria
HttpCompletionOption.ResponseHeadersRead.Content-Lengthover a configured/default cap.