T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/post_with_image.py:25- Finding
Excessive Credential Propagation to Child Processes
- Content
View full analysis
str: result = subprocess.run( ["uv", "run", NANO_BANANA_SCRIPT, "--prompt", prompt, "--filename", out_path, "--resolution", "1K"], capture_output=True, text=True, env={**os.environ, "GEMINI_API_KEY": os.environ.get("GEMINI_API_KEY", "")} ) ``` ```python def post_tweet(text: str, media_id: str = None): cmd = ["xurl", "post", text] if media_id: cmd += ["--media-id", media_id] result = subprocess.run(cmd, capture_output=True, text=True) print(result.stdout) if result.returncode != 0: raise RuntimeError(result.stderr) ``` ### Technical Analysis The image-generation subprocess is explicitly given a copy of the entire parent environment through `env={**os.environ, ...}`. The parent environment contains the Twitter OAuth credentials read by this script: - `X_CONSUMER_KEY` - `X_CONSUMER_SECRET` - `X_ACCESS_TOKEN` - `X_ACCESS_TOKEN_SECRET` The image generator only requires the Gemini credential, but it also receives all Twitter credentials and any other secrets present in the process environment. In addition, `NANO_BANANA_SCRIPT` is configurable through an environment variable. If an attacker can influence that variable, the selected script can directly inspect its inherited environment. The `xurl` subprocess does not provide an explicit environment, so Python gives it the complete inherited environment by default. It can therefore access `GEMINI_API_KEY` and unrelated sensitive variables even though they are unnecessary for ...[truncated 1856 chars]- Remediation
View remediation
