T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/authorize.py:30
- Finding
- Overprivileged Device Token Exceeds the Skill's Functional Requirements<![CDATA[ ## Vulnerability Details **File Location**: `scripts/authorize.py:30-34`, `scripts/authorize.py:216-227` **Vulnerability Type**: Excessive OAuth authorization scope **Risk Level**: High ### Vulnerable Code ```python SCOPE = ( "mcp:tools artifacts:write images:generate videos:generate music:generate " "speech:generate voices:read voices:write wallet:spend tasks:read artifacts:read tasks:cancel" ) ``` The credential validation logic requires the stored credential to contain this entire scope: ```python if ( not isinstance(value, dict) or value.get("schema_version") != 1 or value.get("mcp_url") != MCP_URL or value.get("token_type") != "Bearer" or any(not isinstance(value.get(name), str) or not value[name] for name in required_strings) or set(value["scope"].split()) != set(SCOPE.split()) ): return None ``` ### Technical Analysis The Skill's declared purpose is to create lab-cover images. Its legitimate requirements are limited to image generation and editing, optional artifact uploads, model discovery, billing information, and task status operations. The requested Device Token additionally grants video generation, music generation, speech generation, voice-resource write access, general wallet spending, artifact reads, and task cancellation. These permissions are unrelated to producing still lab covers. The credential is shared by Beatra Skills and is accepted only when it contains the complete scope set. This prevents use of a narrower credential and violates the principle of least privilege. Any compromise of this package, its updater, or its Agent instructions therefore exposes capabilities substantially broader than the Skill's advertised function. ### Attack Path 1. The user invokes the authorization helper. 2. The helper requests the full scope set from the Beatra authorization service. 3. The user approves the Device Token through the browser. 4. The broad bearer token is saved in `~/.beatra/credentials. ...[truncated 845 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Issue a package-specific, least-privilege token instead of requiring one shared full-scope credential. - Restrict the authorization request to capabilities required by this Skill, such as: - Model discovery for text-to-image. - Image generation and explicitly requested image editing. - Optional artifact upload. - Package-owned task reads and narrowly scoped cancellation. - Read-only wallet balance or ledger access when requested. - Remove video, music, speech, voice-write, and unrestricted wallet-spending scopes. - Do not reject an otherwise valid credential merely because it lacks capabilities unrelated to lab-cover generation. - Implement server-side audience and package restrictions so a token issued for this Skill cannot invoke unrelated Beatra tools. - Display the requested permissions clearly on the authorization page before approval. ]]>
