T05 · Unauthorized Access and Privilege Escalation
- Location
permission_switch.py:69- Finding
No-approval mode can be enabled without enforced human confirmation
- Content
View full analysis
Vulnerability Details
File Location:
permission_switch.py:69-117, 332-333; related consent requirement inSKILL.md:79-83
Vulnerability Type: Approval-control bypass and privilege escalation
Risk Level: HighVulnerable Code
The
no_approvalmode defines a policy that grants unrestricted command execution without approval:python "no_approval": { "name": "免审批模式", "security": "full", "ask": "off", "safety": "⭐", "convenience": "⭐⭐⭐⭐⭐", "description": "所有命令自动执行,无需任何审批", "recommendation": "仅用于可信环境,存在安全风险" },The mode is applied directly to the persistent OpenClaw configuration:
python def switch_mode(self, mode_name: str) -> Dict[str, Any]: """ 切换权限模式(直接修改配置文件) Args: mode_name: 模式名称(default/full/no_approval/strict) Returns: 切换结果 """ if mode_name not in self.MODES: # 尝试模糊匹配 matched_mode = self._fuzzy_match_mode(mode_name) if matched_mode: mode_name = matched_mode else: return { "success": False, "error": f"未知模式:{mode_name}", "available_modes": list(self.MODES.keys()), "mode_names": {k: v["name"] for k, v in self.MODES.items()} } mode = self.MODES[mode_name] # 直接修改配置文件 try: if not os.path.exists(self.config_path): return { "success": False, "error": f"配置文件不存在:{self.config_path}" } # 读取配置 with open(self.config_path, 'r', encoding='utf-8') as f: config = json.load(f) # 修改 tools.exec 配置 if "tools" not in config: config["tools"] = {} if "exec" not in config["tools"]: config["tools"]["exec"] = {} config["tools"]["exec"]["security"] = mode["security"] config ...[truncated 3278 chars]- Remediation
View remediation
Remediation Suggestions
- Require an explicit confirmation mechanism specifically for
no_approval. In interactive use, display the old and proposed policies and require an exact confirmation phrase before writing the configuration. - Reject non-interactive activation by default. If automation is necessary, require a separate, narrowly scoped authorization token or protected flag rather than treating the mode name as sufficient authorization.
- Bind confirmation to the requested configuration, user, and a short expiration period so an old confirmation cannot be replayed.
- Prefer temporary elevation with automatic rollback after a defined timeout. Restore the previous policy even if the process or Gateway exits unexpectedly.
- Record an audit event containing the initiating identity, timestamp, previous policy, new policy, and confirmation method.
- Perform configuration writes atomically using a temporary file and rename operation. Preserve a secure backup and verify that the destination is not an attacker-controlled symbolic link.
- Validate the resulting configuration after writing and fail closed by restoring the prior approval policy if validation fails.
- Treat
security = fullorask = offas security-sensitive downgrades and enforce authorization in the executable itself rather than relying on agent instructions or documentation.
- Require an explicit confirmation mechanism specifically for
