T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/flomo_tool.py:173
- Finding
- Bearer Token Can Be Transmitted to an Arbitrary API Host<![CDATA[ ## Vulnerability Details **File Location**: `scripts/flomo_tool.py`, lines 173-202 **Vulnerability Type**: Unrestricted credential destination **Risk Level**: Medium ### Vulnerable Code ```python def _api_get(path: str, extra_params: dict | None = None) -> dict: base = os.getenv("FLOMO_API_BASE", "https://flomoapp.com/api/v1").rstrip("/") params = { "api_key": "flomo_web", "app_version": _get_app_version(), "platform": os.getenv("FLOMO_PLATFORM", "mac"), "timestamp": int(time.time()), "webp": "1", } if extra_params: params.update(extra_params) params["sign"] = _sign_params(params.copy()) url = f"{base}{path}?{urllib.parse.urlencode(params, doseq=True)}" return _curl_json( "GET", url, headers={ "Accept": "application/json, text/plain, */*", "Authorization": f"Bearer {_get_access_token()}", "platform": "Mac", "device-model": "Mac", }, ) ``` ### Technical Analysis The `FLOMO_API_BASE` environment variable can replace the default API origin with an unrestricted URL. Regardless of the selected origin, `_api_get()` attaches the bearer token obtained from `FLOMO_ACCESS_TOKEN` or the local flomo desktop configuration. Consequently, configuration or launch-environment manipulation can redirect an authenticated request to an attacker-controlled HTTP or HTTPS server. Customizing the credential-bearing API host is not required for the Skill's ordinary flomo read/write functionality and exceeds the minimum privilege needed for the declared behavior. The English and Chinese README files explicitly document the unrestricted `FLOMO_API_BASE` override, making this behavior part of the supported configuration rather than an unreachable implementation detail. ### Attack Path 1. An attacker or compromised orchestration component influences the Skill's launch environment. 2. `FLOMO_API_BASE` is set to an ...[truncated 893 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove `FLOMO_API_BASE` if custom API origins are not essential. 2. Otherwise, parse and validate the URL before issuing any request: - Require HTTPS. - Require the exact approved hostname, such as `flomoapp.com`. - Reject embedded credentials, unexpected ports, IP literals, fragments, and deceptive subdomains. 3. Maintain a strict allowlist of paths that may receive the bearer token. 4. Prevent authenticated requests from following redirects to a different origin. If redirects are needed, validate every destination before retaining the authorization header. 5. Do not attach credentials to any endpoint until its scheme, hostname, port, and path have been validated. 6. Remove the unrestricted override from both README files or document only an explicitly safe, allowlisted development mode that never uses production credentials. 7. Add tests confirming that attacker-controlled hosts and cross-origin redirects are rejected before credential retrieval or network transmission. ]]>
