T09 · Insecure Skill Coding Practices
- Location
scripts/notify.sh:116- Finding
AppleScript Injection in the macOS Notification Fallback
- Content
View full analysis
/dev/null; then # Escape double quotes to prevent injection local safe_title safe_title=$(echo "$TITLE" | sed 's/"/\\"/g') local safe_body safe_body=$(echo "$BODY" | sed 's/"/\\"/g') osascript -e "display notification \"${safe_body}\" with title \"${safe_title}\"" 2>&1 ``` ### Technical Analysis The script constructs AppleScript source code dynamically by interpolating `TITLE` and `BODY` into the argument passed to `osascript -e`. The attempted sanitization escapes only double-quote characters. It does not safely encode pre-existing backslashes, control characters, line boundaries, or other input capable of affecting AppleScript parsing. Consequently, attacker-controlled notification content may be interpreted as AppleScript syntax rather than as a literal notification string. This is an injection flaw because untrusted data and executable source code are combined in one shell-expanded string. Shell quoting alone does not make the resulting AppleScript safe: after shell expansion, `osascript` still parses the assembled value as source code. ### Attack Path 1. An attacker causes a task or another invocation path to supply crafted content that reaches the notification title or body. 2. The Skill passes this content to `notify.sh` through `--title` or `--body`. 3. `notify.sh` replaces double quotes but does not perform complete AppleScript-safe encoding. 4. The sanitized value is interpolated directly into an AppleScript program. 5. On macOS, when `terminal-notifier` is unavailable and `osascript` is present, the fallback executes the dynamically generated program. 6. Crafted input can alter the program structure and cause unintended AppleScript operations, potentially including invocatio ...[truncated 768 chars]- Remediation
View remediation
