T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- scripts/youtube_upload.py:36
- Finding
- OAuth Authorization Requests Excessive YouTube Account Privileges<![CDATA[ ## Vulnerability Details **File Location**: `scripts/youtube_upload.py`, lines 36-40 **Vulnerability Type**: Excessive OAuth scopes and violation of least privilege **Risk Level**: Medium ### Vulnerable Code ```python SCOPES = [ "https://www.googleapis.com/auth/youtube.upload", "https://www.googleapis.com/auth/youtube", "https://www.googleapis.com/auth/youtube.force-ssl", ] ``` ### Technical Analysis The application requests three overlapping OAuth scopes, including the broad `youtube` scope. This grants authority to manage YouTube account resources beyond the upload operation and read-only commands exposed by the script. The broad authorization is applied unconditionally by `get_authenticated_service()`, so even commands that only list channels, videos, or playlists receive the same account-management permissions as mutating operations. Combining this with a persistent refresh token increases the consequences of token disclosure. At minimum, the general `youtube` scope is redundant when narrower scopes are used. Operations with materially different privilege requirements should not automatically share one broadly authorized credential. ### Attack Path 1. A user completes the OAuth flow and approves all scopes requested by the script. 2. Google issues credentials containing a refresh token with the approved YouTube privileges. 3. The application stores those credentials in `token.json`. 4. An attacker who obtains the token through local file access, malware, accidental backup exposure, or another vulnerability refreshes the access token. 5. The attacker invokes YouTube Data API operations allowed by the broad scopes. 6. The attacker can modify account resources beyond the minimum privileges needed for a simple upload or listing command. ### Impact Assessment Successful exploitation requires access to the OAuth credentials rather than merely control over ordinary command-line metadata. The exposed authorization may permit broad mo ...[truncated 309 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the general `https://www.googleapis.com/auth/youtube` scope unless a documented operation strictly requires it. 2. Determine the minimum Google scope required for every implemented command. 3. Use read-only authorization for `channels`, `list`, and `playlists` where possible. 4. Use `youtube.upload` only for video-upload operations. 5. Isolate playlist-modification authorization from read-only and upload-only credentials if the required Google scope is substantially broader. 6. Store separately authorized tokens for privilege tiers rather than granting every command a single union of all scopes. 7. Clearly display the requested privileges before starting the consent flow. 8. After reducing scopes, revoke existing tokens and require reauthorization so previously issued broad grants cannot continue to be used. ]]>
