T09 · Insecure Skill Coding Practices
- Location
scripts/notify.sh:9- Finding
AppleScript and PowerShell Injection Through Notification Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/notify.sh, lines 9–22
Vulnerability Type: Command injection caused by embedding untrusted arguments in interpreter source
Risk Level: HighVulnerable Code
bash if [[ "$OS" == "Darwin" ]]; then # macOS osascript -e "display alert \"${2:-Lobbie Notification}\" message \"${1:-Notification from lobbie!}\"" elif [[ "$OS" == "Linux" ]]; then # Check if we are in WSL if grep -qi "Microsoft" /proc/version 2>/dev/null; then # WSL: Call Windows powershell for the pop-up powershell.exe -Command "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('${1:-Notification from lobbie!}', '${2:-Lobbie Notification}')" else # Native Linux: use notify-send notify-send "${2:-Lobbie Notification}" "${1:-Notification from lobbie!}" fi elif [[ "$OS" == "Unknown" ]] || [[ "$OS" == "MSWindowsNT" ]]; then # Windows (via Git Bash/Cygwin/etc) powershell -Command "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms. MessageBox]::Show('${1:-Notification from lobbie!}', '${2:-Lobbie Notification}')"Technical Analysis
The script inserts positional parameters
$1and$2directly into source code evaluated by AppleScript or PowerShell.On macOS, the arguments are placed inside AppleScript string literals in an
osascript -eexpression. An argument containing quotes and valid AppleScript syntax can terminate the intended literal and alter the program evaluated byosascript.On Windows and WSL, the arguments are placed inside single-quoted PowerShell literals passed to
-Command. A single quote in either argument can terminate the intended PowerShell string, after which additional PowerShell statements can be injected.The Bash quoting around these expressions does not provide protection at the interpreter boundary. It only affects parsing by Bash; after parameter expansion, the resulting text is s ...[truncated 1744 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not concatenate notification content into AppleScript or PowerShell source code.
- On macOS, pass the title and message as separate
osascriptarguments and retrieve them through anon run argvhandler. Keep the AppleScript program fixed so argument content is handled only as data. - On Windows and WSL, use a fixed PowerShell script file or a fixed command that accepts properly bound parameters. Avoid constructing the value supplied to
-Commandfrom caller-controlled text. - If an external script file is used, invoke it with named or positional parameters and ensure that the message and title are passed as process arguments rather than parsed as PowerShell code.
- Validate behavior with security regression tests containing single quotes, double quotes, backticks, semicolons, parentheses, newlines, Unicode characters, and interpreter-specific metacharacters.
- Treat task output, repository content, filenames, logs, and generated Agent text as untrusted whenever they may be forwarded to this script.
- Preserve the native Linux design of passing values as separately quoted arguments to
notify-send.
