T09 · Insecure Skill Coding Practices
- Location
SKILL.md:60- Finding
Shell Command Injection Through Unvalidated MediaGo Configuration and Download Parameters
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 60–109
Vulnerability Type: Shell command injection through unsafe interpolation of user-controlled values
Risk Level: HighThe Skill instructs the Agent to store user-provided configuration and subsequently interpolate configuration values, video URLs, and filenames into shell-based
curlcommands.markdown When the user provides the URL (and optionally an API key), write it to `~/.mediago-skill.json`. ### Updating Config / 更新配置 Trigger on phrases like: - EN: "set mediago url to ...", "mediago api key is ...", "my mediago is at ..." - CN: "设置 mediago 地址为 ...", "mediago api key 是 ...", "我的 mediago 跑在 ..." Read the existing config, update the relevant field, and write it back. ## API Reference All API calls use `curl`. Read `url` and `apiKey` from `~/.mediago-skill.json` before each call. If `apiKey` is set, add header: `-H "X-API-Key: API_KEY"` ### Health Checkcurl -s BASE_URL/healthy
text Returns `{"success":true,...}` if service is running. ### Create & Start Downloadcurl -s -X POST BASE_URL/api/downloads
-H "Content-Type: application/json"
-d '{"tasks":[{"type":"TYPE","url":"VIDEO_URL","name":"NAME"}],"startDownload":true}'text - `type` (required): `m3u8`, `bilibili`, or `direct` - `url` (required): video URL - `name` (optional): custom filename **Type detection from URL:** - Contains `bilibili.com` or `b23.tv` → `bilibili` - Contains `.m3u8` → `m3u8` - Otherwise → `direct` Response `data` is an array of created tasks. Extract `data[0].id` as the task ID. ### Get Task Statuscurl -s BASE_URL/api/downloads/TASK_ID
text Technical Analysis
BASE_URLandAPI_KEYare taken from a configuration file populated using user-provided values.VIDEO_URLandNAMEare also directly or indirectly controlled by the user. The documented command templates do not requi ...[truncated 2636 chars]- Remediation
View remediation
Remediation Suggestions
- Avoid shell command construction. Use a dedicated HTTP client or invoke
curlwith an argument array through an API that does not launch a shell. - Validate the MediaGo base URL. Parse it as a URL, permit only explicitly supported schemes such as
httpandhttps, reject user-information fields and shell metacharacters, and optionally restrict hosts to localhost or an explicit allowlist. - Serialize request bodies safely. Build JSON with a proper serializer rather than interpolating
VIDEO_URL,NAME, orTYPEinto a quoted JSON string. - Treat API keys as opaque arguments. Pass the complete header as one argument without shell evaluation. Never concatenate it into executable command text.
- Validate task identifiers and types. Restrict
TYPEtom3u8,bilibili, ordirect, and require task IDs to match the format returned by the trusted API before placing them into endpoint paths. - Protect stored credentials. Create
~/.mediago-skill.jsonwith permissions limited to the owning user, such as mode0600, or use an operating-system credential store. - Document safe execution requirements. Explicitly prohibit
shell=true,eval, command-string execution, and equivalent mechanisms for all dynamic HTTP requests. - Add adversarial tests. Test configuration values, URLs, and filenames containing quotes, semicolons, command substitutions, newlines, redirects, and backticks to verify they remain inert data.
- Avoid shell command construction. Use a dedicated HTTP client or invoke
