T09 · Insecure Skill Coding Practices
- Location
scripts/session_mgr.py:225- Finding
Unvalidated Session Name Allows Control-Signal and Output Injection
- Content
View full analysis
") return 1 session_name = args[0].strip() names = load_names() if session_name in names: print(f"Error: a session named '{session_name}' already exists. Use /reload-session {session_name} to return to it.") return 1 print(f"NEW_SESSION:{session_name}") return 0 ``` ### Technical Analysis `cmd_new_session()` accepts the first command-line argument as a session name and embeds it directly into the `NEW_SESSION:` control output. It does not enforce the documented session-name allowlist or the documented 64-character maximum. Elsewhere, `cmd_name()` and `cmd_rename()` partially validate names as letters, digits, underscores, and hyphens. The missing equivalent validation in `cmd_new_session()` creates inconsistent trust boundaries. An argument can contain newline characters, terminal escape sequences, delimiters, or an excessively long value. Because `NEW_SESSION:` is intended to be consumed as an agent control signal rather than ordinary text, unescaped attacker-controlled content can alter the apparent structure of the output. Depending on downstream parsing behavior, this may create additional forged lines, spoof messages, confuse signal handling, or inject terminal control sequences. No evidence shows direct operating-system command execution through this flaw. ### Attack Path 1. An attacker or untrusted caller invokes the script's `new-session` command with a crafted first argument containing a newline, control sequence, delimiter, or excessive length. 2. `cmd_new_session()` strips only leading and trailing whitespace; it pe ...[truncated 1144 chars]- Remediation
View remediation
