T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/fetch_message.py:148
- Finding
- Tenant Access Token Exposure Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/fetch_message.py`, lines 148-157; documented in `SKILL.md`, line 39 **Vulnerability Type**: Credential exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```python def resolve_token(args): if args.token: return args.token app_id = os.environ.get("FEISHU_APP_ID") app_secret = os.environ.get("FEISHU_APP_SECRET") if not app_id or not app_secret: app_id, app_secret = get_openclaw_feishu_creds() if not app_id or not app_secret: print("Error: Provide --token, set FEISHU_APP_ID/FEISHU_APP_SECRET, " "or have OpenClaw config at ~/.openclaw/openclaw.json", file=sys.stderr) sys.exit(1) return get_tenant_token(app_id, app_secret) ``` ```python parser.add_argument("--token", help="tenant_access_token (auto if not provided)") ``` The documented interface also recommends this option: ```markdown Alternatively set `FEISHU_APP_ID` + `FEISHU_APP_SECRET` env vars, or pass `--token <tenant_access_token>`. ``` ### Technical Analysis The Skill permits a Feishu tenant access token to be supplied directly as a command-line argument. Command-line arguments are not an appropriate secret-transport mechanism because they may be exposed through: - Shell history files. - Process inspection utilities or operating-system process interfaces. - Command auditing, terminal recording, and job execution logs. - Wrapper scripts, orchestration systems, or diagnostic reports that record complete command lines. The script does not intentionally transmit the token to an unrelated service. It uses the token as a bearer credential only for the fixed official Feishu API origin. The vulnerability is instead the local exposure created before the network request occurs. ### Attack Path 1. A user obtains a valid Feishu tenant access token. 2. The user runs the documented command with `--token <tenant_access_token>`. 3. The complete invocation ...[truncated 1068 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the `--token` command-line option so bearer tokens cannot be supplied through process arguments. 2. Prefer a permission-restricted credential store or the existing OpenClaw configuration mechanism. 3. If direct token input is necessary, read it from standard input without terminal echo, for example through Python's `getpass` module. 4. An environment variable may be retained as a compatibility mechanism, but a protected credential store is preferable because environment variables can also be exposed through diagnostics or inherited by child processes. 5. Update `SKILL.md` to remove examples that encourage users to place tenant tokens on the command line. 6. Ensure errors never include tokens, application secrets, authorization headers, or complete authentication responses. 7. Document the minimum Feishu scopes required for message retrieval and recommend short-lived credentials and prompt revocation after suspected disclosure. ]]>
