Skip to content

[Bounty $200] security: ms365: /tools dispatch trusts body uid and acts with the victim's Microsoft token #14683

Closed as duplicate

Description

@onkar717

Summary

POST /tools/{tool_name} in plugins/omi-ms365-app/main.py (tool_dispatch, main.py:208) reads uid from the request body (main.py:216) and runs the named Microsoft Graph tool as that user, with no check that the caller owns the uid. The one gate, _auth_guard (main.py:186, called at main.py:221), only calls auth.get_access_token(uid) (main.py:188): it proves the victim is connected, not that the caller is the victim. A request naming a connected victim's uid passes the guard and dispatches at main.py:228 with that user's token.

The 16 tools reached through the one dispatch route (_TOOLS, main.py:235):

Group Tools Line
Profile get_me 239
Mail list_recent_emails, search_emails, read_email, send_email 241
Calendar list_upcoming_events, create_event, find_free_slots 244
Teams list_recent_chats, send_chat_message, list_my_teams, create_online_meeting 248
Files list_recent_files, search_files, upload_text_file, read_file_text 252

Same defect class as the paid whoop fix (#14453) and the five-app sweep (#14455): the route trusts a body uid and acts with that user's stored OAuth token. ms365 is not in either file list. This is distinct from #14582 (reflected HTML on the setup and OAuth-error pages), which does not touch the tool routes.

Note on _auth_guard: it is not caller authentication. auth.get_access_token(uid) loads the victim's cached MSAL token and raises only when the victim has no token. Against a connected victim it always succeeds, so the guard is a no-op for access control.

Impact

  • Read as victim: get_me, list_recent_emails, read_email, search_files, read_file_text expose the victim's profile, mailbox, and OneDrive/SharePoint files.
  • Write and impersonate as victim: send_email sends mail from the victim, send_chat_message posts as the victim in Teams, create_event and create_online_meeting book on their calendar, upload_text_file writes to their OneDrive.

These are the same externally reachable chat-tool routes whose uid-trust was accepted and paid on whoop (#14453). ms365 exposes the identical surface, with only the connection-check _auth_guard in front.

Evidence

Hermetic reproduction (stdlib only, framework, config, auth, and httpx stubbed, drives the real tool_dispatch, _auth_guard, and profile.me). An attacker request carrying only {"uid": "<victim>"}, with no Authorization header and no secret, calling get_me:

outbound : GET https://graph.microsoft.com/v1.0/me
outbound : Authorization: Bearer VICTIM-MS365-ACCESS-TOKEN
returned : {display_name: "Victim User", mail: "[email protected]", job_title: "CFO"}

The dispatch passed _auth_guard, ran profile.me as the victim, and returned the victim's profile, selected entirely by the body uid.

Fix

Per-app ms365_tools_auth.py shared-secret guard: Authorization: Bearer or a ms365_tools_token query param, checked against the MS365_TOOLS_SECRET env var with hmac.compare_digest, applied via Depends() in front of the dispatch route. Fail-closed 503 when unconfigured, 401 on missing or wrong token. Keep _auth_guard as the connection check. Same mechanism as the merged mentor precedent (plugins/basic/mentor_webhook_auth.py) and #14455.

Bounty

Per the Contribution guide ("If there are no paid bounties available, you can suggest your own"), proposing US$200 for this fix plus regression tests, in line with the per-app security fixes already paid (#14453, #14451). PR with fix + tests follows.

cc @josancamon19 @kodjima33

Activity

  1. moved this from Someday to In progress in omi TODO / bountieson Sep 19, 2026
  2. added 2 commits that reference this issue on Sep 19, 2026
    c4395fe
    8e7f117
  3. aryanorastar commented on Sep 22, 2026

    @aryanorastar
    Collaborator

    Later copy of the same ms365 /tools body-uid report. Keep #14455 / PR #14456 as the vehicle.

  4. moved this from In progress to In review in omi TODO / bountieson Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions