T07 · Tool Hijacking and Spoofing
- Location
scripts/translate.py:3- Finding
Untrusted External Python Module Loading Through Search Path Manipulation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/translate.py, lines 3–6
Vulnerability Type: Untrusted module loading and local tool hijacking
Risk Level: Highpython import sys, os sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "integration")) from translate_srt import main if __name__ == "__main__": main()Technical Analysis
The script prepends an external directory to Python's module search path before importing
translate_srt. Based on the audited project location, the constructed path resolves outside the project to/tmp/integration.Because this external directory is placed at index zero of
sys.path, a file namedtranslate_srt.pylocated there takes precedence over modules from other locations. Python executes top-level module code immediately during the import, beforemain()is called.The
translate_srtimplementation is not included in the audited project. Consequently, its integrity and behavior cannot be verified, and the executable behavior of the Skill is not constrained to the text-only subtitle processing documented inSKILL.md. If an attacker can create or replace/tmp/integration/translate_srt.py, the import becomes an arbitrary-code execution primitive.Attack Path
- An attacker gains write access to
/tmp/integration, or creates that directory if it does not exist. - The attacker places a malicious file at
/tmp/integration/translate_srt.py. - A user or Agent invokes
scripts/translate.py. - The script prepends
/tmp/integrationtosys.path. - Python imports the attacker-controlled module in preference to any trusted implementation.
- Malicious top-level code executes immediately during import.
- If execution continues, the attacker-controlled
main()function is invoked as well.
Impact Assessment
Successful exploitation permits arbitrary Python code execution with the same operating-system iden ...[truncated 740 chars]
- An attacker gains write access to
- Remediation
View remediation
Remediation Suggestions
-
Move
translate_srt.pyinto the Skill package and import it through a package-relative, auditable path. -
Remove the
sys.path.insert()call and avoid loading executable modules from parent directories, temporary locations, or other externally writable paths. -
Package the implementation explicitly, for example:
python from .translate_srt import mainAlternatively, use a properly installed, pinned package imported through its canonical package name.
-
If an external integration is operationally unavoidable, resolve it from a trusted configuration rather than a relative traversal path. Validate that the directory and file are owned by an expected trusted identity and are not writable by untrusted users.
-
Verify the external module against a pinned cryptographic digest or signed manifest before loading it, and fail closed if verification fails.
-
Avoid placing the external directory at the front of the global module search path. Load only the explicitly validated file and prevent unintended transitive imports from the same directory.
-
Run the translation process with least privilege and restrict filesystem, credential, subprocess, and network access to reduce impact if module integrity is compromised.
-
Include the complete executable implementation and its dependencies in future audits so the documented translation behavior can be compared with the code actually executed.
-
