T09 · Insecure Skill Coding Practices
- Location
scripts/perform_image_gen.py:54- Finding
API Key Exposure Through Command-Line Arguments
- Content
View full analysis
str | None: """Get API key from argument, config, or environment.""" if provided_key: return provided_key return os.environ.get("GITEEAI_API_KEY") ``` ### Technical Analysis Secrets passed through command-line arguments may be exposed outside the intended process. Depending on the operating system and runtime environment, command arguments can appear in process inspection interfaces, monitoring agents, diagnostic output, job execution records, shell history, or orchestration logs. The documentation makes this exposure more likely by presenting `--api-key YOUR_API_KEY` as the normal invocation method. The script also gives the command-line value precedence over the environment variable. The key is not hardcoded and is not deliberately printed by the script, but its presence in the process invocation creates an avoidable credential-handling weakness. Exploitation requires access to command history, process metadata, or a logging system that records invocations. It is therefore primarily a local or operational credential-disclosure issue rather than a remote ...[truncated 1158 chars]- Remediation
View remediation
str | None: return os.environ.get("GITEEAI_API_KEY") ``` The invocation should then omit the secret: ```bash GITEEAI_API_KEY="..." python scripts/perform_image_gen.py \ --prompt "your image description" \ --model Qwen-Image ``` For higher-assurance deployments, the environment value should itself be populated by a protected secret-management facility rather than committed to a file or embedded in reusable shell scripts. ]]>
