T07 · Tool Hijacking and Spoofing
- Location
scripts/chain_entry.py:11- Finding
External Dashboard Hook Permits Local Python Module Hijacking
- Content
View full analysis
Vulnerability Details
File Location:
scripts/chain_entry.py:11-16
Vulnerability Type: Untrusted external module loading
Risk Level: Highpython # === PharmaLab Dashboard Hook === sys.path.insert(0, os.path.join(script_dir, '..', '..', 'pharmaclaw-lab-ui', 'scripts')) try: from lab_hook import lab_update except ImportError: def lab_update(*a, **kw): passTechnical Analysis
The script prepends a directory outside the audited project to Python's module search path and then imports
lab_hookfrom that location. Python executes all module-level code when a module is imported.The imported module is not included in the audited project, is not declared as a trusted dependency, and is not verified before execution. Consequently, an attacker who can create or modify
pharmaclaw-lab-ui/scripts/lab_hook.pycan cause arbitrary Python code to run wheneverchain_entry.pystarts.The use of
sys.path.insert(0, ...)gives this external directory priority over normal module locations, increasing the risk of module spoofing. CatchingImportErrordoes not mitigate the issue because malicious module-level code executes before the import completes.Attack Path
- An attacker gains the ability to create or modify the sibling path
pharmaclaw-lab-ui/scripts. - The attacker places a malicious file named
lab_hook.pyin that directory. - A user or Agent invokes
scripts/chain_entry.pyfor a normal chemistry operation. - The script places the attacker-controlled directory at the beginning of
sys.path. - Python imports the malicious
lab_hookand executes its module-level code. - The payload runs with the same operating-system privileges, filesystem access, environment variables, and network access as the Agent process.
Impact Assessment
Successful exploitation provides arbitrary code execution under the account running the Skill. The attacker could read or modify files a ...[truncated 466 chars]
- An attacker gains the ability to create or modify the sibling path
- Remediation
View remediation
Remediation Suggestions
- Remove the dynamic
sys.pathmodification and external dashboard hook if it is not essential to chemistry processing. - If the integration is required, distribute it as an explicit, reviewed, and version-pinned package rather than importing from a relative sibling directory.
- Import the dependency through the normal Python package mechanism without placing writable directories at the beginning of
sys.path. - Verify the origin and integrity of any optional plugin before loading it.
- Disable the integration by default and require an explicit trusted configuration setting to enable it.
- Run the Skill under a dedicated least-privileged account and ensure project-adjacent directories are not writable by untrusted users.
- Document the external hook and its security boundary in
SKILL.md.
- Remove the dynamic
