T07 · Tool Hijacking and Spoofing
- Location
scripts/search.py:5- Finding
Execution of an Unverified External Script from a Predictable Temporary Path
- Content
View full analysis
Vulnerability Details
File Location:
scripts/search.py, lines 5-14
Vulnerability Type: Untrusted local script execution and tool hijacking
Risk Level: HighVulnerable Code
python CANONICAL_SCRIPT = ( Path(__file__).resolve().parents[3] / "custom-skills" / "realtime-web-search" / "scripts" / "search.py" ) if __name__ == "__main__": runpy.run_path(str(CANONICAL_SCRIPT), run_name="__main__")Technical Analysis
The Skill does not contain its canonical search implementation. Instead, it constructs a path outside the audited package and executes the referenced Python file using
runpy.run_path.Given the supplied project location,
Path(__file__).resolve().parents[3]resolves to/tmp, making the effective target:text /tmp/custom-skills/realtime-web-search/scripts/search.pyThis is a predictable location outside the Skill's trusted package boundary. The code performs no validation of the target's ownership, permissions, trusted root, file type, or cryptographic integrity before executing it. If another local user or process can create or replace the target file, the legitimate-looking Skill invocation will execute attacker-controlled Python code with the same privileges and environment as the invoking process.
The external implementation was not included in the audit artifact. Consequently, its network behavior, endpoint validation, request handling, and use of
BAIDU_API_KEYcannot be independently verified.Attack Path
- An attacker gains the ability to create or replace files under the expected
/tmp/custom-skills/realtime-web-search/scripts/path. - The attacker places a malicious Python payload at
/tmp/custom-skills/realtime-web-search/scripts/search.py. - A user or agent invokes
scripts/search.pyaccording to the documented workflow. - The wrapper resolves the predictable external path without verifying its trustwor ...[truncated 990 chars]
- An attacker gains the ability to create or replace files under the expected
- Remediation
View remediation
Remediation Suggestions
- Bundle the canonical search implementation within the audited Skill package and execute or import it using a path located under the package's validated root.
- Alternatively, distribute the canonical implementation as a version-pinned, trusted Python package and import it through normal package resolution rather than executing an arbitrary filesystem path.
- Do not load executable code from
/tmpor another shared, attacker-writable location. - If an external script is operationally required:
- Resolve it from an explicitly configured trusted installation directory.
- Confirm that the resolved path remains inside that trusted directory.
- Reject symbolic links and unexpected file types.
- Validate file ownership and ensure the file and every parent directory are not writable by untrusted users.
- Verify the file against a pinned cryptographic digest or authenticated signature before execution.
- Fail closed with a clear error if the trusted implementation is absent or fails validation; do not search fallback locations.
- Include the complete canonical implementation in future audit artifacts so its handling of credentials, endpoint overrides, network traffic, and untrusted search content can be reviewed.
