T09 · Insecure Skill Coding Practices
- Location
scripts/note.sh:74- Finding
Arbitrary Command Execution via sed Program Injection in Note Deletion
- Content
View full analysis
- Remediation
View remediation
&2 return 1 fi ``` 2. Do not construct executable sed programs from untrusted input. After validation, use a static parser or an `awk` implementation that passes the identifier as data through `-v` rather than inserting it into program source. 3. Use fixed-string matching where regular expressions are unnecessary: ```bash grep -Fq "[$id]" "$NOTES_FILE" ``` Strict ID validation is still required to ensure the operation can target only valid note identifiers. 4. Write updates to a securely created temporary file using `mktemp`, verify successful processing, and atomically replace the original file. Install a `trap` to remove temporary files on failure. 5. Add regression tests for malformed identifiers containing `/`, `\`, newlines, semicolons, BRE alternation, sed command characters, and shell metacharacters. Confirm that every invalid identifier is rejected before any file is copied or modified. 6. Run the Skill with least privilege and prevent it from accessing credentials or files unrelated to note management, reducing the impact of any future command-execution defect. ]]>
