T09 · Insecure Skill Coding Practices
- Location
SKILL.md:88- Finding
API Key Exposure Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:88;scripts/sora_world.py:342-353,357
Vulnerability Type: API key disclosure through process arguments and shell history
Risk Level: MediumVulnerable Code
SKILL.md:88:bash python3 "$SKILL_PATH/scripts/sora_world.py" configure --api-key sk-api-your-ai-hive-keyscripts/sora_world.py:342-353,357:python def configure(args): if not args.api_key.startswith("sk-api-") or len(args.api_key) < 20: raise SystemExit("API Key 格式错误,应为完整的 sk-api-*") KEY_FILE.parent.mkdir(parents=True, exist_ok=True) KEY_FILE.write_text( json.dumps({"api_key": args.api_key}, indent=2), encoding="utf-8", ) KEY_FILE.chmod(0o600) print("已安全写入", KEY_FILE)python config.add_argument("--api-key", required=True)Technical Analysis
The documented configuration procedure requires users to place the AI Hive API key directly in a command-line argument. Command-line secrets can be retained in shell history, terminal logs, command auditing systems, support bundles, or process-monitoring telemetry. Depending on the operating system configuration, another local account or monitoring process may also be able to inspect active process arguments.
The implementation accepts the same
--api-keyargument for other client operations. Although the persistent configuration file is changed to mode0600, that permission does not protect the key before it is written or remove copies retained by shell history and process-observation systems.Attack Path
- A user follows the documented command and supplies a valid API key through
--api-key. - The shell records the complete command in its history, or a local process-monitoring or audit facility records the process arguments.
- A local attacker, compromised monitoring component, or user with access to the history or diagnostic data retrieves ...[truncated 728 chars]
- A user follows the documented command and supplies a valid API key through
- Remediation
View remediation
Remediation Suggestions
- Replace command-line secret entry with an interactive prompt implemented using Python's
getpass.getpass(). - Support reading the key from standard input or a pre-existing protected credential file without echoing it.
- Remove secret-bearing command examples from
SKILL.md. - If environment-variable authentication remains supported, document that environment variables may also be exposed by diagnostics, child processes, or misconfigured process-inspection facilities.
- Retain the
0600file permission and create the file atomically with restrictive permissions to avoid a brief period with broader default permissions. - Recommend rotating any key previously supplied through shell commands and removing affected entries from shell history and operational logs.
- Replace command-line secret entry with an interactive prompt implemented using Python's
