T09 · Insecure Skill Coding Practices
- Location
scripts/send-image.sh:34- Finding
Unrestricted Local File Selection May Expose Sensitive Files to Feishu
- Content
View full analysis
Vulnerability Details
File Location:
scripts/send-image.sh, lines 34-38 and 97-100
Vulnerability Type: Unrestricted external upload of caller-selected local files
Risk Level: MediumVulnerable Code
bash IMAGE_PATH="$1" RECEIVER_ID="$2" ACCOUNT_ID="${3:-prompt}" # 检查图片文件是否存在 if [ ! -f "$IMAGE_PATH" ]; then echo "错误: 图片文件不存在: $IMAGE_PATH" exit 1 fibash UPLOAD_RESPONSE=$(curl -s -X POST "${FEISHU_API_BASE}/im/v1/images" \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -F "image_type=message" \ -F "image=@$IMAGE_PATH")Technical Analysis
The script accepts an arbitrary path from its first command-line argument and only verifies that the path resolves to a regular file. It does not:
- Restrict the file to an approved workspace or generated-output directory.
- Resolve and validate the canonical path.
- Reject symbolic links that resolve outside an approved directory.
- Verify the file's content-based MIME type.
- Apply an explicit image-format allowlist.
- Enforce a file-size limit.
- Require confirmation before transmitting the file externally.
The selected file is then submitted to Feishu using curl's
@fileupload syntax. The Feishu endpoint may independently reject unsupported content, but the local script itself provides no protection against selecting sensitive files that are valid images or otherwise accepted by the remote endpoint.This is especially relevant when an AI agent derives script arguments from untrusted conversation content. A malicious or misleading request could cause the agent to select a private image or another accepted file outside the intended workspace.
Attack Path
- An attacker provides an instruction that identifies a sensitive local file path, or points to a symbolic link resolving to such a file.
- The agent invokes
send-image.shwith that path and a Feishu recipient ID controlled by the attacke ...[truncated 1013 chars]
- Remediation
View remediation
Remediation Suggestions
- Resolve the requested path to its canonical form before use, for example with
realpath. - Require the canonical path to remain under an explicitly approved image-output directory.
- Reject symbolic links, or validate the resolved target against the approved directory.
- Determine the MIME type from file contents using a trusted utility such as
file --mime-type, rather than relying on the extension. - Allow only explicitly supported image MIME types such as
image/jpeg,image/png,image/webp, andimage/gif. - Enforce an appropriate maximum file size before upload.
- Require explicit user confirmation that displays the canonical source path and destination recipient when the path is not a newly generated agent output.
- Consider applying a policy layer that prevents agent-controlled requests from accessing files outside the current workspace.
- Resolve the requested path to its canonical form before use, for example with
