T09 · Insecure Skill Coding Practices
Warning
- Location
- call_aida_app.py:42
- Finding
- Bearer token may be exposed through command-line arguments and environment variables<![CDATA[ ## Vulnerability Details **File Location**: `call_aida_app.py:42-58` **Additional Locations**: `SKILL.md:21-29`, `README.zh.md:17-32`, `EXAMPLES.md:57-67` **Vulnerability Type**: Insecure credential handling **Risk Level**: Medium ### Vulnerable Code ```python parser = argparse.ArgumentParser(description="调用 AI 搭 chat-messages 接口") parser.add_argument("--appid", help="AI 搭 appid (Bearer Token)") parser.add_argument("--query", default="", help="用户 query,可选") parser.add_argument("--inputs", help="inputs JSON 字符串") parser.add_argument("--user", default="openclaw", help="用户标识") args = parser.parse_args() if args.appid and args.inputs: try: inputs = json.loads(args.inputs) if isinstance(args.inputs, str) else args.inputs return args.appid, args.query, inputs except json.JSONDecodeError: pass # 3. 环境变量 appid = os.environ.get("AIDA_APPID") query = os.environ.get("AIDA_QUERY", "") inputs_str = os.environ.get("AIDA_INPUTS") ``` The documentation actively recommends command-line token submission: ```bash python3 main.py --appid <用户提供的appid> --query "<用户提供的query>" --inputs '<用户提供的inputs的JSON字符串>' ``` It also recommends exporting the token into the process environment: ```bash export AIDA_APPID="your-app-id" export AIDA_INPUTS='{"key": "value"}' export AIDA_QUERY="optional query" export AIDA_USER="your-username" ``` ### Technical Analysis The project identifies `appid` as a bearer token but supports and documents passing it as a command-line argument. Command-line arguments can be retained in shell history and may be visible through process inspection, CI job logs, terminal recording, monitoring agents, or diagnostic reports. Environment variables are safer than command-line arguments in some environments but remain vulnerable to inheritance by child processes, accidental diagnostic dumps, CI configuration exposure, and access by sufficiently privileged local processes. Several stdin examples use `echo` with the toke ...[truncated 1620 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove bearer-token values from command-line examples and discourage use of `--appid` for production credentials. 2. Prefer integration with an operating-system keychain, CI secret manager, or dedicated secrets-management service. 3. Support reading the token from a permission-restricted file, inherited file descriptor, or interactive hidden prompt. 4. If environment-variable support is retained: - Clearly document its exposure and inheritance risks. - Avoid printing the environment in diagnostics. - Unset the variable immediately after loading it where practical. - Prevent child processes from inheriting it unnecessarily. 5. Do not embed real tokens in `echo` commands. Provide an interactive or protected-file stdin example instead. 6. Ensure logging, exception handling, and telemetry never include the `Authorization` header or raw token. 7. Recommend narrowly scoped and short-lived tokens, with rotation and revocation procedures. ]]>
