The vulnerability is a denial-of-service (DoS) caused by a data amplification attack, commonly known as a 'decompression bomb'. The application's /v1/audio/transcriptions endpoint checks the size of the uploaded compressed audio file but fails to limit the size of the audio after it is decompressed. An attacker can upload a small, specially crafted audio file (e.g., a low-bitrate OPUS file) that expands to a very large size in memory during decoding.
The analysis of the patch commit 1b1359c33269446f13c05da9a90c25174cbea590 reveals the exact functions involved. The vulnerability is triggered in SpeechToTextProcessor._preprocess_speech_to_text, which reads the uploaded audio and calls load_audio. The load_audio function, in turn, uses either load_audio_pyav or load_audio_soundfile to perform the decoding. In the vulnerable version, these decoding functions would read and process the entire audio stream into memory without any limits. The load_audio_pyav function is particularly illustrative, as it iteratively appends decoded chunks into a list, which is then concatenated into a single, massive memory allocation.
The fix introduces a new configuration parameter, max_duration_s, which is passed down from the entry point to the decoding functions. This parameter is used to check the audio's duration, both from its metadata and during the decoding process itself, causing the operation to fail early if the limit is exceeded. This prevents the excessive memory allocation that leads to the DoS.