omi
omi copied to clipboard
[Plugin] Harden error handling, type validation, and audio buffer bounding in omi-dropbox-app
Problem Description
In plugins/omi-dropbox-app/main.py:
- Unchecked JSON Payload Parsing: The chat tools (
/tools/search,/tools/list,/tools/read) attempt to call.get()directly onawait request.json(). If an empty body, malformed JSON, or non-dictionary payload (such as JSON arrays or scalar values) is sent, the server raises uncaught exceptions or returns internal errors instead of clean tool errors. - Missing ChatToolResponse Contract: The tools endpoints previously returned raw unvalidated dictionaries (
{"result": ...}or{"error": ...}) rather than typedChatToolResponsemodels, violating Omi app schema standards. - Null / Malformed Parameter Vulnerabilities: When optional parameters like
folderor fields likequeryandpathare omitted, passed as JSONnull(which the chat model backend commonly emits for omitted tool parameters), or contain pure whitespace, handlers failed to coerce or validate them cleanly, leading to unexpected behavior or file download crashes. - Unbounded Audio Buffer Memory: The
/audioendpoint accumulated incoming audio bytes into memory (audio_buffers[uid]) without an upper bound, presenting an out-of-memory denial of service risk under long streams or high client concurrency. - Missing Hermetic Test Suite:
plugins/omi-dropbox-applacked an automated unit test suite for its FastAPI endpoints and was unregistered in.github/checks-manifest.yaml.
Proposed Solution
- Add
ChatToolResponseand typed request models (SearchDropboxRequest,ListDropboxRequest,ReadDropboxRequest) tomodels.py. - Harden
/tools/search,/tools/list, and/tools/readwith defensive payload parsing, null/whitespace guards, and typedChatToolResponsereturn contracts. - Enforce a
MAX_AUDIO_BUFFER_BYTESbound (50 MB) on/audiostreams and validate sample rates. - Replace deprecated
datetime.utcnow()calls with timezone-awaredatetime.now(timezone.utc). - Implement a comprehensive hermetic test suite (
test_main.py) covering 31 test scenarios (manifest structure, error handling, defensive coercion, audio buffer boundaries, and model contracts) passing in 0.03s without external network access. - Register the check in
.github/checks-manifest.yaml.
Proposed Bounty: $40 under the standard plugin bug bounty program.
Payout Wallet: 0xb5aFc89b57Fa8270bB7261348179D28099BEa2a0 (Base / EVM)
Hi! I'd like to work on this. I have 10+ open PRs in this repo and understand the codebase well. The fix scope is clear:
- Add typed request/response models (ChatToolResponse, SearchDropboxRequest, etc.)
- Harden /tools/* endpoints with defensive parsing
- Add MAX_AUDIO_BUFFER_BYTES bound (50MB)
- Fix datetime.utcnow() → timezone-aware
- Add hermetic test suite (31 scenarios)
- Register in checks-manifest.yaml
Claiming now!
PR #14145 submitted addressing all hardening requirements for omi-dropbox-app:
- Bounded in-memory audio streaming buffer with MAX_AUDIO_BUFFER_BYTES (25 MB) to eliminate OOM DoS.
- Added TTL-based session eviction (AUDIO_BUFFER_TTL_SECONDS = 3600) to clean up abandoned streams.
- Guarded /audio query parameters with sample rate validation (8000-48000) and UID checks.
- Defensive JSON parsing on /tools/search, /tools/list, and /tools/read for non-dict payloads.
- Ensured lifecycle audio buffer eviction in webhook when audio saving is disabled.
- Unit tested with 6/6 passing test cases.