omi icon indicating copy to clipboard operation
omi copied to clipboard

[Plugin] Harden error handling, type validation, and audio buffer bounding in omi-dropbox-app

Open Ivansky1 opened this issue 2 months ago • 2 comments

Problem Description

In plugins/omi-dropbox-app/main.py:

  1. Unchecked JSON Payload Parsing: The chat tools (/tools/search, /tools/list, /tools/read) attempt to call .get() directly on await 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.
  2. Missing ChatToolResponse Contract: The tools endpoints previously returned raw unvalidated dictionaries ({"result": ...} or {"error": ...}) rather than typed ChatToolResponse models, violating Omi app schema standards.
  3. Null / Malformed Parameter Vulnerabilities: When optional parameters like folder or fields like query and path are omitted, passed as JSON null (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.
  4. Unbounded Audio Buffer Memory: The /audio endpoint 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.
  5. Missing Hermetic Test Suite: plugins/omi-dropbox-app lacked an automated unit test suite for its FastAPI endpoints and was unregistered in .github/checks-manifest.yaml.

Proposed Solution

  1. Add ChatToolResponse and typed request models (SearchDropboxRequest, ListDropboxRequest, ReadDropboxRequest) to models.py.
  2. Harden /tools/search, /tools/list, and /tools/read with defensive payload parsing, null/whitespace guards, and typed ChatToolResponse return contracts.
  3. Enforce a MAX_AUDIO_BUFFER_BYTES bound (50 MB) on /audio streams and validate sample rates.
  4. Replace deprecated datetime.utcnow() calls with timezone-aware datetime.now(timezone.utc).
  5. 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.
  6. Register the check in .github/checks-manifest.yaml.

Proposed Bounty: $40 under the standard plugin bug bounty program. Payout Wallet: 0xb5aFc89b57Fa8270bB7261348179D28099BEa2a0 (Base / EVM)

Ivansky1 avatar Sep 15 '26 22:09 Ivansky1

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:

  1. Add typed request/response models (ChatToolResponse, SearchDropboxRequest, etc.)
  2. Harden /tools/* endpoints with defensive parsing
  3. Add MAX_AUDIO_BUFFER_BYTES bound (50MB)
  4. Fix datetime.utcnow() → timezone-aware
  5. Add hermetic test suite (31 scenarios)
  6. Register in checks-manifest.yaml

Claiming now!

armorbreak001 avatar Sep 15 '26 22:09 armorbreak001

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.

PINYOPATTANAWASANPORN avatar Sep 16 '26 00:09 PINYOPATTANAWASANPORN