T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- SKILL.md:43
- Finding
- Cross-Agent Session Transcript Enumeration<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:43-51` **Additional Occurrences**: `SKILL.md:72-76`, `SKILL.md:91-99` **Vulnerability Type**: `T05: Unauthorized Access and Privilege Escalation` **Risk Level**: Medium ### Vulnerable Code ```python for f in glob.glob(os.path.expanduser("~/.openclaw/agents/*/sessions/*.jsonl")): if today in os.path.basename(f) or os.path.getmtime(f) > __import__('time').time() - 86400: sessions += 1 with open(f) as fh: for line in fh: try: cost = json.loads(line).get('message',{}).get('usage',{}).get('cost',{}).get('total',0) if cost: total += cost except: pass ``` Equivalent cross-agent wildcard access is also used by the budget-check and per-model-breakdown examples. ### Technical Analysis The wildcard path `~/.openclaw/agents/*/sessions/*.jsonl` enumerates and opens session transcripts belonging to every locally accessible agent. It does not restrict access to the current agent or to a dedicated usage ledger. Although the supplied code only extracts model and cost fields, each entire JSONL line is read and decoded first. Session transcripts may contain prompts, responses, tool results, and other sensitive operational context. Consequently, the implementation gives the cost-analysis workflow access to substantially more data than it needs. The code does not bypass operating-system permissions, and no transmission of transcript data is implemented. The security concern is the failure to maintain least-privilege separation between local agents. ### Attack Path 1. A user or agent runs one of the documented cost-analysis commands. 2. The wildcard enumerates session files for every agent under `~/.openclaw/agents/`. 3. The process opens every qualifying transcript file that its current account can read. 4. Every JSONL record is loaded into memory and parsed. 5. A modified, compromised, or extended version ...[truncated 662 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Restrict the default path to the current agent and current session. - Require explicit user authorization before producing a fleet-wide cost report. - Prefer a dedicated usage or billing ledger that contains only timestamps, model identifiers, token counts, and costs. - Allow cross-agent paths only through an explicit allowlist rather than the `*` wildcard. - Validate resolved paths and reject files outside the intended session directory. - Avoid parsing complete transcript records when usage metadata can be stored and read separately. - Document the exact files accessed and the sensitivity of session transcripts. - Run the reporting process under an account or sandbox with access only to required usage data. ]]>
