T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/todolist_drive_folder_agent.mjs:99
- Finding
- Managed OAuth requests unrestricted access to the user's entire Google Drive<![CDATA[ ## Vulnerability Details **File Location**: `scripts/todolist_drive_folder_agent.mjs:99-104`; `scripts/todolist_agent_entrypoint.mjs:156-161` **Vulnerability Type**: Excessive OAuth permissions **Risk Level**: High ### Vulnerable Code ```javascript // scripts/todolist_drive_folder_agent.mjs:99-104 async function ensureManagedOAuth({ refreshTokenFile, clientId, clientSecret, authCode }) { if (fs.existsSync(refreshTokenFile)) { const existing = JSON.parse(fs.readFileSync(refreshTokenFile, 'utf8')); if (existing?.refresh_token) return existing; } const scopes = ['https://www.googleapis.com/auth/drive']; ``` ```javascript // scripts/todolist_agent_entrypoint.mjs:156-161 async function ensureManagedOAuth({ refreshTokenFile, clientId, clientSecret, authCode }) { // Returns { refresh_token } when available. if (fs.existsSync(refreshTokenFile)) { const existing = JSON.parse(fs.readFileSync(refreshTokenFile, 'utf8')); if (existing?.refresh_token) return existing; } const scopes = ['https://www.googleapis.com/auth/drive']; ``` ### Technical Analysis Both managed OAuth implementations request the unrestricted Google Drive scope. This scope permits the application to view, download, create, modify, and potentially delete files throughout the authorized user's Drive, subject to Google Drive API behavior and the user's existing permissions. The declared functionality is limited to reviewing and updating selected Markdown todo files. Full-Drive authorization therefore exceeds the minimum privilege normally required. The scripts retain a refresh token, so the excessive authorization is not limited to a single execution. The network exchanges themselves are directed to the official Google OAuth endpoint and are necessary for OAuth authentication. The security issue is the breadth of the requested scope, not the destination of the requests. ### Attack Path 1. A user runs either script and follows the managed OAuth authorization ...[truncated 1079 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace the unrestricted Drive scope with `https://www.googleapis.com/auth/drive.file` where the workflow can operate on files explicitly created or selected through the application. 2. Require explicit user selection or authorization for every file the Skill may process. 3. If folder-wide access cannot be implemented with a narrower scope, use a dedicated Google account or isolated Drive folder containing no unrelated content. 4. Clearly disclose any unavoidable broad permission before authorization rather than describing the OAuth mode only as managed or recommended. 5. Enforce folder membership, Markdown type, and per-file opt-in checks independently of OAuth scope before every download or update. 6. Store refresh tokens in an operating-system credential store or secrets manager when available, retain restrictive file permissions as defense in depth, and provide a documented revocation procedure. 7. Detect previously stored tokens authorized with the broad scope and require reauthorization with the reduced scope. ]]>
