T09 · Insecure Skill Coding Practices
- Location
scripts/hot_scanner.py:22- Finding
Full Process Environment Exposed to a Third-Party Twitter CLI
- Content
View full analysis
- Remediation
View remediation
dict[str, str]: credentials = {} if not path.exists(): return credentials for raw_line in path.read_text(encoding="utf-8").splitlines(): line = raw_line.strip() if not line or line.startswith("#") or "=" not in line: continue key, value = line.split("=", 1) key = key.strip() if key in ALLOWED_BIRD_KEYS: credentials[key] = value.strip().strip('"').strip("'") return credentials ``` 3. Construct a minimal subprocess environment instead of copying the complete parent environment: ```python credentials = load_bird_credentials(ENV_FILE) bird_env = { "PATH": os.environ.get("PATH", ""), "AUTH_TOKEN": credentials.get("AUTH_TOKEN", os.environ.get("AUTH_TOKEN", "")), "CT0": credentials.get("CT0", os.environ.get("CT0", "")), } result = subprocess.run( [bird_bin, "search", query, "-n", "15", "--json"], capture_output=True, text=True, timeout=30, env=bird_env, check=False, ) ``` 4. Reject or ignore unexpected `.env` keys and duplicate credential definitions. 5. Resolve `bird` to an explicitly configured, verified executable rather than relying on the ambient `PATH`. 6. Document that the Twitter integration receives account session credentials and should run in an isolated environment without unrelated secrets. 7. Prefer a scoped API credential over reusable browser session cookies where Twitter/X provides an appropriate supported mechanism. ]]>
