T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/authorize.py:31
- Finding
- Overprivileged Device Token Combined with Unrestricted Tool Dispatch<![CDATA[ ## Vulnerability Details **File Location**: `scripts/authorize.py:31-35`; `scripts/mcp_client.py:1463-1482` **Vulnerability Type**: Excessive authorization scope and missing local tool allowlist **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" ) ``` ```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}, ) ``` ### Technical Analysis The declared purpose of the Skill is to create risk-grade image stills. However, authorization requests a shared bearer token with permissions for unrelated capabilities, including video, music, speech, voice writing, artifact writing, wallet spending, and task cancellation. The command dispatcher accepts an arbitrary `tool_name` from the command line and forwards it to the remote MCP endpoint without enforcing a package-specific allowlist. Consequently, the broad token permissions are directly reachable through the bundled client rather than merely being dormant scopes. This violates least privilege. The legitimate workflow appears to require image generation and editing, optional artifact upload, model discovery, task reads, wallet reads, and narrow ...[truncated 1182 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Issue a package-specific token with only the scopes required by this Skill. 2. Remove unrelated video, music, speech, and voice scopes. 3. Separate read-only wallet access from wallet spending and request spending authority only immediately before an approved billable operation. 4. Add a strict local tool allowlist, for example: - `beatra.models.list` - `beatra.images.generate` - `beatra.images.edit` - `beatra.assets.upload` - `beatra.tasks.get` - `beatra.tasks.list` - narrowly required wallet-read operations 5. Gate billable tools and `beatra.tasks.cancel` on explicit, operation-specific user approval. 6. Reject unknown tool names locally before opening an authenticated MCP session. 7. Avoid sharing one full-scope token across unrelated packages; use audience- and package-restricted credentials where supported. ]]>
