T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/main.py:13
- Finding
- Unauthenticated Plaintext Control of Physical and Privacy-Sensitive Robot Functions<![CDATA[ ## Vulnerability Details **File Location**: `scripts/main.py:13-33`, with sensitive operations exposed through `scripts/main.py:86-112` **Vulnerability Type**: Unauthenticated plaintext HTTP communication **Risk Level**: High ### Vulnerable Code ```python ROBOT_IP = "192.168.199.10" API_BASE = f"http://{ROBOT_IP}:60010" class RobotClient: """元萝卜机器人控制客户端""" def __init__(self, ip=ROBOT_IP): self.ip = ip self.api_base = f"http://{ip}:60010" # ── HTTP API ── def _api_get(self, path, params=None, binary=False): url = f"{self.api_base}{path}" if params: url += "?" + urllib.parse.urlencode(params, quote_via=urllib.parse.quote) print(f"📡 GET {url}") req = urllib.request.Request(url) with urllib.request.urlopen(req, timeout=30) as resp: data = resp.read() if binary: print(f"✅ 响应: [Binary Data] {len(data)} bytes") return data body = data.decode("utf-8") print(f"✅ 响应: {body[:500]}") return body ``` The same unauthenticated transport is used for privacy-sensitive and file-transfer operations: ```python def show_image(self, image_path): """显示图片""" # Using curl for multipart/form-data upload as it's simpler and more robust # than manual multipart construction in standard library without requests url = f"{self.api_base}/skill-show-image" print(f"📡 POST {url} image={image_path}") try: # Use curl to upload the file cmd = ['curl', '--location', url, '--form', f'image=@"{image_path}"'] result = subprocess.run(cmd, capture_output=True, text=True, check=True) print(f"✅ 响应: {result.stdout[:500]}") return result.stdout except subprocess.CalledProcessError as e: print(f"❌ Curl failed: {e.stderr}") return "" def take_photo(self, camera_id): """拍照 (0=前置 1=右边 2=左边)""" return self._api_get("/ ...[truncated 2922 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace HTTP with HTTPS and validate the robot's certificate. 2. Prefer mutual TLS or certificate/public-key pinning when the robot uses a private certificate authority. 3. Require authentication and authorization for every API operation. Use short-lived, scoped credentials rather than embedding long-lived secrets in source code. 4. Add request integrity and replay protection if TLS cannot be deployed immediately, while recognizing that this is not a full substitute for authenticated encryption. 5. Reject redirects for robot API calls and image uploads, or allow them only after validating that the destination has the expected scheme, host, and port. 6. Validate response status codes, content types, maximum response sizes, and complete JSON schemas before acting on responses. 7. Correlate physical-operation responses with request identifiers and independently verify safety-critical state before initiating a subsequent action. 8. Segment the robot onto a restricted network and limit access to explicitly authorized controller devices with firewall rules. 9. Avoid logging complete URLs when query parameters may contain private speech content or other sensitive information. ]]>
