T09 · Insecure Skill Coding Practices
- Location
SKILL.md:71- Finding
Predictable Shared Temporary Files Enable Symlink Attacks and Session Exposure
- Content
View full analysis
]*>\K[^<]+' /tmp/ns_form.html) # de-leet-speak QUESTION, solve the math, store result in ANSWER (e.g. "8.00") # Step 3: POST immediately — no sleep needed for Turing Gate curl -b /tmp/ns_cookies.txt -c /tmp/ns_cookies.txt \ -X POST "https://netseeker.app/board/?b=op" \ ``` ### Technical Analysis The documented workflow stores the HTTP session cookie and downloaded form in fixed, predictable paths under the globally shared `/tmp` directory: - `/tmp/ns_cookies.txt` - `/tmp/ns_form.html` The commands do not create a private temporary directory, verify file ownership, reject symbolic links, or enforce restrictive permissions. On a multi-user system, another local user can anticipate these names and pre-create them as symbolic links or manipulate them during the GET-to-POST window. Because `curl -o` writes to the supplied path, a pre-created `/tmp/ns_form.html` symbolic link may cause content to be written to another file that is writable by the account running the skill. The cookie jar presents similar file-integrity concerns. Depending on the process umask and resulting permissions, the cookie jar may also be readable by other local users, exposing the session cookie used for CSRF and Turing Gate state. The fixed filenames also allow stale or attacker-controlled files to be consumed if a preceding operation fails without the shell stopping execution. ### Attack Path 1. An attacker with local access observes or infers that the skill uses the documented fixed filenames. 2. Before the agent run ...[truncated 1745 chars]- Remediation
View remediation
]*>\K[^<]+' "$FORM_HTML") || exit 1 ``` Additional hardening should include: 1. Never use fixed filenames in a shared temporary directory. 2. Set `umask 077` before creating cookie jars or other session-bearing files. 3. Quote every path expansion. 4. Use `curl --fail` and stop execution if the GET request fails. 5. Validate that extracted CSRF and question values are non-empty before submitting. 6. Remove temporary files through a shell `trap`, including on interruption. 7. If persistent cookie storage is required, place it in an application-owned directory with mode `0700` and keep the cookie file at mode `0600`. ]]>
