T08 · Insecure Dependencies
- Location
commands/generate-tearsheet.md:54- Finding
Untrusted External Module Import Through Hardcoded Search Path
- Content
View full analysis
Vulnerability Details
File Location:
commands/generate-tearsheet.md, lines 54-58
Vulnerability Type: Insecure dependency resolution and arbitrary local code execution
Risk Level: MediumComplete Code Snippet:
python import sys import pandas as pd sys.path.insert(0, '/Users/DanBot/Desktop/dev/Backtests') from backtesting.tearsheets.strategy_comparison_tearsheet import StrategyComparisonTearsheetThe dependency is also explicitly documented in
SKILL.md, lines 101-110:text ## Dependencies - Python 3.10+ - pandas, numpy, matplotlib - StrategyComparisonTearsheet from backtesting.tearsheets ## Installation The skill uses the tearsheet generator at: `/Users/DanBot/Desktop/dev/Backtests/backtesting/tearsheets/strategy_comparison_tearsheet.py` Ensure this path is accessible or update the script paths accordingly.Technical Analysis
The implementation prepends a user-specific external directory to
sys.pathand then imports executable Python code from that directory. Because the inserted path has the highest module-resolution priority, Python will loadbacktesting.tearsheets.strategy_comparison_tearsheetfrom that location before normally installed packages.Python executes module-level statements during import. Therefore, the imported module does not need to wait for
StrategyComparisonTearsheetto be instantiated: arbitrary statements placed at module scope execute immediately. The external component is not bundled with this project, version-pinned, integrity-checked, or otherwise authenticated, so its effective behavior cannot be established through an audit of this repository alone.This is an unsafe local dependency and supply-chain trust boundary. Exploitation requires an attacker to control or modify the referenced directory, or to induce the user to place an untrusted project there.
Attack Path
- An attacker obtains write access to `/Users/DanBot/ ...[truncated 1350 chars]
- Remediation
View remediation
Remediation Suggestions
- Bundle the required tearsheet generator in the Skill package so that the reviewed code is the code executed at runtime.
- Alternatively, publish it as a trusted package and pin an exact version and cryptographic hashes in a lock file or requirements file.
- Remove the
sys.path.insert(0, ...)modification and use standard package imports from an isolated virtual environment. - Do not rely on a user-specific absolute path. Resolve packaged resources relative to the installed Skill only.
- If loading a configurable local component is unavoidable:
- Require an explicit trusted path rather than silently assigning highest import priority.
- Resolve and validate the canonical path.
- Reject directories writable by untrusted users.
- Verify file ownership and permissions.
- Verify the component against a pinned cryptographic digest or trusted signature before importing it.
- Load it in a restricted subprocess with minimal filesystem, network, environment, and credential access.
- Document the exact dependency source, supported version, expected digest, and update procedure.
- Add automated tests that fail if module resolution escapes the packaged or locked dependency environment.
