T09 · Insecure Skill Coding Practices
- Location
scripts/feishu_card_sender.py:15- Finding
Hardcoded Feishu Application Credentials
- Content
View full analysis
Vulnerability Details
File Location:
scripts/feishu_card_sender.py, lines 15–16
Vulnerability Type: Hardcoded secret
Risk Level: Highpython APP_ID = os.environ.get("FEISHU_APP_ID", "cli_a9f13ef641f8dcd9") APP_SECRET = os.environ.get("FEISHU_APP_SECRET", "z7Aq63KvIUJNVRA5UbtOkd48on8rmA26")Technical Analysis
The source code embeds a live-looking Feishu application ID and application secret as fallback values. If the corresponding environment variables are absent, the Skill automatically authenticates with these shared credentials.
Anyone who can obtain the Skill package or source code can extract the credentials. The application secret is then usable with the official Feishu tenant-token endpoint invoked by
get_token():python url = "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" resp = requests.post(url, json={"app_id": self.app_id, "app_secret": self.app_secret})Sending a user-supplied application secret to Feishu's official authentication endpoint is necessary for the declared functionality. Embedding a shared secret in distributed source code is not necessary and violates least-secret-exposure principles. Environment-variable support does not mitigate the exposure because the hardcoded value remains available to every recipient of the package.
Attack Path
- An attacker downloads the Skill or obtains read access to its source.
- The attacker extracts the hardcoded application ID and secret from lines 15–16.
- The attacker submits those credentials to Feishu's internal tenant-access-token endpoint.
- If the credentials remain valid, Feishu returns a tenant access token.
- The attacker invokes Feishu APIs authorized for the application, including potentially sending messages as the application.
- The attacker can continue using the credentials until the secret is revoked, rotated, or otherwise invalidated.
Impact Assessment
If th ...[truncated 761 chars]
- Remediation
View remediation
Remediation Suggestions
- Revoke and rotate the exposed Feishu application secret immediately; removing it from the current source is insufficient if it has already been distributed.
- Remove all hardcoded credential fallback values:
python APP_ID = os.environ.get("FEISHU_APP_ID") APP_SECRET = os.environ.get("FEISHU_APP_SECRET") - Fail closed before making any network request when either credential is absent:
python if not APP_ID or not APP_SECRET: raise RuntimeError( "FEISHU_APP_ID and FEISHU_APP_SECRET must be configured securely" ) - Prefer a managed secret store or platform credential provider over plaintext environment configuration where available.
- Ensure credentials are never written to logs, exception messages, command-line arguments, examples, test fixtures, or generated artifacts.
- Review repository history, release archives, package registries, caches, and build logs for previous copies of the secret.
- Audit Feishu token issuance and API activity for unauthorized use of the exposed application.
- Restrict the Feishu application to the minimum API scopes and tenant resources required to send cards.
- Add automated secret scanning and pre-commit checks to prevent future credential commits.
