T09 · Insecure Skill Coding Practices
- Location
scripts/batch_img2img.py:326- Finding
Browser Cookies Can Be Disclosed to an Unvalidated Image Host
- Content
View full analysis
300 and box['height'] > 300: area = box['width'] * box['height'] if area > latest_image_size: latest_image_size = area latest_image_url = src print(f"[发现] 新生成图片: {int(box['width'])}x{int(box['height'])}") # ... cookies = await page.context.cookies() cookies_dict = {cookie['name']: cookie['value'] for cookie in cookies} headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', 'Referer': 'https://timiai.woa.com/', } response = requests.get( latest_image_url, cookies=cookies_dict, headers=headers, timeout=60 ) ``` ### Technical Analysis The download destination is derived from the `src` attribute of any newly appearing image whose rendered dimensions exceed the configured threshold. The script does not validate the URL scheme, hostname, port, resolved address, or redirect destination before making the request. After selecting the URL, the script retrieves all cookies available from the Playwright browser context and reduces them to a name/value dictionary. It then explicitly attaches that dictionary to a separate `requests.get()` call. This conversion discards browser-enforced cookie attributes and scoping information, including domain, path, `Secure`, and `SameSite` restrictions. Consequently, cookies that a browser would not send to the selected image host may be transmitted by the `requests` clien ...[truncated 1507 chars]- Remediation
View remediation
