T09 · Insecure Skill Coding Practices
Error
- Location
- auth_guard.py:108
- Finding
- Emergency Stop Disables Authorization Enforcement and Fails Open<![CDATA[ ## Vulnerability Details **File Location**: `auth_guard.py:108-115` and `auth_guard.py:425-429` **Vulnerability Type**: Fail-open authorization logic **Risk Level**: Critical ### Vulnerable Code ```python if not self.config.get("enabled", True): return { "authorized": True, "auth_token": "disabled", "expires_at": (datetime.utcnow()() + timedelta(hours=1)).isoformat() + "Z", "note": "Auth Guard 已禁用" } ``` ```python def emergency_stop(self): """紧急停止 - 禁用所有授权""" self.config["enabled"] = False self._save_config() print("⚠️ 紧急停止已激活 - 所有授权已禁用") ``` ### Technical Analysis The `emergency_stop()` method persists `enabled = False`. However, `request_authorization()` interprets that state as permission to authorize every request instead of rejecting requests. This reverses the expected behavior of a security shutdown control. The project describes emergency stop as stopping all authorization, but invoking it removes the authorization requirement and returns an accepted result with the placeholder token `disabled`. The control therefore fails open precisely when the operator expects the strongest restriction. ### Attack Path 1. An attacker, compromised automation, or misleading instruction causes the user to invoke `python cli.py emergency-stop`. 2. `emergency_stop()` writes `"enabled": false` to the configuration file. 3. A subsequent guarded operation calls `request_authorization()`. 4. The disabled-state branch immediately returns `"authorized": true`. 5. The calling integration proceeds with the external API operation without user confirmation. ### Impact Assessment Any external operation routed through this guard can be approved without confirmation after emergency stop is activated. The effective scope depends on the permissions of the downstream API credentials, potentially including sending messages, reading private data, creating resources, or modifying remote services. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions - Change the disabled and emergency states to fail closed: ```python if not self.config.get("enabled", True): return { "authorized": False, "reason": "Auth Guard is disabled or emergency stop is active" } ``` - Maintain a separate explicit development-only bypass option if bypass behavior is genuinely required. - Require deliberate, authenticated administrative action to enable any bypass. - Add tests asserting that emergency stop rejects every mode and operation. - Revoke all pending and active tokens when emergency stop is activated. - Record emergency activation in an append-only security audit log. ]]>
