T09 · Insecure Skill Coding Practices
- Location
scripts/gemini_smart_search.sh:7- Finding
Executable and Overly Broad Loading of Repository-Local Environment Configuration
- Content
View full analysis
None: if os.environ.get("GEMINI_SMART_SEARCH_SKIP_LOCAL_ENV") == "1": return script_dir = Path(__file__).resolve().parent env_path = script_dir.parent / ".env.local" if not env_path.exists(): return for raw_line in env_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() value = value.strip() if not key or key in os.environ: continue if value and len(value) >= 2 and value[0] == value[-1] and value[0] in {'"', "'"}: value = value[1:-1] os.environ[key] = value ``` ### Technical Analysis The shell wrapper loads `.env.local` using the Bash `.` command. This does not parse the file as passive key-value configuration; it executes the entire file as shell code in the wrapper's process. A crafted file can contain command substitutions, shell commands, redirections, functions, or other Bash constructs. These execute before the wrapper invokes the Python search implementation. The Python loader avoids direct shell execution, but it accepts every key found in `.env.local` and inserts it into `os.environ`. The Skill only needs `SMART_SEARCH_GEMINI_API_KEY` and the compatibility fallback `GEMINI_API_KEY`. Importing ...[truncated 2369 chars]- Remediation
View remediation
