T09 · Insecure Skill Coding Practices
- Location
scripts/upload_image.py:78- Finding
Tenant Access Token Exposure Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/upload_image.py, lines 78–82
Vulnerability Type: Credential exposure through process arguments and shell history
Risk Level: MediumVulnerable Code
python parser.add_argument( "--token", default=None, help="tenant_access_token(不传则从环境变量 FEISHU_TENANT_ACCESS_TOKEN 获取)", )The insecure invocation method is also documented in
webhook-image.md, lines 47–48:bash # 指定 token uv run upload_image.py <image_path> --token <tenant_access_token>Technical Analysis
The script permits a Feishu tenant access token to be supplied directly through the
--tokencommand-line option. Command-line arguments are not an appropriate secret-transport mechanism because they may be exposed through:- Process inspection utilities and operating-system process interfaces.
- Shell command history.
- Process-monitoring and endpoint-management agents.
- CI/CD task logs, wrapper scripts, and debugging telemetry.
- Error reports that record complete command invocations.
The script already supports retrieving the token from
FEISHU_TENANT_ACCESS_TOKEN, which avoids placing it in the process argument vector. However, the documentation explicitly promotes the less secure command-line alternative.The bearer-token transmission itself at
scripts/upload_image.py:57-69is necessary for the declared image-upload functionality and is limited to Feishu's official HTTPS endpoint,https://open.feishu.cn/open-apis/im/v1/images. The vulnerability concerns local handling of the credential before that transmission, not the intended API request.Attack Path
- A user follows the documented example and runs the uploader with
--token <tenant_access_token>. - The token is stored in the process argument vector and may also remain in shell history or execution logs.
- A local process-inspection user, monitoring service, log reader, or ...[truncated 1099 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the
--tokenargument and obtain the credential exclusively fromFEISHU_TENANT_ACCESS_TOKEN, an operating-system secret manager, or another protected credential provider. - If interactive entry is required, use a non-echoing prompt such as Python's
getpass.getpass()rather than a command-line argument. - Remove the command-line token example from
webhook-image.mdand document the protected environment-variable or secret-manager workflow instead. - If backward compatibility requires retaining
--token, clearly mark it as deprecated and insecure, avoid displaying it in examples, and reject its use in shared, logged, or multi-user environments. - Ensure CI/CD systems inject the token through masked secret variables and do not print environment values or complete command invocations.
- Rotate any tenant access token that may previously have been supplied through command-line arguments in environments where process lists, shell histories, or logs are accessible.
- Remove the
