@plumpslabs/kuma 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +60 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2057,6 +2057,24 @@ function truncateOutput(output, maxChars) {
2057
2057
  }
2058
2058
 
2059
2059
  // src/tools/safeTerminalExec.ts
2060
+ function stripShellObfuscation(cmd) {
2061
+ let result = cmd;
2062
+ let prev;
2063
+ do {
2064
+ prev = result;
2065
+ result = result.replace(/\$\([^()]*\)/g, "");
2066
+ } while (result !== prev);
2067
+ do {
2068
+ prev = result;
2069
+ result = result.replace(/\$\(\([^()]*\)\)/g, "");
2070
+ } while (result !== prev);
2071
+ result = result.replace(/\$\{[^}]*\}/g, " ");
2072
+ result = result.replace(/\$'[^']*'/g, "");
2073
+ result = result.replace(/\$"[^"]*"/g, "");
2074
+ result = result.replace(/\$[a-zA-Z_][a-zA-Z0-9_]*/g, " ");
2075
+ result = result.replace(/\s+/g, " ").trim();
2076
+ return result;
2077
+ }
2060
2078
  function buildTaskCommand(task, cwd) {
2061
2079
  const pm = detectPackageManagerForDir(cwd);
2062
2080
  const prefix = pm === "pnpm" ? "pnpm" : pm === "yarn" ? "yarn" : pm === "bun" ? "bun" : "npm";
@@ -2075,24 +2093,59 @@ function buildTaskCommand(task, cwd) {
2075
2093
  }
2076
2094
  }
2077
2095
  var DANGEROUS_PATTERNS = [
2096
+ // RM variants
2078
2097
  "rm -rf",
2079
2098
  "rm -fr",
2099
+ "rm --recursive",
2100
+ "rm --force",
2080
2101
  "del /f",
2081
2102
  "rd /s",
2082
2103
  "rmdir /s",
2104
+ // Git dangerous
2083
2105
  "git push",
2084
2106
  "git commit",
2107
+ "git reset --hard",
2108
+ "git clean -fd",
2109
+ "git checkout -- .",
2110
+ // Publish to registries
2085
2111
  "npm publish",
2086
2112
  "npx publish",
2087
2113
  "yarn publish",
2088
2114
  "pnpm publish",
2115
+ // System destruction
2089
2116
  "> /dev/sda",
2090
- "format",
2091
2117
  "mkfs",
2092
2118
  "dd if=",
2119
+ "dd of=",
2120
+ "fdisk",
2121
+ "parted",
2122
+ "mkswap",
2123
+ // Fork bomb
2093
2124
  ":(){ :|:& };:",
2094
- "curl ",
2095
- "wget "
2125
+ ":(){",
2126
+ // Pipe to shell (remote code execution vector)
2127
+ "| bash",
2128
+ "| sh",
2129
+ // Dangerous eval/exec
2130
+ "eval ",
2131
+ "exec ",
2132
+ "source /dev/stdin",
2133
+ ". /dev/stdin",
2134
+ // Find destruction
2135
+ "find . -delete",
2136
+ "find / -delete",
2137
+ "find . -exec rm",
2138
+ "find / -exec rm",
2139
+ // Chmod abuse
2140
+ "chmod -R 777",
2141
+ "chmod 777 /",
2142
+ "chmod 000",
2143
+ // Alias hijacking
2144
+ "alias rm=",
2145
+ "alias cd=",
2146
+ "alias sudo=",
2147
+ // Overwrite protection
2148
+ "shred"
2096
2149
  ];
2097
2150
  async function handleSafeTerminalExec(params) {
2098
2151
  const { task, customCommand, timeout = 60, cwd: inputCwd, workspace } = params;
@@ -2134,7 +2187,10 @@ Available workspaces: ${workspaces?.map((w) => `"${w.name}" (${w.path})`).join("
2134
2187
 
2135
2188
  Fix the code first before running the task again.`;
2136
2189
  }
2137
- const dangerousPattern = DANGEROUS_PATTERNS.find((p) => command.toLowerCase().includes(p.toLowerCase()));
2190
+ const deobfuscated = stripShellObfuscation(command);
2191
+ const dangerousPattern = DANGEROUS_PATTERNS.find(
2192
+ (p) => deobfuscated.toLowerCase().includes(p.toLowerCase())
2193
+ );
2138
2194
  if (dangerousPattern) {
2139
2195
  return `\u{1F6AB} BLOCKED: Command contains a dangerous pattern: "${dangerousPattern}".
2140
2196
  This command is not permitted.`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumpslabs/kuma",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Zero-setup safety toolkit for AI coding agents. MCP server with code review, git analysis, file editing, session memory, and static analysis — works with Claude Code, Cursor, Gemini CLI.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",