T09 · Insecure Skill Coding Practices
- Location
scripts/mcp-call.sh:16- Finding
Predictable and Insufficiently Protected MCP Session File
- Content
View full analysis
"$SESSION_FILE" fi ``` ### Technical Analysis The MCP session identifier is stored in a fixed, predictable path under the system-wide `/tmp` directory. The filename depends only on the current username and does not distinguish between MCP endpoints, tenants, OpenClaw instances, or concurrent conversations. The script does not set a restrictive `umask`, explicitly assign mode `0600`, verify ownership, reject symbolic links, or create the session file atomically. With a common process umask of `022`, shell redirection can create the file with mode `0644`, allowing other local users to read the session identifier. There is also a time-of-check/time-of-use window between `rm -f "$SESSION_FILE"` and the later shell redirection. The redirection follows symbolic links if one is introduced during that window. In addition, all processes running under the same account share the same session file, which can cause one Skill invocation t ...[truncated 1996 chars]- Remediation
View remediation
"$tmp_session" mv -f "$tmp_session" "$SESSION_FILE" ``` 4. Before reading the file, verify that it is a regular file, is owned by the effective user, is not a symbolic link, and has no group or world permissions. 5. Isolate sessions by endpoint, tenant, and process or OpenClaw instance. Do not use one username-derived file for every invocation. 6. Register cleanup handlers and remove session material when it is no longer required: ```bash trap 'rm -rf "$SESSION_DIR"' EXIT HUP INT TERM ``` 7. Consider keeping the session identifier in process memory when persistence across separate script invocations is not strictly required. ]]>
