T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/l1_fast_check.py:80- Finding
Unnecessary Reading of Sensitive OpenClaw Agent Files
- Content
View full analysis
tuple: """检查文件是否存在 Returns: (exists: bool, size_kb: int, readable: bool) """ if not file_path.exists(): return False, 0, False try: size = file_path.stat().st_size size_kb = size // 1024 # 检查是否可读 with open(file_path, "r", encoding="utf-8") as f: f.read(1024) # 只读 1KB 测试 return True, size_kb, True ``` The files passed to this function include `SOUL.md`, `IDENTITY.md`, `AGENTS.md`, `TOOLS.md`, and `MEMORY.md`, as defined at `scripts/l1_fast_check.py:34-40`. ### Technical Analysis The L1 feature is presented as an existence, size, and readability check. However, the implementation opens each configured file and reads up to 1 KB of its contents. Reading content is unnecessary for establishing that a file exists or determining its size. These OpenClaw files may contain Agent identity information, behavioral instructions, tool definitions, or persistent memory. Consequently, the implementation crosses a least-privilege boundary even though the current code does not retain, display, or transmit the data. The immediate implementation does not contain an exfiltration channel. Nevertheless, unnecessarily loading sensitive content into the process increases exposure if the script, an imported local module, or a future version is compromised. ### Attack Path 1. The user or an OpenClaw initialization hook invokes `scripts/l1_fast_check.py`. 2. The script resolves the default workspace under `~/.openclaw/workspace`. 3. It iterates over sensitive Agent files, including `MEMORY.md`, `SOUL.md`, and `AGENTS.md`. 4. `check_file_exists()` opens every existing file. 5. Th ...[truncated 638 chars]- Remediation
View remediation
tuple: if not file_path.is_file(): return False, 0, False try: size_kb = file_path.stat().st_size // 1024 readable = os.access(file_path, os.R_OK) return True, size_kb, readable except OSError: return True, 0, False ``` - Make checks of `MEMORY.md`, `SOUL.md`, and other sensitive Agent files explicitly opt-in. - Restrict configurable filenames to the intended workspace and reject absolute paths or traversal components. - Add a regression test confirming that L1 performs no content reads. ]]>
