T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/authorize.py:34
- Finding
- Device Authorization Requests Privileges Beyond the Skill’s Declared Functionality<![CDATA[ ## Vulnerability Details **File Location**: `scripts/authorize.py:34-36` **Vulnerability Type**: Excessive OAuth/device-token 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 breadth of this authorization is also disclosed in `references/installation-and-auth.md:71-74`: ```text The helper opens no local listener and requires no inbound connection. One approval covers image, video, music, speech, upload, model, and task tools. ``` ### Technical Analysis The Skill’s declared purpose is to read public Xiaohongshu complaints and create still-image material cards. Its legitimate operations include social-content lookup, image generation or editing, selected-file upload, model discovery, billing access, and task-result retrieval. The requested token additionally grants capabilities for: - Video generation - Music generation - Speech generation - Reading and writing voices - Broad artifact access - Wallet spending - Task cancellation Video, music, speech, and voice-writing permissions are not necessary for the declared still-image workflow. Broad cancellation and artifact permissions may also affect tasks or assets created by other packages because the credential is shared through `~/.beatra/credentials.json`. This violates the principle of least privilege. Although the audit found no code that intentionally abuses these permissions, the unnecessarily broad token increases the consequences of credential theft, future code compromise, or misuse by an automatically installed update. ### Attack Path 1. The user runs `scripts/authorize.py`. 2. The authorization request asks the user to approve the complete scope defined by `SCOPE`. 3. Beatra returns a bearer token containing permissions unrelated to the still-image workflow. 4. The ...[truncated 1091 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace the shared broad scope with a package-specific least-privilege scope. 2. Remove at least the following permissions unless a documented workflow explicitly requires them: - `videos:generate` - `music:generate` - `speech:generate` - `voices:read` - `voices:write` 3. Restrict `tasks:cancel` to tasks created by this package, or request it only when the user explicitly initiates cancellation. 4. Restrict artifact access to artifacts uploaded or generated by this package. 5. Separate read-only discovery and account operations from credit-spending operations where the authorization service supports granular scopes. 6. Bind wallet spending to explicit operation families and package identity on the server. 7. Display the exact requested permissions on the approval page, emphasizing paid and destructive capabilities. 8. Add server-side authorization tests confirming that this package cannot invoke unrelated media-generation or cross-package task-management operations. 9. Rotate existing credentials after narrowing the scope so previously issued broad tokens no longer remain valid. ]]>
