T09 · Insecure Skill Coding Practices
- Location
scripts/collect-session.mjs:274- Finding
Session Content and API Credentials Can Be Sent to an Unvalidated Network Endpoint
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill is a documented session-history collector, but it automatically reads and stores broad OpenClaw session data and can send user-message excerpts plus a LiteLLM key to a configurable endpoint without strong privacy controls.
Install only if you want automatic long-term session logging. Keep the output directory out of shared or synced repositories, use --no-llm or leave LITELLM_API_KEY unset for sensitive work, restrict LITELLM_BASE_URL to a trusted local endpoint, and periodically delete or protect the generated Markdown and JSONL logs.
scripts/collect-session.mjs:274Session Content and API Credentials Can Be Sent to an Unvalidated Network Endpoint
scripts/hook-handler.ts:15Unvalidated Event Context Controls the JavaScript File Executed by the Hook
Referenced artifact was not completely inspected
Copy `scripts/collect-session.mjs` to your workspace scripts directory:
Referenced artifact was not completely inspected
Copy `scripts/collect-session.mjs` to your workspace scripts directory:
The skill explicitly states it captures every session, including turns, tool calls, model usage, and writes rich Markdown summaries to disk, but it provides no privacy warning, scoping limits, retention guidance, or redaction controls. This can cause sensitive prompts, secrets, internal file paths, tool outputs, or personal data to be persistently stored in searchable local artifacts, increasing exposure after compromise or accidental sharing.
The documented behavior is to persist entire session contents and related telemetry into multiple local files, including a searchable index and JSONL log. Persisting comprehensive conversation and tool activity creates a durable record of potentially sensitive operational data that may later be accessed by other local users, backup systems, malware, or accidentally committed to source control.
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
Copy scripts/hook-handler.ts to your OpenClaw hooks directory and register it:
mkdir -p ~/.openclaw/hooks/collect-session
cp hook-handler.ts ~/.openclaw/hooks/collect-session/handler.ts
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
**Hook not firing on /new:** Check that `collect-session` is enabled in `openclaw.json` and the gateway was restarted. Look for `[collect-session]` lines in gateway logs.
**`LITELLM_API_KEY not configured` warning:** Set `LITELLM_API_KEY` env var or edit the CONFIG block. The script will fall back to heuristic titles but still write session files.
**Sessions directory not found:** The default sessions path is `~/.openclaw/agents/main/sessions`. If you use a custom agent name, update `SESSIONS_DIR` in the CONFIG block.
The enrichment flow intentionally extracts user message excerpts and forwards them to an LLM, then stores model-generated summaries and keywords derived from that content. This creates a data-sharing and data-retention chain for potentially sensitive session material, and the downstream summary may preserve or amplify confidential details that were present in the original conversation.
The script sends sampled user session content to a LiteLLM endpoint for title/keyword/summary generation without any explicit consent flow, sensitivity check, or redaction step. Even though the default endpoint is localhost, LiteLLM commonly proxies to third-party model providers, so private prompts, secrets, file paths, or other sensitive context can be disclosed outside the local machine.
The generated Markdown front matter and later JSONL logging preserve session identifiers, source filenames, full source paths, costs, and other session-derived details on disk. In an agent skill context, this is more dangerous because session files may contain traces of user activity and repository locations, and persistent logs broaden the attack surface beyond the original session artifact.
The script persistently stores session-derived metadata, summaries, keywords, source paths, and usage details into Markdown and JSONL files without any warning about sensitivity or retention. Those files can accumulate confidential conversation content and filesystem information, increasing exposure if the workspace is shared, synced, backed up, or later exfiltrated.