T07 · Tool Hijacking and Spoofing
- Location
scripts/build-dataify-request.py:5- Finding
External Module Shadowing Can Execute Unreviewed Code
- Content
View full analysis
Vulnerability Details
File Location:
scripts/build-dataify-request.py:5-9
Vulnerability Type: Python module search-path hijacking
Risk Level: HighVulnerable Code
python TASK_RUNTIME_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "dataify-task-operations", "scripts")) if TASK_RUNTIME_DIR not in sys.path: sys.path.insert(0, TASK_RUNTIME_DIR) from catalog_builder import build_curl, run_catalog_builderTechnical Analysis
The launcher inserts an external sibling directory at the beginning of
sys.pathbefore importingcatalog_builder. Because index zero has the highest import priority, acatalog_builder.pyplaced in that external directory supersedes the reviewed implementation bundled in this project.Python executes module-level code during import. Consequently, an attacker who can create or modify the external module can execute arbitrary code as soon as the documented launcher is run. The substituted module also receives access to the current process environment, which may contain
DATAIFY_API_TOKEN.This is a local tool-hijacking condition rather than remote payload retrieval: the effective implementation can be replaced outside the audited project without modifying the launcher itself.
Attack Path
- An attacker gains write access to the expected sibling path
dataify-task-operations/scripts. - The attacker creates or replaces
catalog_builder.pywith malicious module-level code. - A user runs the documented
scripts/build-dataify-request.pyhelper. - The launcher prepends the attacker-controlled directory to
sys.path. - Python imports and executes the substituted module.
- The malicious module can read environment variables, access files available to the process, make network requests, or spoof task results.
Impact Assessment
Successful exploitation provides arbitrary code execution with the same operating-system priv ...[truncated 292 chars]
- An attacker gains write access to the expected sibling path
- Remediation
View remediation
Remediation Suggestions
- Remove the external
sys.pathmodification and import the bundled implementation through an explicit package-relative import. - Avoid ambiguous top-level module names that can be shadowed by adjacent directories.
- If an external runtime is genuinely required, resolve a fixed trusted path and verify its version and cryptographic digest before loading it.
- Package the shared runtime as a pinned dependency rather than dynamically preferring an uncontrolled local directory.
- Run task submission with a narrowly scoped API token and an execution account with minimal filesystem permissions.
- Add a regression test proving that a sibling
catalog_builder.pycannot replace the bundled implementation.
- Remove the external
