T09 · Insecure Skill Coding Practices
- Location
references/details.md:65- Finding
Feishu Tenant Access Token Exposed Through Standard Output
- Content
View full analysis
Vulnerability Details
File Location:
references/details.md, line 65
Vulnerability Type: Sensitive bearer-token disclosure through logging
Risk Level: MediumVulnerable Code
python # Usage example app_id = "cli_xxxxxxxxxxxxxxxx" app_secret = "your_app_secret" token = get_tenant_token(app_id, app_secret) print(f"Tenant Token: {token}")Technical Analysis
The example prints the complete Feishu tenant access token to standard output. Tenant access tokens are bearer credentials: possession is sufficient to authenticate API requests, subject to the permissions granted to the associated Feishu application.
If this example is executed in a terminal-recorded environment, CI/CD job, notebook, shared console, process supervisor, or centralized logging system, the token can be retained and exposed to users or services that do not otherwise have access to the application's credentials.
Although the token is time-limited, its disclosure creates a usable window for unauthorized API access. The surrounding authentication request to the official
https://open.feishu.cnendpoint is necessary for the declared functionality; the vulnerability is the subsequent plaintext output of the returned token.Attack Path
- An operator follows and executes the documented authentication example.
- A valid tenant access token is printed in full to standard output.
- The output is captured by terminal history, CI logs, notebook output, monitoring software, or centralized log storage.
- An unauthorized person or compromised service reads the retained token.
- The attacker places the token in an
Authorization: Bearer ...header and calls Feishu APIs before it expires. - Feishu accepts requests within the scopes granted to the application.
Impact Assessment
A disclosed token may permit unauthorized actions across the application's granted scopes. Depending on tenant configuration, these could ...[truncated 595 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove the statement that prints the complete token:
python token = get_tenant_token(app_id, app_secret) print("Tenant token obtained successfully") -
If diagnostic identification is necessary, display only a non-reusable, masked fragment:
python print(f"Tenant token obtained: {token[:4]}...{token[-4:]}") -
Prohibit authentication tokens, application secrets, and authorization headers from application and HTTP debug logs.
-
Add redaction filters for fields such as
tenant_access_token,app_secret, andAuthorizationbefore logs are emitted or forwarded. -
Restrict access to CI output, notebooks, terminal recordings, and centralized logs; configure short retention periods where authentication workflows are executed.
-
Apply least privilege by granting only the specific Feishu scopes required for each automation scenario rather than the complete permission list.
-
If a real token has already appeared in logs, remove the retained output, investigate access to those logs, and revoke or rotate the associated application credentials where exposure cannot be confidently contained.
-
