T09 · Insecure Skill Coding Practices
- Location
scripts/activate-memory-sync.sh:5- Finding
Persistent Cron Command Injection Through an Unescaped Workspace Path
- Content
View full analysis
/dev/null 2>&1; then echo "ℹ️ Cron not available - using file-based sync tracking" echo "$(date): Memory sync activated (file-based)" >> .memory-sync-log echo "✅ File-based memory sync activated" exit 0 fi # Add cron job for memory sync (every 6 hours) CRON_JOB="0 */6 * * * cd $WORKSPACE && bash scripts/sync-memory.sh >> .memory-sync-log 2>&1" # Check if cron job already exists if crontab -l 2>/dev/null | grep -q "sync-memory.sh"; then echo "✅ Memory sync cron job already active" else # Add to crontab (crontab -l 2>/dev/null; echo "$CRON_JOB") | crontab - 2>/dev/null || true ``` ### Technical Analysis The script accepts the workspace path from its first argument and confirms only that the shell can change to it. It then inserts that path directly into a crontab command without shell quoting or escaping. Cron executes command fields through a shell. Consequently, shell metacharacters in the workspace path—such as semicolons, command substitutions, redirection operators, or line-breaking characters—can change the meaning of the installed command. Quoting `"$WORKSPACE"` during the initial `cd` does not protect its later interpolation into `CRON_JOB`. The generated command is persistent and runs every six hours. The script also suppresses errors from `crontab` and unconditionally reports successful activation, making installation failures or unexpected modifications harder to detect. ### Attack Path 1. An attacker creates or controls a directory whose path contains shell syntax, or convinces the user to provide such a path as the workspace argument. 2. The user runs: ```bash bash scripts/activate-memory-sync.sh ...[truncated 970 chars]- Remediation
View remediation
/dev/null || true`. 8. Provide a documented uninstall command that removes only the Skill's own marked cron entry. 9. Avoid running the installer or activation script as root. ]]>
