T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/ws_client.py:391
- Finding
- Physical device safety workflow is not enforced by the controller<![CDATA[ ## Vulnerability Details **File Location**: `scripts/ws_client.py:391-442`; related requirements in `SKILL.md:105-128` **Vulnerability Type**: Missing server-side safety and authorization state enforcement **Risk Level**: High ### Vulnerable Code ```python def do_POST(self): try: body = self._read_json_body() if self.path == "/strength": result = self._handle_strength(body) self._json_response(200, result) elif self.path == "/waveform": result = self._handle_waveform(body) self._json_response(200, result) elif self.path == "/clear": channel = body.get("channel", "A") self._run_async(self.session.clear_channel(channel)) self._json_response(200, {"ok": True, "action": f"Cleared channel {channel}"}) elif self.path == "/emergency-stop": self._run_async(self.session.emergency_stop()) self._json_response(200, {"ok": True, "action": "Emergency stop executed"}) elif self.path == "/stop": self._json_response(200, {"ok": True, "action": "Shutting down"}) self.session.request_stop() self.server_shutdown.set() else: self._json_response(404, {"error": f"Unknown endpoint: {self.path}"}) except (ValueError, RuntimeError) as e: self._json_response(400, {"error": str(e)}) except Exception as e: logger.exception("API error") self._json_response(500, {"error": str(e)}) def _handle_strength(self, body: dict) -> dict: channel = body.get("channel", "A") action = body.get("action", "set") value = int(body.get("value", 1)) self._run_async(self.session.send_strength(channel, action, value)) return { "ok": True, "action": f"strength {action}", "channel": channel, "value": value, } def _handle_waveform(self, body: dict) -> dict: channel = body.get("channel", "A") ...[truncated 2543 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Add explicit server-side safety state to `DGLabSession`, initially set to unconfirmed. 2. Add a dedicated confirmation operation that records: - Completion of the required safety checklist. - The authorized channel set. - The current pairing identifier. - Confirmation time. 3. Reject `/strength`, `/waveform`, and `/clear` unless confirmation is valid for the current pairing. 4. Reject commands for channels not included in the authorized set. 5. Remove default channel selection; require an explicit valid channel in every request. 6. Reset consent and authorized-channel state after disconnect, pairing changes, controller restart, or reported channel changes. 7. Keep `/emergency-stop` available regardless of confirmation state. 8. Start paired sessions with both channel strengths set to zero where protocol behavior permits. 9. Add tests proving that output is rejected before confirmation and on unauthorized channels. ]]>
