T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/openclaw_troubleshooting.py:291
- Finding
- Recursive Permission Repair Exposes the Entire OpenClaw Workspace<![CDATA[ ## Vulnerability Details **File Location**: `scripts/openclaw_troubleshooting.py`, lines 291–302 **Vulnerability Type**: Excessive recursive permission modification **Risk Level**: High ### Vulnerable Code ```python def fix_permissions(self): """Fix permissions issues""" try: # Fix workspace permissions if os.path.exists(self.workspace_dir): subprocess.check_output(['chmod', '-R', '755', self.workspace_dir]) # Fix custom skills directory permissions custom_skills_dir = os.path.join(self.workspace_dir, 'custom-skills') if os.path.exists(custom_skills_dir): subprocess.check_output(['chmod', '-R', '755', custom_skills_dir]) ``` The quick-start example can invoke this operation automatically when its permission check reports a warning: ```python permissions_status = diagnosis.get('permissions', {}).get('status', 'warning') if permissions_status == 'warning': print("🔐 发现权限问题,正在修复...") troubleshooter.fix_issue('permissions') ``` ### Technical Analysis The permission repair function executes `chmod -R 755` against the complete OpenClaw workspace. This recursively assigns owner read, write, and execute permissions and group/other read and execute permissions to every directory and regular file below the workspace. The workspace is expected to include `custom-skills`, `projects`, and `memory`. These directories may contain private project files, agent state, user information, configuration data, or credentials. Applying mode `755` recursively therefore violates least privilege by making all such files readable by every local account. It also unnecessarily marks regular files as executable. The implementation does not: - Determine which individual path has a permission problem. - Preserve existing restrictive permissions. - Distinguish directories from regular files. - Check effective access using `os.access`. - Request confirmation before recursively changing the ...[truncated 1943 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the recursive `chmod -R 755` operation. 2. Diagnose effective permissions with `os.access(path, os.R_OK | os.W_OK)` rather than checking only owner mode bits. 3. Change only the specific paths for which a permission defect has been confirmed. 4. Apply restrictive defaults: - Workspace and private directories: `0700`. - Private regular files: `0600`. - Executable files: add execute permission only when execution is required. 5. Distinguish directories from regular files while repairing permissions. 6. Preserve existing permission bits unless a specific change is necessary. 7. Require explicit user confirmation before any recursive permission operation. 8. Display every affected path and its old and proposed modes before applying changes. 9. Avoid following symbolic links and ensure resolved targets remain inside the intended workspace. 10. Record prior modes so that changes can be rolled back if the repair fails. 11. Do not automatically invoke permission repair from the quick-start example; provide diagnosis and an explicit remediation command instead. ]]>
