T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/authorize.py:34
- Finding
- Over-Privileged Device Token and Unrestricted Remote Tool Invocation<![CDATA[ ## Vulnerability Details **File Location**: `scripts/authorize.py:34-38`; `scripts/mcp_client.py:1463-1480`; `scripts/mcp_client.py:1487-1490` **Vulnerability Type**: Excessive authorization scope and unrestricted MCP tool dispatch **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 generic command handler accepts any tool name supplied by the caller: ```python def _run_command(command: str, tool_name: str | None = None) -> dict[str, Any]: session = _session_with_registration( state_dir=Path.home() / ".beatra", post_json=_default_post_json, ) if command == "tools": return session.request(2, "tools/list", {}) try: arguments = json.load(os.sys.stdin) except json.JSONDecodeError as exc: raise RuntimeError("Tool arguments on stdin must be one JSON object") from exc if not isinstance(arguments, dict): raise RuntimeError("Tool arguments on stdin must be one JSON object") assert tool_name is not None return session.request( 2, "tools/call", {"name": tool_name, "arguments": arguments}, ) ``` ```python call = subparsers.add_parser("call", help="Call one tool with a JSON object on stdin") call.add_argument("tool_name") ``` ### Technical Analysis The declared Skill creates Shopify product-page still images. Its legitimate runtime requirements include image generation, model-card lookup, optional image upload, and relevant task and billing reads. The authorization request nevertheless obtains unrelated capabilities for video, music, speech, voice management, broad wallet spending, and task cancellation. The local client compounds this excessive scope by accepting an arbitrary MCP tool name without an allowlist. Possession of the shared token therefore gra ...[truncated 1415 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace the shared full-scope token with a package-specific, least-privilege token. 2. Remove unrelated scopes, including: - `videos:generate` - `music:generate` - `speech:generate` - `voices:read` - `voices:write` 3. Limit spending authority to explicitly approved image-generation operations. 4. Add a hardcoded tool allowlist containing only the operations required by this Skill, such as: - `beatra.models.list` - `beatra.assets.upload` - `beatra.images.generate` - `beatra.images.edit` - Required task, wallet, and installation-registration reads 5. Reject unknown tool names locally before creating an MCP session. 6. Separate read-only operations, billable operations, and task cancellation into distinct permission grants. 7. Require explicit user confirmation at the enforcement layer for each billable or destructive operation rather than relying only on Skill instructions. 8. Avoid sharing one broadly privileged credential across unrelated packages. ]]>
