T07 · Tool Hijacking and Spoofing
- Location
scripts/content_calendar.py:129- Finding
Untrusted Dynamic Module Execution from Predictable User-Writable Paths
- Content
View full analysis
Vulnerability Details
File Location:
scripts/content_calendar.py:129-151
Vulnerability Type: Arbitrary local Python module loading without origin or integrity validation
Risk Level: MediumVulnerable Code
python if library_path: compound_path = None for candidate in [ Path.home() / ".claude" / "skills" / "phy-content-compound" / "scripts" / "content_compound.py", Path.home() / "Desktop" / "openclaw-skills-publish" / "phy-content-compound" / "scripts" / "content_compound.py", ]: if candidate.exists(): compound_path = str(candidate) break if compound_path: try: spec = importlib.util.spec_from_file_location("content_compound", compound_path) if spec and spec.loader: mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(mod) library = mod.scan_directory(library_path) for pillar in pillars: results = mod.retrieve_atoms(library, pillar, top_n=3) if results: atoms_by_topic[pillar] = [ f"[{a.atom_type}] {a.text[:80]}... ({a.source_file})" for a, _ in results ] except Exception: passTechnical Analysis
When the optional
--libraryargument is provided, the script searches two predictable locations under the user's home directory forcontent_compound.py. It then loads the first existing file withimportlib.util.spec_from_file_location()and executes its top-level code throughspec.loader.exec_module(mod).The loader does not verify the module's expected cryptographic hash, package identity, canonical path, owner, or filesystem permissions. Consequently, the existence check is treated as sufficient evidence that the discovered Pyt ...[truncated 1950 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove source-file discovery and direct execution from predictable home-directory paths.
- Move the required functionality into reviewed code shipped with this project, or consume a properly installed and version-pinned package through the normal Python import system.
- If optional integration must remain, require the user to provide an explicit module path rather than silently selecting the first existing candidate.
- Establish a trust policy before loading any explicit module:
- Resolve and validate the canonical path.
- Restrict loading to an approved directory.
- Verify expected file ownership and reject group-writable or world-writable files and parent directories.
- Verify the module against a pinned cryptographic digest or signed manifest.
- Prefer a data-only interoperability format such as JSON over importing executable Python. Run a separately trusted helper with a constrained interface if code-based integration is unavoidable.
- Replace the silent exception handler with clear error reporting and audit logging. Avoid suppressing module-loading failures because they may indicate tampering.
- Apply least-privilege execution and sandboxing so the calendar process cannot access unrelated user files, credentials, or network resources.
