T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/clear_agent_rules.py:418- Finding
Overbroad Recursive Deletion of Configuration and Potentially Sensitive Data
- Content
View full analysis
Vulnerability Details
File Location:
scripts/clear_agent_rules.py:168,scripts/clear_agent_rules.py:207-238, andscripts/clear_agent_rules.py:418-433
Vulnerability Type: Overbroad destructive file operation
Risk Level: HighThe implementation deletes entire application configuration directories and a generic project-level
config.toml, despite the documentation stating that only AI rule or skill files are removed.Vulnerable Code
python {"name": "OpenHands 配置文件", "platform": "openhands", "path": "config.toml"},python {"name": "Continue 全局配置目录", "platform": "continue", "path": home(".continue")}, {"name": "Claude Code 全局指令文件", "platform": "claude", "path": home(".claude", "CLAUDE.md")}, {"name": "Claude Code 全局配置目录", "platform": "claude", "path": home(".claude")}, {"name": "OpenCode 全局配置目录", "platform": "opencode", "path": home(".config", "opencode")}, {"name": "OpenCode 全局 AGENTS.md", "platform": "opencode", "path": home(".config", "opencode", "AGENTS.md")}, {"name": "OpenCode Claude 兼容目录", "platform": "opencode", "path": home(".claude")}, {"name": "Kiro 全局配置目录", "platform": "kiro", "path": home(".kiro")}, {"name": "Kiro MCP 配置文件", "platform": "kiro", "path": home(".kiro", "mcp-config.json")}, {"name": "OpenHands 全局配置目录", "platform": "openhands", "path": home(".openhands")}, {"name": "PI 编码代理全局配置", "platform": "pi", "path": home(".pi", "agent", "settings.json")}, {"name": "PI 全局配置目录", "platform": "pi", "path": home(".pi")},python def do_delete(targets): """执行删除,返回 (success_count, fail_count)""" section("执行清除") success, fail = 0, 0 for t in targets: try: if t["path"].is_dir(): shutil.rmtree(str(t["path"])) else: t["path"].unlin ...[truncated 2687 chars]- Remediation
View remediation
Remediation Suggestions
- Replace directory-level targets with explicit allowlists of documented rule files and rule-only subdirectories.
- Do not recursively delete complete roots such as
~/.claude,~/.continue,~/.kiro,~/.openhands, or~/.pi. - Remove the generic project-root
config.tomltarget, or verify platform ownership through a strict schema and platform-specific markers before including it. - Enumerate and display every individual file that will be deleted rather than displaying only a parent directory.
- Resolve and validate each path immediately before deletion, ensuring that it remains inside an approved project or user configuration boundary.
- Reject symlinks and other path redirections, or handle them without traversing their targets.
- Require separate explicit confirmation for project-level and global deletion.
- Update the documentation so that it accurately describes every type of data that may be removed.
- Add automated tests proving that credentials, histories, generic configuration files, and unrelated files survive cleanup.
