T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- self_governor.py:46
- Finding
- Unrestricted Workspace Reconnaissance Exceeds the Skill's Declared Scope<![CDATA[ ## Vulnerability Details **File Location**: `self_governor.py:46-73` **Vulnerability Type**: Excessive filesystem access and workspace reconnaissance **Risk Level**: High ### Vulnerable Code ```python def scan_project_for_roles(self, project_dir: str = None) -> List[Dict]: """从项目中扫描角色模板""" if project_dir is None: project_dirs = [ os.path.expanduser("~/ai-security/research"), os.path.expanduser("~/.openclaw/workspace/skills"), os.path.expanduser("~/.openclaw/workspace"), ] else: project_dirs = [project_dir] roles = [] keywords = ["role", "agent", "skill", "capability", "职责", "能力"] for pdir in project_dirs: if not os.path.exists(pdir): continue for root, dirs, files in os.walk(pdir): dirs[:] = [d for d in dirs if not d.startswith('.')] for f in files: if f.endswith(('.md', '.yaml', '.json')): path = os.path.join(root, f) try: with open(path, 'r', encoding='utf-8', errors='ignore') as fp: content = fp.read().lower() for kw in keywords: if kw in content: roles.append({ "file": path, "name": f, "type": self._detect_type(f, content), "keywords": self._extract_keywords(content) }) break except: pass ``` ### Technical Analysis When no project directory is explicitly supplied, the self-governance module recursively traverses the entire OpenClaw workspace, its Skill directory, and the external research directory. I ...[truncated 2366 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove workspace-wide directories from the default configuration. 2. Require the caller to provide an explicit scan root and obtain user approval before scanning it. 3. Resolve the requested root with `Path.resolve()` and verify that it is inside a narrowly defined allowlisted directory. 4. Scan only designated role-template files rather than every Markdown, YAML, and JSON file. 5. Introduce maximum traversal depth, file-count, and file-size limits. 6. Reject symlinks or verify that every resolved file remains inside the approved root. 7. Do not return absolute paths unless explicitly required; return paths relative to the approved root. 8. Add structured audit logging that records the approved root and files accessed without recording sensitive contents. 9. Replace broad exception suppression with explicit error handling so denied or malformed files are visible during security review. ]]>
