T08 · Insecure Dependencies
- Location
evals/run_evals.py:7- Finding
Unverified External Python Module Import Enables Arbitrary Code Execution
- Content
View full analysis
Vulnerability Details
File Location:
evals/run_evals.py:7-10
Vulnerability Type: Unsafe external dependency loading through Python path manipulation
Risk Level: HighVulnerable Code:
python REPO_ROOT = Path(__file__).resolve().parent.parent.parent.parent sys.path.insert(0, str(REPO_ROOT / "shared")) from eval_framework import mainTechnical Analysis
The evaluation runner computes a directory outside the audited project, prepends its
sharedsubdirectory tosys.path, and importseval_frameworkfrom that search path. Python executes a module's top-level code when importing it.The imported dependency is not included in the audited project and is not constrained by a package version, trusted installation location, lockfile, signature, or cryptographic integrity check. Prepending the directory gives it priority over later module search locations. Consequently, a malicious or compromised
eval_framework.pyor equivalent importable package in the computedshareddirectory would execute automatically when the evaluation runner starts.Exploitation requires an attacker to control or modify the external
shareddirectory or its deployment contents. The audit did not establish that this directory is attacker-writable, so this prerequisite is environment-dependent.Attack Path
- The attacker gains write access to the
shareddirectory derived four parent levels aboveevals/run_evals.py. - The attacker creates or replaces
eval_framework.py, or an equivalent importableeval_frameworkpackage, with malicious top-level Python code. - A user or automated service executes
python evals/run_evals.py. - The script inserts the attacker-controlled directory at index zero of
sys.path. - Python resolves
from eval_framework import mainto the attacker's module. - The malicious top-level code executes with the privileges and environment of the evaluation process before `main() ...[truncated 586 chars]
- The attacker gains write access to the
- Remediation
View remediation
Remediation Suggestions
- Package
eval_frameworkas a normal, trusted dependency and pin its exact version and hashes in a lockfile or requirements file. - Prefer an audited dependency installed into an isolated virtual environment rather than modifying
sys.pathat runtime. - If the framework is project-specific, vendor its reviewed source within the repository and import it through an explicit package structure.
- If loading from an external directory is unavoidable:
- Resolve and validate the canonical module path before execution.
- Restrict the source directory to a trusted, administrator-controlled location.
- Verify the module against a cryptographic digest or signature.
- Reject symlinks and unexpected package layouts where applicable.
- Run the evaluator in a least-privileged sandbox with no unnecessary credentials, restricted filesystem access, and limited network access.
- Add CI checks that fail when imports resolve outside approved dependency roots.
- Package
