T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/monitor.sh:10
- Finding
- Untargeted browser screenshot may disclose unrelated sensitive content<![CDATA[ ## Vulnerability Details **File Location**: `scripts/monitor.sh:10-12, 24-32`; `scripts/capture_qrcode.sh:7-14` **Vulnerability Type**: Unscoped browser capture and unintended data transmission **Risk Level**: High ### Vulnerable Code `scripts/monitor.sh:10-12, 24-32`: ```bash # Check if page is open PAGE_STATE=$(browser action=tabs targetUrl="$WEBSITE" 2>&1) if echo "$PAGE_STATE" | grep -q "_/\|chat\|message"; then echo "Logged in! Sending test message..." else echo "Not logged in - capturing QR..." # Capture QR browser action=screenshot path="$OUTPUT_FILE" # Send QR to user if [ -f "$OUTPUT_FILE" ]; then message action=send to="$USER_PHONE" media="$OUTPUT_FILE" echo "QR code sent to $USER_PHONE" else echo "Failed to capture QR" fi fi ``` `scripts/capture_qrcode.sh:7-14`: ```bash echo "Capturing QR code from filehelper.weixin.qq.com..." # Take screenshot browser action=screenshot path="$OUTPUT_FILE" if [ -f "$OUTPUT_FILE" ]; then echo "QR code captured: $OUTPUT_FILE" ls -la "$OUTPUT_FILE" ``` ### Technical Analysis The code queries tabs using the expected WeChat URL but does not extract, validate, or retain the `targetId` of the matching tab. The subsequent `browser action=screenshot` command is invoked without a `targetId` or an element selector. Consequently, the screenshot can be taken from the active or default browser context rather than the WeChat File Helper tab. In `monitor.sh`, the resulting image is then sent through a configured messaging channel. The script also does not verify the final page origin or confirm that the captured image contains a WeChat QR element before transmission. This behavior exceeds the minimum browser access necessary for the declared functionality. The Skill only needs to capture the QR element on a validated WeChat page, not the entire active browser context. ### Attack Path 1. The user or a scheduled job invokes `scripts/monitor.sh`. 2. A browser page other than ...[truncated 1073 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Extract the exact `targetId` returned for `https://filehelper.weixin.qq.com/`. 2. Pass that `targetId` explicitly to every screenshot, snapshot, evaluation, typing, and clicking operation. 3. Immediately before capture, verify that: - The origin is exactly `https://filehelper.weixin.qq.com`. - The page is in the expected logged-out state. - A unique QR-code element is present. 4. Capture only the validated QR-code element instead of the full browser viewport. 5. Abort if multiple matching tabs exist or if the target cannot be identified unambiguously. 6. Do not send an image merely because a file was created; validate that it came from the intended target and capture operation. 7. Require an explicitly configured and validated recipient before transmitting the image. ]]>
