T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/extract_decisions.py:14- Finding
Unscoped Access to Sensitive Agent Session Transcripts
- Content
View full analysis
Vulnerability Details
File Location:
scripts/analyze_context.py:31-44,scripts/extract_decisions.py:14-56, andscripts/summarize_session.py:19-39
Vulnerability Type: Missing session-level access control and ignored session selector
Risk Level: MediumComplete Code Snippets
scripts/analyze_context.py:31-44:python transcript_paths = [ Path("~/.openclaw/agents/main/sessions/").expanduser(), ] total_messages = 0 oldest = None newest = None for p in transcript_paths: if p.exists() and p.is_dir(): jsonl_files = list(p.glob("*.jsonl")) if jsonl_files: latest = max(jsonl_files, key=lambda f: f.stat().st_mtime) with open(latest) as f: for line in f: if line.strip(): total_messages += 1scripts/extract_decisions.py:14-56:python def load_messages(): """Load messages from the latest session transcript.""" p = Path("~/.openclaw/agents/main/sessions/").expanduser() if not p.exists(): return [] jsonl_files = [f for f in p.glob("*.jsonl") if ".lock" not in str(f)] if not jsonl_files: return [] latest = max(jsonl_files, key=lambda f: f.stat().st_mtime) messages = [] with open(latest) as f: for line in f: if not line.strip(): continue try: entry = json.loads(line) if entry.get("type") == "message": msg = entry.get("message", {}) role = msg.get("role", "unknown") content = msg.get("content", []) text = "" if isinstance(content, str): text = content elif isinstance(content, list): for block in content: if is ...[truncated 3646 chars]- Remediation
View remediation
Remediation Suggestions
- Make
--sessionmandatory and use it to resolve one specific transcript rather than selecting the newest global file. - Validate the session identifier against a strict format and reject path separators or traversal sequences.
- Resolve the selected path and verify that it remains inside an approved session directory.
- Verify that the caller is authorized to access the requested session.
- Do not include tool arguments by default; tool commands can contain tokens, file paths, or other sensitive values.
- Apply secret redaction to transcript text before printing or writing it.
- Require explicit confirmation before processing a transcript selected through a
currentalias. - Open files using UTF-8 with controlled error handling and impose limits on transcript size and line length.
- Add tests proving that a request for one session cannot read another session, even when the other file has a newer modification time.
- Make
