omi
omi copied to clipboard
[Bounty proposal] fix(backend): validate identifiers, clamp boundaries, and add transaction retry in calendar_meetings ($50 proposed)
Following the contribution guide's invitation to propose paid work — @kodjima33, @Git-on-my-level, would a US$50 bounty be appropriate for this? Proposed amount, not an existing award.
Problem & Vulnerabilities in backend/database/calendar_meetings.py
- Transaction Contention Risk:
create_meetingexecuted_upsert_meeting_transactionviadb.transaction()directly without bounded retry logic. Concurrent calendar sync operations for the same user can trigger Firestore transaction contention (Aborted/Conflict), causing meeting creation to fail. - Missing Input Validation & KeyError Risk:
create_meetingindexedmeeting_data['calendar_source']andmeeting_data['calendar_event_id']directly without validation. Missing or malformed keys caused unhandledKeyErrorcrashes. - Identifier Sanitization: Missing path traversal and empty string validation on
uidandmeeting_idacrosscreate_meeting,get_meeting,update_meeting,delete_meeting, andlist_meetings. - Unbounded Pagination Limits:
list_meetingspassed unvalidatedlimitdirectly to Firestore queries without clamping, allowing invalid/negative arguments to fail. - Unhandled NotFound on Concurrency:
update_meetinganddelete_meetingcould raise uncaughtNotFoundexceptions when operating on concurrently removed documents.
Remediation
- Wrapped meeting upsert transactions in
run_with_transaction_contention_retryto guarantee resilience against concurrent synchronization collisions. - Sanitized identifiers (
uid,meeting_id,calendar_source,calendar_event_id) with_clean_idand_clean_strto prevent invalid characters and path traversal. - Added safe fallback defaults for
calendar_sourceandcalendar_event_idincreate_meeting. - Clamped pagination limits in
list_meetingsto[1, 500]and validated date ranges inget_meetings_in_time_range. - Guarded
NotFoundexceptions during update and delete operations. - Added 10 hermetic unit tests in
backend/tests/unit/test_calendar_meetings_resilience.py(100% pass, zero stub leaks). Registered in.github/checks-manifest.yaml.