T09 · Insecure Skill Coding Practices
- Location
SKILL.md:36- Finding
Unrestricted Local File Ingestion Through User-Controlled Path
- Content
View full analysis
str: data = pathlib.Path(path).read_bytes() return base64.b64encode(data).decode("utf-8") def run_moondream(image_path: str, prompt: str = ""): img_b64 = encode_image(image_path) payload = { "model": "moondream", "prompt": prompt, "images": [img_b64], "stream": False, } resp = requests.post(OLLAMA_URL, json=payload) ``` ### Technical Analysis The command treats a user-controlled path as an image and reads the entire referenced file without validating its type, canonical location, size, or symlink status. It therefore permits access to any file readable by the operating-system identity running the Skill. Base64 encoding provides no confidentiality protection. The resulting content is submitted to the fixed loopback Ollama endpoint at `http://127.0.0.1:11434/api/generate`. This transmission is consistent with the declared local image-analysis functionality, and the reviewed code does not send data to an external host. Nevertheless, unrestricted path handling exceeds the minimum access needed to analyze ordinary image files. The documented approximate 5 MB image limit is not enforced before `read_bytes()`, meaning a very large file could also cause excessive memory consumption. ### Attack Path 1. An attacker or untrusted user obtains the ability to provide the `image_path` command argument. 2. The attacker supplies a path to a sensitive file, symlink, device-like file, or excessively large file instead of a legitimate image. 3. `pathlib.Path(path).read_bytes()` reads the complete resource using the Skill process's existing filesystem permissions. 4. The content is Base64-encoded and submitted to the local Ollama service. 5. Depending on the file format and model behavior, sen ...[truncated 625 chars]- Remediation
View remediation
