T05 · Unauthorized Access and Privilege Escalation
- Location
- scripts/authorize.py:32
- Finding
- Overprivileged Shared Device Token and Unrestricted MCP Tool Dispatch<![CDATA[ ## Vulnerability Details **File Location**: `scripts/authorize.py:32-36`, `scripts/mcp_client.py:1470-1478` **Vulnerability Type**: Excessive authorization scope and unrestricted privileged tool selection **Risk Level**: High ### Complete Code Snippet ```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" ) ``` ```python call = subparsers.add_parser("call", help="Call one tool with a JSON object on stdin") call.add_argument("tool_name") ``` ```python assert tool_name is not None return session.request( 2, "tools/call", {"name": tool_name, "arguments": arguments}, ) ``` ### Technical Analysis The Skill's declared purpose is to create Hanzi recognition-card images. Its authorization scope nevertheless grants unrelated video, music, speech, voice-write, task-cancellation, artifact-write, and general wallet-spending privileges. The bundled client also accepts an arbitrary MCP tool name and forwards it to the service without enforcing a package-specific allowlist. Consequently, the extra privileges are operationally accessible rather than merely present in an unused token. This violates least privilege. A shared bearer credential with broad spending and content-generation authority materially expands the consequences of malicious instructions, local compromise, or unintended invocation. The documentation confirms that one approval covers multiple media types, but disclosure does not make those unrelated permissions necessary for this Skill's stated functionality. ### Attack Path 1. The user authorizes the Skill through `scripts/authorize.py`. 2. Beatra issues a bearer token containing the complete broad scope. 3. The token is stored in `~/.beatra/credentials.json`. 4. An attacker who can influence Agent commands, modify local Skill instructions, or invoke the client calls: `python3 scripts/m ...[truncated 839 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Issue a package-specific token with only the scopes needed for Hanzi card generation: - Image generation. - Model listing. - Necessary artifact upload/read access. - Task status reads. - Narrow billing authority limited to approved image-generation operations. 2. Remove video, music, speech, voice-write, and task-cancellation scopes unless a documented feature requires them. 3. Replace unrestricted `call.add_argument("tool_name")` forwarding with a strict allowlist, such as: - `beatra.models.list` - `beatra.images.generate` - `beatra.images.edit` - `beatra.assets.upload` - Required task and wallet read operations 4. Reject unknown or unrelated tool names locally before establishing a privileged session. 5. Separate read-only and spending capabilities into different credentials or require explicit elevation immediately before a billable call. 6. Enforce equivalent tool restrictions on the server so a modified local client cannot bypass the package policy. ]]>
