The vulnerability is an uncontrolled resource consumption issue in the text-generation-inference router. The root cause is in the fetch_image function located in router/src/validation.rs. This function was responsible for downloading images from URLs provided in the user's input. The vulnerable version of the code read the entire response body into memory without enforcing any size limits, using reqwest::blocking::get(url)?.bytes()?. An attacker could exploit this by crafting a request containing a markdown image link pointing to an extremely large file. This would cause the server to attempt to allocate a large amount of memory, leading to memory exhaustion and a denial of service.
The patch addresses this by introducing a size limit (max_image_fetch_size). The updated fetch_image function now first inspects the Content-Length header of the response. If the reported size exceeds the limit, the request is immediately rejected. If the header is not present, it proceeds to read the response body but uses response.take() to enforce a hard limit on the number of bytes read from the socket, thus preventing the application from consuming excessive memory. The prepare_input function was also identified as it is the function that parses the user input and calls the vulnerable fetch_image function.