fix(security): prevent command injection and URL protocol bypass vulnerabilities#1028
fix(security): prevent command injection and URL protocol bypass vulnerabilities#1028Aryanpatel2001 wants to merge 3 commits intogeneralaction:mainfrom
Conversation
|
@Aryanpatel2001 is attempting to deploy a commit to the General Action Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryFixed three security vulnerabilities:
The PR correctly addresses the stated vulnerabilities with appropriate fixes. However, the security review exposed similar command injection vulnerabilities in SSH connection handling code (lines 276-320 in Confidence Score: 2/5
|
| Filename | Overview |
|---|---|
| src/main/ipc/appIpc.ts | Added URL protocol whitelist to prevent file:// and other dangerous protocols from being opened via app:openExternal |
| src/main/services/GitHubService.ts | Replaced shell echo with spawn() and stdin to prevent command injection when authenticating with GitHub token |
| src/main/ipc/githubIpc.ts | Applied quoteShellArg() to escape repository owner/name before passing to shell command |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User Input] --> B{app:openExternal}
B --> C[URL Protocol Validation]
C -->|http/https| D[shell.openExternal - SAFE]
C -->|file://, etc| E[Reject - BLOCKED]
F[GitHub Token] --> G{authenticateGHCLI}
G --> H[spawn with stdin]
H --> I[gh auth login - SAFE]
J[Repo owner/name] --> K{gh repo delete}
K --> L[quoteShellArg]
L --> M[execAsync - SAFE]
N[SSH Connection Data] --> O{app:openInEditor}
O --> P[VSCode/Cursor URL]
O --> Q[Terminal SSH Commands]
P -.->|VULNERABLE| R[Unescaped host/target]
Q -.->|VULNERABLE| S[Unescaped username/host/target]
Last reviewed commit: ee8fab5
Additional Comments (6)
|
The app:openExternal IPC handler was accepting any URL protocol, allowing access to local files via file:// and other dangerous protocols. This adds validation to only allow http: and https: protocols, preventing local file disclosure and malicious protocol
…ations
- GitHubService.ts: Replace shell echo with spawn() to pass token via stdin
This prevents command injection if token contains shell metacharacters
- githubIpc.ts: Use quoteShellArg() to escape owner/name in repo delete
This prevents command injection via crafted repository names
- Add quoteShellArg to escape SSH connection parameters - Escape username, host, port, target in Terminal/iTerm2/Warp/Ghostty - URL-encode host for VSCode/Cursor remote
ee8fab5 to
2858f94
Compare
Summary
This PR fixes three security vulnerabilities:
Changes
Testing