T07 · Tool Hijacking and Spoofing
- Location
skill.py:14- Finding
Arbitrary Code Execution Through a User-Writable Python Import Path
- Content
View full analysis
Vulnerability Details
File Location:
skill.py, lines 14-17
Vulnerability Type: Untrusted module loading and local tool spoofing
Risk Level: HighVulnerable Code
python # 添加工作目录到路径 sys.path.insert(0, str(Path.home() / ".openclaw" / "workspace")) # 导入共享记忆加载器 from shared_memory_loader import get_latest_holdingsTechnical Analysis
The Skill prepends
~/.openclaw/workspaceto Python's module search path and then importsshared_memory_loaderfrom that location. The loader is not bundled with the reviewed project, and the code performs no validation of the resolved module's canonical path, ownership, permissions, or integrity.Python executes module-level statements while importing a module. Consequently, a malicious or compromised
shared_memory_loader.pyin the workspace can execute arbitrary Python code before the Skill performs its intended portfolio analysis.This is a local module-preloading vulnerability. It does not independently provide privilege escalation: the injected code runs with the same operating-system privileges, credentials, filesystem access, and network access as the user or Agent process invoking the Skill.
Attack Path
- An attacker obtains the ability to create or replace files in
~/.openclaw/workspace. - The attacker places a malicious file named
shared_memory_loader.pyin that directory. - A user or Agent invokes the
stock-decisionSkill. - The Skill inserts the workspace at index zero of
sys.path. - Python resolves
shared_memory_loaderfrom the attacker-controlled workspace. - Python executes the malicious module's top-level code during import.
- The attacker-controlled code operates with the invoking process's privileges.
Impact Assessment
Successful exploitation enables arbitrary code execution in the context of the Skill process. Depending on that process's existing permissions, attacker code could read or modify accessib ...[truncated 380 chars]
- An attacker obtains the ability to create or replace files in
- Remediation
View remediation
Remediation Suggestions
- Bundle
shared_memory_loaderinside the reviewed package and import it through a package-relative import. - Do not add a user-writable workspace directory to the beginning of
sys.path. - If external loading is unavoidable, resolve a fixed canonical file path and verify that the path remains within the expected directory.
- Validate file ownership and permissions before loading external code.
- Verify the loader against a trusted cryptographic digest or signed manifest.
- Prefer parsing
SHARED_MEMORY.mdas data rather than importing executable Python code from the workspace. - Run the Skill with least privilege and restrict write access to directories containing executable modules.
- Bundle
