openhuman
openhuman copied to clipboard
Bug: No size limit on audio base64 input in cloud_transcribe.rs
Summary
src/openhuman/voice/cloud_transcribe.rs — transcribe_cloud() has no size check on audio_base64 input. A caller can pass an extremely large base64 string, causing a massive memory allocation during decode before upload.
Impact
Low — Potential OOM if an unusually large audio payload is passed (e.g., multi-hour recording). Unlike the WebSocket endpoint, this requires authenticated access.
Suggested Fix
Add a max size check before decode:
const MAX_AUDIO_BASE64_LEN: usize = 33_554_432; // ~25MB base64 → ~18MB audio
if audio_base64.len() > MAX_AUDIO_BASE64_LEN {
anyhow::bail!("Audio input exceeds maximum size (25MB)");
}