T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/upload_image.py:46
- Finding
- Feishu application secret exposed through plaintext documentation and command-line arguments<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:10-17`; `scripts/upload_image.py:46-48` **Vulnerability Type**: Plaintext credential storage and command-line secret exposure **Risk Level**: Medium ### Relevant Code The documentation instructs users to place the Feishu App ID and App Secret directly in `USER.md`: ```markdown Configure the Feishu application credentials in USER.md: - **Feishu App ID:** cli_xxx - **Feishu App Secret:** xxx ``` The upload script also accepts the application secret as a command-line argument: ```python parser = argparse.ArgumentParser(description="Upload an image to Feishu") parser.add_argument("--image", required=True, help="Image path") parser.add_argument("--app-id", default=APP_ID, help="Feishu App ID") parser.add_argument("--app-secret", default=APP_SECRET, help="Feishu App Secret") args = parser.parse_args() ``` ### Technical Analysis The Skill recommends storing a long-lived Feishu application secret as plaintext in `USER.md`. Any agent, extension, backup process, synchronization service, or local user with access to that file or its surrounding user context may consequently obtain the credential. The script independently supports passing the same secret through `--app-secret`. Command-line arguments can be exposed through process-inspection interfaces, monitoring agents, diagnostic reports, shell history, terminal logs, and automation logs. This exposure is unnecessary because the script already supports `FEISHU_APP_SECRET` as an environment variable. The documented configuration is also inconsistent with the implementation: the script does not read `USER.md`. This inconsistency may encourage users or automation authors to copy the secret into additional files or command lines while troubleshooting. The transmission of the App ID and App Secret to Feishu's official authentication endpoint is necessary for the declared image-upload functionality. The identified risk concerns local credential handli ...[truncated 1435 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the `--app-secret` command-line option so the secret cannot be supplied through process arguments: ```python app_secret = os.environ.get("FEISHU_APP_SECRET") if not app_secret: raise RuntimeError("FEISHU_APP_SECRET must be configured securely") ``` 2. Do not instruct users to store credentials in `USER.md`, project documentation, source-controlled files, or other agent-readable context. 3. Obtain the secret from a dedicated secret manager where available. If environment variables must be used, inject them only into the upload process and avoid printing or logging the environment. 4. Validate that both the App ID and App Secret are present before making a network request. Return a generic configuration error without including secret values. 5. Ensure exception handling never prints request headers, authentication payloads, environment variables, or access tokens. 6. Restrict the Feishu application to the minimum permissions required for image upload and message delivery. Periodically review granted permissions and remove unnecessary scopes. 7. Rotate the App Secret after remediation if it has previously appeared in `USER.md`, shell history, logs, process captures, or source control. 8. Update the documentation to describe secure secret provisioning accurately and consistently with the implementation. ]]>
