T09 · Insecure Skill Coding Practices
- Location
scripts/feishu_api.py:10- Finding
Unrestricted API Base URL Can Exfiltrate Feishu Application Credentials
- Content
View full analysis
None: self.base_url = get_optional('FEISHU_BASE_URL', 'https://open.feishu.cn') self.app_id = get_required('FEISHU_APP_ID') self.app_secret = get_required('FEISHU_APP_SECRET') def tenant_access_token(self) -> str: resp = requests.post( f'{self.base_url}/open-apis/auth/v3/tenant_access_token/internal', headers={'Content-Type': 'application/json; charset=utf-8'}, json={'app_id': self.app_id, 'app_secret': self.app_secret}, timeout=30, ) ``` The endpoint can also be implicitly selected through environment files in the current working directory: ```python def load_local_env() -> None: candidates = [ Path.cwd() / '.env.local', Path.cwd() / '.env', ROOT_DIR / '.env.local', ROOT_DIR / '.env', ] for item in candidates: _load_env_file(item) ``` ### Technical Analysis `FEISHU_BASE_URL` is used directly when constructing the authentication endpoint. The implementation does not enforce HTTPS, validate the hostname against an allowlist, reject URL credentials, or otherwise establish that the destination is an authorized Feishu/Lark API service. The application ID and application secret are included in the body of the first request to this configurable destination. If the destination returns a successful token-shaped response, the same base URL is subsequently used to transmit the bearer token, destination identifier, and reminder message. The risk is increased by loading `.env` and `.env.local` from the current working directory. A file controlled by another local user, deployment artifact, or untrusted workspace can alter `FEI ...[truncated 1809 chars]- Remediation
View remediation
