T09 · Insecure Skill Coding Practices
- Location
server.py:319- Finding
Unauthenticated Desktop-Control API with Permissive Cross-Origin Access
- Content
View full analysis
Vulnerability Details
File Location:
server.py:319-339,server.py:360-379, andserver.py:416
Vulnerability Type: Missing authentication and overly permissive CORS on a security-sensitive local API
Risk Level: HighVulnerable Code
python def _send_json(self, data, status=200): try: self.send_response(status) self.send_header('Content-Type', 'application/json') self.send_header('Access-Control-Allow-Origin', '*') self.end_headers() self.wfile.write(json.dumps(data).encode()) except Exception as e: print(f"Error sending response: {e}") def _send_error(self, message, status=400): self._send_json({"ok": False, "error": message}, status) def do_OPTIONS(self): self.send_response(200) self.send_header('Access-Control-Allow-Origin', '*') self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS') self.send_header('Access-Control-Allow-Headers', 'Content-Type') self.end_headers()Sensitive operations are then dispatched without any authentication or authorization check:
python if path == '/capture': cap_result = capture(quality=data.get('quality')) result = cap_result elif path == '/move': result = handle_move(data.get('x'), data.get('y')) elif path == '/click': result = handle_click(data.get('x'), data.get('y'), data.get('button', 'left')) elif path == '/drag': result = handle_drag(data.get('x1'), data.get('y1'), data.get('x2'), data.get('y2'), data.get('button', 'left')) elif path == '/scroll': result = handle_scroll(data.get('x'), data.get('y'), data.get('direction', 'down'), data.get('amount', 3)) elif path == '/enter': result = handle_enter(data.get('keys', []))The service is restricted to loopback, but this does not protect it from local proc ...[truncated 2728 chars]
- Remediation
View remediation
Remediation Suggestions
- Generate a cryptographically random secret for every server session and require it in an
Authorization: Bearerheader for all endpoints except, if necessary, a minimal health check. - Store the secret with user-only permissions and never place it in URLs, where it may leak through logs or browser history.
- Remove
Access-Control-Allow-Origin: *. If browser integration is required, use a strict allowlist of trusted origins and reject requests with missing or unexpectedOriginheaders. - Restrict accepted methods and require
Content-Type: application/jsonfor action endpoints. - Consider separate privileges for capture and input injection, allowing clients to receive only the capabilities they require.
- Add rate limits and maximum action-sequence lengths to reduce automated abuse.
- Require explicit user confirmation for high-impact keyboard combinations or provide an emergency stop mechanism.
- Continue binding to loopback and document that loopback binding is defense in depth, not a substitute for authentication.
- Generate a cryptographically random secret for every server session and require it in an
