T08 · Insecure Dependencies
- Location
scripts/generate_bank.py:75- Finding
Unpinned Third-Party Dependency Installation
- Content
View full analysis
list[dict]: try: from openai import OpenAI except ImportError: print("[ERROR] openai package not installed. Run: pip3 install openai") sys.exit(1) api_key = os.environ.get("OPENAI_API_KEY") if not api_key: print("[ERROR] OPENAI_API_KEY environment variable not set") ``` ### Technical Analysis The script instructs users to install the `openai` package using `pip3 install openai` without specifying an audited version, using a lockfile, or verifying package hashes. This causes the installed code to depend on whichever package release and transitive dependencies the package index serves at installation time. Python package installation and import can execute package-controlled code under the invoking user's privileges. If the upstream package, a transitive dependency, the configured package index, or the dependency resolution process is compromised, an attacker could introduce arbitrary code into the environment. The script also implements an external OpenAI API workflow even though `SKILL.md` directs the agent to generate questions inline and states, “Do not call any external script or API.” Although the inspected code does not transmit the API key itself, it uses that key for authentication and transmits the selected quiz topic, difficulty, and generated prompt to OpenAI. This behavior should either be removed as unnecessary or explicitly disclosed and consented to. ### Attack Path 1. A user invokes `scripts/generate_bank.py` in an environment where the OpenAI SDK is absent. 2. The script directs the user to execute `pip3 install openai`. 3. Pip resolves and downloads the current package and its dependencies ...[truncated 1258 chars]- Remediation
View remediation
