T09 · Insecure Skill Coding Practices
- Location
scripts/nano_banana_2.py:163- Finding
API Key Exposure Through Command-Line Arguments
- Content
View full analysis
Optional[str]: return explicit_api_key or os.environ.get(ENV_KEY_NAME) or load_api_key_from_openclaw_config() ``` ```python def add_common_auth_args(parser: argparse.ArgumentParser) -> None: parser.add_argument("--api-key", help="NanoPhoto API key") parser.add_argument("--timeout", type=int, default=60, help="Per-request timeout in seconds (default: 60)") parser.add_argument("--user-agent", default=DEFAULT_USER_AGENT, help="HTTP User-Agent override") ``` ```python api_key = resolve_api_key(getattr(args, "api_key", None)) if not api_key: fail("Missing API key. Pass --api-key, set NANOPHOTO_API_KEY, or configure ~/.openclaw/openclaw.json skills.entries.nano-banana-2.env.NANOPHOTO_API_KEY.") ``` ### Technical Analysis The script explicitly accepts the NanoPhoto API key through the `--api-key` command-line option and prioritizes that value during credential resolution. A command such as: ```bash python3 scripts/nano_banana_2.py submit --api-key SECRET_VALUE --prompt "Example" ``` places the credential in the process command line. Depending on the operating system and runtime environment, command-line arguments may be exposed through process inspection facilities, process-monitoring software, audit logs, shell history, terminal logging, job metadata, or diagnostic reports. The project already supports safer credential sources through the `NANOPHOTO_API_KEY` environment variable and the OpenClaw configuration file. Consequently, accepting the credential directly through an ordinary command-line argument is unnecessary and increases the credential exposure surface. The key is legitimately transmitted as an HTTPS Bearer token to the documented Nan ...[truncated 1481 chars]- Remediation
View remediation
Optional[str]: return os.environ.get(ENV_KEY_NAME) or load_api_key_from_openclaw_config() ``` The parser should omit `--api-key`, and the call site should use: ```python api_key = resolve_api_key() if not api_key: fail( "Missing API key. Set NANOPHOTO_API_KEY or configure " "~/.openclaw/openclaw.json skills.entries.nano-banana-2.env.NANOPHOTO_API_KEY." ) ``` ]]>
