T07 · Tool Hijacking and Spoofing
Error
- Location
- scripts/send_npc_scene_to_feishu.py:35
- Finding
- Unverified Helper Modules Are Discovered and Executed from Ancestor Directories<![CDATA[ ## Vulnerability Details **File Location**: `scripts/send_npc_scene_to_feishu.py:35-52`; equivalent ancestor-directory imports occur in `scripts/senseaudio_asr.py:14-27`, `scripts/batch_tts_scene.py:11-24`, and `scripts/run_player_voice_npc_pipeline.py:8-21` **Vulnerability Type**: Untrusted local module discovery and execution **Risk Level**: High ### Vulnerable Code ```python def load_helper_module(skill_name: str, script_name: str, alias: str) -> Any: current = Path(__file__).resolve() for parent in current.parents: candidate = parent / skill_name / "scripts" / script_name if candidate.exists(): spec = importlib.util.spec_from_file_location(alias, candidate) if spec and spec.loader: module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) return module raise SystemExit(f"could not locate {skill_name}/scripts/{script_name}") feishu_sender = load_helper_module("audioclaw-skills-voice-reply", "feishu_audio_sender.py", "npc_feishu_sender") ``` The other affected scripts use the following equivalent pattern: ```python def _bootstrap_shared_senseaudio_env() -> None: current = Path(__file__).resolve() for parent in current.parents: candidate = parent / "_shared" / "senseaudio_env.py" if candidate.exists(): candidate_dir = str(candidate.parent) if candidate_dir not in sys.path: sys.path.insert(0, candidate_dir) from senseaudio_env import ensure_senseaudio_env ensure_senseaudio_env() return _bootstrap_shared_senseaudio_env() ``` ### Technical Analysis The Skill searches every ancestor directory for helper files and executes the first matching module without verifying its canonical location, ownership, permissions, package identity, signature, or cryptographic digest. The referenced helpers are not included in the audited project ...[truncated 2527 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Package all required helper modules inside the reviewed Skill or a pinned, trusted Python package. 2. Replace ancestor traversal with a single canonical import path under a trusted installation root. 3. Resolve the helper path with `Path.resolve()` and verify that it remains inside the expected trusted directory. 4. Reject helper files or parent directories writable by untrusted users. 5. Verify helper modules against a pinned SHA-256 digest or signed package manifest before loading them. 6. Avoid inserting dynamically discovered directories at the front of `sys.path`. 7. Pin dependency versions and verify package hashes during installation. 8. Fail closed when the expected helper is absent rather than searching increasingly broad filesystem locations. 9. Document and audit the exact helper package because it processes credentials and external messaging operations. 10. Run the Skill under a dedicated, minimally privileged account with access only to the required workspace and credentials. ]]>
