T09 · Insecure Skill Coding Practices
- Location
skill.ts:55- Finding
Unrestricted Local File Upload Enables Sensitive File Disclosure
- Content
View full analysis
Vulnerability Details
File Location:
skill.ts, lines 55–76
Vulnerability Type: Arbitrary local file read and network upload
Risk Level: Hightypescript export const uploadMedia: Tool = { name: "upload_media", description: "Upload a media file (image, video, or audio) to Molttwit", parameters: { file_path: { type: "string", description: "Path to the media file", required: true }, description: { type: "string", description: "Alt text / description for accessibility" }, focus: { type: "string", description: "Focal point for thumbnails (e.g., 0,0, -0.5,0.5)" } }, execute: async ({ file_path, description, focus }) => { const fs = await import('fs'); const FormData = await import('form-data'); const formData = new FormData(); formData.append('file', fs.createReadStream(file_path)); if (description) formData.append('description', description); if (focus) formData.append('focus', focus); const response = await fetch(`${BASE_URL}/media`, { method: "POST", headers: { "Authorization": `Bearer ${TOKEN}` // FormData sets Content-Type automatically with boundary }, body: formData }); return await response.json(); } };Technical Analysis
The
upload_mediatool accepts an unrestricted, caller-controlledfile_pathand passes it directly tofs.createReadStream. The implementation does not canonicalize the path, restrict access to an approved media directory, verify that the target is a regular media file, reject symbolic links, enforce file-size limits, or obtain confirmation for the resolved path.Consequently, the tool can read any file accessible to the Skill process and send its contents to the fixed Molttwit media endpoint at
https://molttwit.com/api/v1/media. Although network transmission is expected for legitimate media uploads, unrestricted access to the local filesys ...[truncated 1439 chars]- Remediation
View remediation
Remediation Suggestions
- Require files to originate from an explicit user-selected attachment mechanism rather than accepting arbitrary path strings.
- Resolve the supplied path with
realpathand verify that the canonical result remains within a dedicated, allowlisted media directory. - Reject absolute paths, traversal sequences, symbolic links, device files, named pipes, sockets, directories, and other non-regular files.
- Open files using protections against symbolic-link races where supported, and validate the opened file descriptor rather than relying only on pre-open path checks.
- Verify allowed media types using file signatures rather than filename extensions alone.
- Enforce conservative file-size limits before initiating network transmission.
- Display the canonical path, detected media type, size, destination, and intended visibility to the user and require explicit confirmation before upload.
- Run the Skill under a sandboxed account with access only to approved media files, preventing it from reading credential stores and unrelated user data.
- Handle upload and validation failures safely without returning secrets or sensitive filesystem details in error messages.
