T09 · Insecure Skill Coding Practices
- Location
scripts/generate.py:148- Finding
Unrestricted Product and Image URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
bool: """Try to find and download the main product image from a product page.""" try: from bs4 import BeautifulSoup except ImportError: print(" ⚠ beautifulsoup4 not available for product image extraction", flush=True) return False print(" Fetching product page for main image...", flush=True) try: headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", "Accept": "text/html,*/*", } response = client.get(product_url, headers=headers, follow_redirects=True, timeout=20.0) if response.status_code != 200: print(f" ✗ Could not fetch product page ({response.status_code})", flush=True) return False soup = BeautifulSoup(response.text, "html.parser") # Strategy 1: og:image meta tag (most reliable) og_img = soup.find("meta", property="og:image") if og_img and og_img.get("content"): img_url = urljoin(product_url, og_img["content"]) print(f" Found og:image: {img_url[:80]}...", flush=True) if download_to_file(client, img_url, dest): return True # Strategy 2: Large images in the page images = soup.find_all("img") candidates = [] for img in images: src = img.get("src") or img.get("data-src") or img.get("data-lazy-src") if not src: continue src = urljoin(product_url, src) # Skip tiny images, icons, tracking pixels width = img.get("width", "0") height = img.get("height", "0") try: w = in ...[truncated 3826 chars]- Remediation
View remediation
