Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 10, 2026

The ShortcutsCommandRunner was vulnerable to shell command injection through unescaped shortcutIdentifier values in shell scripts. A malicious identifier like Shortcut"; rm -rf ~; echo "x" would execute arbitrary commands.

Changes

  • Replace shell script execution with direct Process invocation in ShortcutsCommandRunner.run()

    • Pass shortcutIdentifier as a separate argument array instead of interpolating into a shell string
    • Remove dependency on ScriptCommandRunner
  • Apply same fix to CommandRunner.reveal() for the shortcuts view command

Before

let source = """
shortcuts run "\(command.shortcutIdentifier)"
"""
let shellScript = ScriptCommand(...)
return try await commandRunner.run(shellScript, ...)

After

let process = Process()
process.executableURL = URL(filePath: "/usr/bin/shortcuts")
process.arguments = ["run", command.shortcutIdentifier]
try process.run()

This prevents shell interpretation of special characters in user-controlled input from configuration files.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Base automatically changed from swift/format to main January 10, 2026 13:35
Replace shell script execution with direct Process invocation, passing
shortcutIdentifier as a separate argument to prevent command injection.
This fixes the security vulnerability where malicious shortcut names
could execute arbitrary shell commands.

Co-authored-by: zenangst <[email protected]>
Copilot AI changed the title [WIP] WIP: Address feedback on code formatting in swiftformat PR Fix shell injection vulnerability in ShortcutsCommandRunner Jan 10, 2026
Copilot AI requested a review from zenangst January 10, 2026 13:41
Signed-off-by: Christoffer Winterkvist <[email protected]>
@zenangst zenangst marked this pull request as ready for review January 10, 2026 19:19
@github-actions
Copy link

Test: succeeded ✅
https://github.com/zenangst/KeyboardCowboy/actions/runs/20883160741

@Copilot

@zenangst zenangst merged commit 46422ef into main Jan 11, 2026
1 check passed
@zenangst zenangst deleted the copilot/sub-pr-690 branch January 11, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants