T05 · Unauthorized Access and Privilege Escalation
Note
- Location
- scripts/setup-device-code.sh:116
- Finding
- Unnecessary User.Read Permission and Account Profile Disclosure<![CDATA[ ## Vulnerability Details **File Location**: `scripts/setup-device-code.sh:116-121` and `scripts/setup-device-code.sh:286-300` **Vulnerability Type**: Excessive OAuth permission and unnecessary access to user profile information **Risk Level**: Low ### Vulnerable Code The device-code flow requests `User.Read` in addition to the permissions required for Microsoft To Do: ```bash ALLOWED_SCOPES=( "offline_access" "https://graph.microsoft.com/User.Read" "https://graph.microsoft.com/Tasks.ReadWrite" ) SCOPE_JOINED="${ALLOWED_SCOPES[*]}" ``` After authentication, the setup script uses this permission to retrieve and print the signed-in account's user principal name: ```bash load_config || die "config missing after save" PROBE=$(curl --silent --show-error --max-time 15 \ -H "Authorization: Bearer $ACCESS" \ -H "Accept: application/json" \ "${OUTLOOK_TODO_GRAPH_BASE}/me?\$select=id,displayName,userPrincipalName") || die "probe transport error" UPN=$(echo "$PROBE" | jq -r '.userPrincipalName // empty') if [[ -z "$UPN" ]]; then # Could be a 401 or a malformed response; show a sanitized snippet SNIP=$(echo "$PROBE" | head -c 200) die "token probe did not return a userPrincipalName: $SNIP" fi ``` ### Technical Analysis The declared functionality is to read and modify Microsoft To Do lists and tasks. Microsoft Graph's `Tasks.ReadWrite` delegated permission provides the required access for those operations. The additional `User.Read` permission is used only for an optional `/me` identity probe and is not necessary for the core task-management functionality. Requesting `User.Read` expands the authority of the issued OAuth token beyond the minimum required scope. The setup script then retrieves `id`, `displayName`, and `userPrincipalName`, and prints the UPN to stderr. Although stderr is appropriate for diagnostics, it is commonly captured by terminal session recording, CI systems, agent runtimes, and centralized logging. ...[truncated 1617 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove `https://graph.microsoft.com/User.Read` from `ALLOWED_SCOPES` and from the scope documentation in `SKILL.md`. 2. Remove the `/me` identity probes from both `scripts/setup-device-code.sh` and `scripts/token.sh`. 3. Validate authentication by making a minimal request to a Microsoft To Do endpoint already covered by `Tasks.ReadWrite`, such as retrieving a limited task-list result. 4. Do not print the account UPN by default. If account identity display is considered necessary, place it behind an explicit opt-in flag and clearly disclose the additional permission before authorization. 5. After authentication, validate the returned `scope` field against the expected scope set and warn or fail if unexpected permissions are issued. 6. Add automated tests confirming that: - `User.Read` is not requested; - only approved Microsoft Graph scopes are present; - setup and status operations do not access `/me`; - account identifiers and bearer tokens are never written to output streams. ]]>
