T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/parse_forward.py:233
- Finding
- Feishu Application Secret Exposed Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/parse_forward.py:233-234`; `scripts/read_forward.sh:8-12`; documented in `SKILL.md:31` and `SKILL.md:44` **Vulnerability Type**: Sensitive credential exposure through process arguments and shell history **Risk Level**: Medium ### Vulnerable Code `scripts/parse_forward.py:233-234`: ```python parser.add_argument('--app-id', help='飞书 App ID (或设置 FEISHU_APP_ID 环境变量)') parser.add_argument('--app-secret', help='飞书 App Secret (或设置 FEISHU_APP_SECRET 环境变量)') ``` `scripts/read_forward.sh:8-12`: ```bash # Usage: ./read_forward.sh <message_id> [app_id] [app_secret] MESSAGE_ID="$1" APP_ID="${2:-$FEISHU_APP_ID}" APP_SECRET="${3:-$FEISHU_APP_SECRET}" ``` `SKILL.md:31`: ```bash python3 scripts/parse_forward.py <message_id> --app-id <id> --app-secret <secret> ``` `SKILL.md:44`: ```bash ./scripts/read_forward.sh <message_id> <app_id> <app_secret> ``` ### Technical Analysis Both implementations accept the Feishu application secret directly through command-line arguments, and the documentation recommends this invocation method. Command-line arguments are not an appropriate secret transport mechanism because they can be retained in shell history and may be observable through process inspection, command auditing, CI/CD logs, terminal recording, or job orchestration metadata. The secret is subsequently exchanged with the official Feishu token endpoint for a tenant access token. The network exchange itself is necessary for the declared message-reading functionality and targets the documented Feishu domain; no unauthorized external recipient was identified. The vulnerability is the local exposure of the credential before or during that legitimate exchange. ### Attack Path 1. An operator follows the documented example and supplies the Feishu application secret in the command line. 2. The complete command is stored in shell history, captured by execution logs, or temporarily exposed through process metadata. 3. ...[truncated 1316 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove `--app-secret` and the shell script's positional secret argument so secrets cannot be supplied through process arguments. 2. Prefer a secret manager or a protected configuration file with restrictive permissions, such as mode `0600`, and validate ownership and permissions before reading it. 3. If interactive entry is required, use Python's `getpass.getpass()` so the secret is neither echoed nor embedded in command history. 4. Retain environment-variable support only where the execution environment injects variables securely; warn that inline assignments and CI logging can still disclose them. 5. Update all examples in `SKILL.md` to avoid placing secrets in commands. 6. Avoid including secrets or access tokens in errors, debug output, telemetry, or exception traces. 7. Rotate any Feishu application secret previously used through the documented command-line method and review shell histories and execution logs for exposure. 8. Apply the least Feishu permissions necessary. Keep contact lookup optional, default it off where sender names are unnecessary, and restrict the application's message visibility as narrowly as Feishu permits. ]]>
