T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/feishu_send_media.py:91
- Finding
- Unmatched agents can silently inherit an unrelated Feishu account<![CDATA[ ## Vulnerability Details **File Location**: `scripts/feishu_send_media.py`, lines 91-99 **Vulnerability Type**: `T05: Unauthorized Access and Privilege Escalation` **Risk Level**: High ### Vulnerable Code ```python if not account_id and bindings: account_id = bindings[0].get("match", {}).get("accountId") if not account_id and accounts: account_id = next(iter(accounts), None) if account_id: account = accounts.get(account_id, {}) app_id = account.get("appId") app_secret = account.get("appSecret") if app_id and app_secret: return app_id, app_secret ``` ### Technical Analysis When no account binding matches the resolved agent, `resolve_feishu_account()` does not fail closed. Instead, it selects the first binding and, if that does not produce an account, the first configured Feishu account. This fallback crosses account and agent authorization boundaries. In a multi-agent or multi-tenant OpenClaw installation, the first configured account may belong to an unrelated agent, workspace, or Feishu tenant. The script then uses that account's application identifier and secret to obtain a tenant access token and send the caller-selected file. The behavior is unnecessary for the declared media-delivery function. Account selection should require an exact, authorized association with the active agent. ### Attack Path 1. Multiple Feishu accounts or agent bindings are present in `~/.openclaw/openclaw.json`. 2. An attacker or untrusted agent executes the script from a workspace for which no exact binding can be found. 3. `resolve_feishu_account()` silently selects the first binding or first account. 4. The script reads that account's `appId` and `appSecret`. 5. It exchanges the credentials for a tenant access token at Feishu. 6. It uploads an attacker-selected local file and sends it to a caller-controlled recipient using the unrelated account. ### Impact Assessment An attacker could cause media to be sent under another configur ...[truncated 591 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove both first-binding and first-account fallback paths. - Require an exact binding between the resolved agent and the selected Feishu account. - Fail closed with a clear error when no matching binding exists. - If manual selection is necessary, introduce an explicit `--account-id` option and verify that the requested account is authorized for the resolved agent. - Do not permit an arbitrary account identifier supplied by the caller to bypass configured bindings. - Add tests covering unmatched agents, multiple accounts, missing bindings, and default-agent behavior. - Log the resolved agent and account identifiers, excluding secrets and access tokens, before performing an upload. ]]>
