T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- commands.md:20
- Finding
- Microsoft Graph Recipe Requests Unnecessary Calendar Write Access## Vulnerability Details **File Location**: `commands.md`, lines 20–25 **Vulnerability Type**: Excessive delegated OAuth permissions **Risk Level**: Medium ### Vulnerable Code ```powershell Import-Module Microsoft.Graph.Calendar Connect-MgGraph -Scopes "Calendars.Read","Calendars.ReadWrite" Get-MgUserCalendarView -UserId $userId -StartDateTime "2026-03-09T00:00:00+01:00" -EndDateTime "2026-03-16T00:00:00+01:00" New-MgUserEvent -UserId $userId -Subject "Weekly review" -Start @{DateTime="2026-03-14T17:00:00";TimeZone="Europe/Madrid"} -End @{DateTime="2026-03-14T17:45:00";TimeZone="Europe/Madrid"} ``` ### Technical Analysis The Microsoft Graph adapter recipe requests both `Calendars.Read` and `Calendars.ReadWrite` during initial authentication. `Calendars.ReadWrite` already includes calendar-reading capability and grants substantially more authority than is necessary for read-only operations such as retrieving a calendar view, checking conflicts, or preparing a proposed schedule. This conflicts with the project's stated least-privilege and approval model. Although the documentation instructs the agent to obtain approval before calendar writes, authorization is granted at connection time, before any operation-specific approval. Application-level instructions do not technically constrain an OAuth token that already possesses write access. ### Attack Path 1. A user asks the agent to inspect an Outlook calendar or perform a read-only conflict audit. 2. The agent follows the documented Microsoft Graph recipe. 3. `Connect-MgGraph` requests `Calendars.ReadWrite` despite the task requiring only read access. 4. The user grants the requested delegated permission. 5. The resulting Graph session can create, modify, or delete calendar events. 6. A compromised agent session, malicious local process, misused PowerShell command, or other code operating through that authenticated session can perform unauthorized calendar writes without ...[truncated 660 chars]
- Remediation
- ## Remediation Suggestions Separate read-only and write-enabled authentication flows: ```powershell # Default read-only workflow Import-Module Microsoft.Graph.Calendar Connect-MgGraph -Scopes "Calendars.Read" Get-MgUserCalendarView -UserId $userId ` -StartDateTime "2026-03-09T00:00:00+01:00" ` -EndDateTime "2026-03-16T00:00:00+01:00" ``` Only request write access after the user explicitly approves a specific calendar modification: ```powershell # Run only after explicit write approval Disconnect-MgGraph Connect-MgGraph -Scopes "Calendars.ReadWrite" New-MgUserEvent -UserId $userId ` -Subject "Weekly review" ` -Start @{DateTime="2026-03-14T17:00:00";TimeZone="Europe/Madrid"} ` -End @{DateTime="2026-03-14T17:45:00";TimeZone="Europe/Madrid"} ``` Additional hardening measures: - Do not request both scopes because `Calendars.ReadWrite` subsumes read access. - Place read and write commands in clearly separated documentation sections. - Make `Calendars.Read` the documented default. - Display the exact target calendar, event data, and side effects before elevating permission. - Disconnect or clear the Graph context after completing the approved write. - Where supported, apply tenant consent policies and conditional-access controls to limit delegated calendar write access.
