T08 · Insecure Dependencies
- Location
evals/run_evals.py:7- Finding
Untrusted External Python Module Loading via Import Path Manipulation
- Content
View full analysis
Vulnerability Details
File Location:
evals/run_evals.py, lines 7–10
Vulnerability Type: Insecure dependency loading and local module substitution
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 derives a dependency directory by traversing four parent directories from its own location, prepends the resulting
shareddirectory tosys.path, and then importseval_frameworkwithout validating the module's origin or integrity.In the audited deployment layout, this resolves to
/tmp/shared, which is outside the audited project directory. Becausesys.path.insert(0, ...)gives that directory precedence over other import locations, a substitutedeval_framework.pyoreval_frameworkpackage in that directory is imported first. Python executes module-level code immediately during import, beforemain()is called.This creates a dependency-substitution risk at a local, ancestor-derived path. Exploitation requires an attacker or compromised process to have write access to the resolved external directory. The audit did not establish the directory's actual permissions or confirm that a malicious module exists, so the finding represents an exploitable unsafe loading mechanism rather than evidence of an active payload.
Attack Path
- An attacker determines that the evaluation runner imports
eval_frameworkfrom the ancestor-derivedshareddirectory. - The attacker obtains write access to that directory, directly or through another compromised process.
- The attacker creates or replaces
/tmp/shared/eval_framework.py, or an equivalent package, with malicious module-level code and a compatiblemainsymbol. - A user launches
python evals/run_evals.py. - The runner places
/tmp/sharedat the beginning of ...[truncated 902 chars]
- An attacker determines that the evaluation runner imports
- Remediation
View remediation
Remediation Suggestions
- Remove the ancestor-derived
sys.pathmodification and packageeval_frameworkas a normal trusted dependency. - Pin the dependency to an approved version and verify its integrity using lock files and cryptographic hashes.
- If the framework belongs to the same repository, place it inside a trusted package tree and use an explicit package import.
- If external loading is unavoidable:
- Obtain the dependency root from a trusted, validated configuration.
- Resolve the path canonically.
- Verify that it is inside an approved directory.
- Reject writable shared or temporary directories.
- Verify the dependency against an expected cryptographic digest before loading it.
- Run evaluation tooling under a least-privileged account in a sandbox with restricted filesystem and network access.
- Add a startup assertion that logs and validates
eval_framework.__file__against the expected trusted location. - Add a security regression test ensuring that an unexpected module in an ancestor or temporary directory cannot shadow the approved framework.
- Remove the ancestor-derived
