T09 · Insecure Skill Coding Practices
- Location
scripts/script.sh:34- Finding
Arbitrary Local File Disclosure Due to Missing Image Validation
- Content
View full analysis
&2 exit 1 fi _check_key IMAGE_PATH="$image_path" STYLE="$style" LANG="$lang" \ API_KEY="${XAI_API_KEY}" API_URL="$API_URL" \ python3 -u - << 'PYEOF' import urllib.request, json, sys, os, base64 API_KEY = os.environ["API_KEY"] API_URL = os.environ["API_URL"] image_path = os.environ["IMAGE_PATH"] style = os.environ["STYLE"] lang = os.environ["LANG"] ext = os.path.splitext(image_path)[1].lower() mime_map = {".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".png": "image/png", ".webp": "image/webp"} mime = mime_map.get(ext, "image/jpeg") with open(image_path, "rb") as f: b64 = base64.b64encode(f.read()).decode() data_url = f"data:{mime};base64,{b64}" STYLE_INSTRUCTIONS = { "professional": "Write a formal, professional product description suitable for B2B buyers.", "casual": "Write a friendly, casual product description as if recommending to a friend.", "luxury": "Write a premium, aspirational product description for luxury shoppers.", "seo": "Write an SEO-optimized product description with keywords and bullet points.", } instruction = STYLE_INSTRUCTIONS.get(style, STYLE_INSTRUCTIONS["professional"]) lang_note = {"zh": " Write in Chinese.", "es": " Write in Spanish."}.get(lang, "") prompt = f"""{instruction}{lang_note} Analyze this product image and include: 1. What the product is 2. Key visible features and benefits 3. Who it is ideal for 4. A compelling call to action""" payload = json.dumps({ "model": "grok-2-vision-latest", "messages": [{ "role": "user", "content": [ {"type": "image_url", "image_url": {"url": data_url}}, {"type ...[truncated 2991 chars]- Remediation
View remediation
