T07 · Tool Hijacking and Spoofing
- Location
scripts/build-dataify-request.py:5- Finding
External Python Module Shadowing Enables Execution of Untrusted Sibling Code
- Content
View full analysis
Vulnerability Details
File Location:
scripts/build-dataify-request.py:5-9
Vulnerability Type: Python import-path hijacking and tool spoofing
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 entry point inserts an external sibling directory at index zero of
sys.pathbefore importingcatalog_builder. Python searches index zero before the directory containing the packaged implementation. If the sibling directory exists and contains a module namedcatalog_builder.py, that module takes precedence over the audited local file atscripts/catalog_builder.py.Importing a Python module executes its top-level code. Therefore, a malicious or compromised sibling module can execute code as soon as the documented Skill entry point starts. The imported module also controls
run_catalog_builder, allowing it to replace the entire task-submission workflow.This is particularly sensitive because the process inherits
DATAIFY_API_TOKEN. A substituted module could read that credential, modify task parameters, submit unauthorized paid requests, forge returned results, or perform arbitrary operations permitted to the user running the Skill.The external executable precedence is not documented in the declared Skill workflow, and the local audited
catalog_builder.pyis not guaranteed to be the implementation used at runtime.Attack Path
- An attacker gains the ability to create or modify the expected sibling directory
dataify-task-operations/scripts. - The attacker places a malicious
catalog_builder.pyin that directory. - A user invokes the documented
scripts/build-dataify-request.pyentry point with `DATAIFY_AP ...[truncated 1153 chars]
- An attacker gains the ability to create or modify the expected sibling directory
- Remediation
View remediation
Remediation Suggestions
- Remove the external
sys.pathmodification and import the packaged implementation directly. - Place shared functionality in a uniquely named, properly packaged Python module rather than importing a generic module name from a sibling directory.
- If an external dependency is unavoidable:
- Pin its exact version and integrity hash.
- Install it through a controlled dependency mechanism.
- Import it through an unambiguous package namespace.
- Verify the resolved module path before executing any imported functionality.
- Do not prepend writable or externally managed directories to
sys.path. - Add a regression test that checks
catalog_builder.__file__resolves inside the current Skill package. - Run the Skill with a restricted environment and avoid exposing credentials to modules that do not require them.
- Remove the external
