T07 · Tool Hijacking and Spoofing
- Location
scripts/video_reader.py:8- Finding
External Python Module Import Enables Local Tool Hijacking
- Content
View full analysis
Vulnerability Details
File Location:
scripts/video_reader.py:8-13
Vulnerability Type: Untrusted external module loading through Python path manipulation
Risk Level: HighVulnerable Code
python # MCP project location # scripts/video_reader.py → parents[4] = /home/ykl/.openclaw/ SKILL_ROOT = Path(__file__).resolve().parents[4] # /home/ykl/.openclaw/ MCP_PATH = SKILL_ROOT / "workspace-code-dev" / "video-reader" sys.path.insert(0, str(MCP_PATH / "src")) # add video-reader/src so video_reader_mcp can be found from video_reader_mcp import VideoReaderMCPThe same insecure pattern also appears in
scripts/analyze_text.py:7-11:python # MCP project location SKILL_ROOT = Path(__file__).resolve().parents[4] # /home/ykl/.openclaw/ MCP_PATH = SKILL_ROOT / "workspace-code-dev" / "video-reader" sys.path.insert(0, str(MCP_PATH / "src")) from video_reader_mcp import VideoReaderMCPTechnical Analysis
Both CLI entry points prepend a hardcoded external workspace directory to
sys.pathand then importvideo_reader_mcpfrom it. Because index zero has import precedence, Python will execute a matching module or package found in that external directory before considering normally installed packages.The imported implementation is not bundled with the audited project and has no version pin, integrity check, ownership validation, or permission validation. Therefore, the effective executable behavior of both scripts can be replaced by anyone who can create or modify the expected external module.
The use of
Path(__file__).resolve().parents[4]is also installation-layout dependent. Moving the Skill or running it from a different hierarchy can cause the calculated trust root to point somewhere unintended. The audit could not verify the external implementation's handling of videos, transcripts, temporary files, API credentials, or network requests because that source code is absent from the artifact.Attack Path
- An attacker ob ...[truncated 1524 chars]
- Remediation
View remediation
Remediation Suggestions
- Bundle
video_reader_mcpwithin the Skill so that the reviewed package contains all executable code. - Remove the hardcoded
parents[4]path calculation andsys.path.insert(0, ...)manipulation. - Import the implementation through a normal package dependency with an exact version and cryptographic hash pin.
- If an external checkout is operationally unavoidable:
- Require its path through explicit trusted configuration rather than deriving it from the Skill's location.
- Resolve and validate the canonical path.
- Reject directories writable by untrusted users.
- Validate expected ownership and restrictive permissions.
- Pin the external source to a reviewed commit.
- Verify file or package hashes before loading it.
- Execute media processing with least privilege and provide only the credentials required for the selected operation.
- Apply the same correction to
scripts/analyze_text.py:7-11, which contains the identical vulnerable import design.
- Bundle
