Back to skill

Security audit

会话日志分析

Security checks for vulnerabilities and agentic risk

Overview

This skill is meant to search local session logs, but its example code can read more history or files than users would reasonably expect.

Review this skill before installing. It does not look malicious, but it handles sensitive local session history and its sample code needs tighter scoping: require explicit user approval before log searches, enforce date limits, restrict file names to known log files, reject traversal and absolute paths, limit results, and redact secrets from returned snippets.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
SKILL.md:64
Finding

Path Traversal Permits Reading Files Outside the Session Log Directory

Content
View full analysis
list: commands = [] with open(self.log_dir / log_file, 'r') as f: for line in f: if 'command:' in line.lower() or 'user:' in line.lower(): commands.append(line.strip()) return commands ``` ### Technical Analysis The `extract_commands()` method uses the caller-controlled `log_file` value directly when constructing the path passed to `open()`. It does not reject absolute paths, parent-directory components such as `../`, symbolic links, or files outside the expected log directory. With `pathlib.Path`, joining `self.log_dir` to an absolute path causes the absolute operand to take precedence. Relative traversal components are also processed by the operating system when the file is opened. Consequently, the function is not restricted to session log files under `self.log_dir`. The returned data is filtered to lines containing `command:` or `user:`. Therefore, this is not an unrestricted full-file disclosure primitive, but it can still disclose matching lines from any file readable by the process. ### Attack Path 1. An attacker or untrusted caller gains the ability to select the `log_file` argument. 2. The caller supplies an absolute path or traversal value, such as `/path/to/sensitive-file` or `../../sensitive-file`. 3. The expression `self.log_dir / log_file` identifies a file outside the configured session log directory. 4. The process opens that file using its existing operating-system privileges. 5. Every line containing `command:` or `user:` is returned to the caller. A symbolic link placed inside the log directory could produce the same result if it points to an external file. ### Impact Assessment The vulnerability permits unauthorized inspection of files outsi ...[truncated 452 chars]
Remediation
View remediation
list: base = self.log_dir.resolve() supplied = Path(log_file) if supplied.is_absolute() or supplied.name != log_file: raise ValueError("A plain log filename is required") target = (base / supplied).resolve() if target.parent != base: raise ValueError("Log file must remain inside the log directory") if target.suffix != ".log" or not target.is_file() or target.is_symlink(): raise ValueError("Invalid log file") commands = [] with target.open("r", encoding="utf-8", errors="replace") as f: for line in f: lowered = line.lower() if "command:" in lowered or "user:" in lowered: commands.append(line.strip()) return commands ``` Apply authorization and output-redaction controls as well, because valid session logs may themselves contain sensitive information. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:48
Finding

Declared Time Restriction Is Not Enforced During Session Log Searches

Content
View full analysis
list: results = [] for file in self.log_dir.glob("*.log"): try: with open(file, 'r', encoding='utf-8', errors='ignore') as f: for i, line in enumerate(f, 1): if keyword.lower() in line.lower(): results.append({ 'file': file.name, 'line': i, 'content': line.strip()[:200] }) except: pass return results ``` The directory searched by this method is initialized as follows: ```python def __init__(self, log_dir: str = "~/.openclaw/logs"): self.log_dir = Path(log_dir).expanduser() ``` ### Technical Analysis The public interface declares a `days` parameter with a default value of seven, and the documented example supplies `days=30`. However, `search_logs()` never calculates a cutoff or checks file modification times. It instead opens every matching `.log` file in the configured directory. A caller can reasonably expect the search to be restricted to the requested time period, but the implementation searches all available history. This creates unnecessary exposure of historical conversations and violates data-minimization expectations. The bare `except:` clause also suppresses every exception, including unexpected programming and filesystem errors. This makes the missing or inconsistent enforcement harder to detect and audit. ### Attack Path 1. A user or integrating component requests a search with a narrow period, such as `days=1`. 2. The function ignores the supplied period. 3. It enumerates every `*.log` file in the configured dir ...[truncated 868 chars]
Remediation
View remediation
list: if not isinstance(days, int) or days < 0 or days > 365: raise ValueError("days must be an integer from 0 to 365") results = [] cutoff = datetime.now() - timedelta(days=days) needle = keyword.casefold() for file in self.log_dir.glob("*.log"): try: if datetime.fromtimestamp(file.stat().st_mtime) < cutoff: continue with file.open("r", encoding="utf-8", errors="replace") as f: for line_number, line in enumerate(f, 1): if needle in line.casefold(): results.append({ "file": file.name, "line": line_number, "content": line.strip()[:200], }) except (OSError, UnicodeError): continue return results ``` ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (2)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill is explicitly designed to search and analyze historical session logs, which can contain sensitive prompts, secrets, personal data, or prior command/output history. Because the description and usage examples encourage log access without any warning, consent boundary, or sensitivity notice, users may expose confidential information unintentionally.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The natural-language content of the skill, including description, headings, activation words, and examples, is presented in Chinese without indicating that users may interact in other languages or that the skill is intentionally region-specific. SQP-3 requires flagging language or locale policy violations when a specific language is imposed without user opt-in or justification.

Content

No source excerpt is available for this finding.