just-bash-mcp 2.8.0 → 2.9.0

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.
package/README.md CHANGED
@@ -7,15 +7,20 @@ An MCP (Model Context Protocol) server that provides a sandboxed bash environmen
7
7
 
8
8
  Execute bash commands in a secure, isolated environment with an in-memory virtual filesystem.
9
9
 
10
- Built on top of [`just-bash`](https://github.com/vercel-labs/just-bash) v2.5.2.
10
+ Built on top of [`just-bash`](https://github.com/vercel-labs/just-bash) v2.9.6.
11
11
 
12
- ## What's New in v2.1.0
12
+ ## What's New in v2.8.0
13
13
 
14
+ - **Synced with upstream `just-bash` v2.9.6** - Latest security hardening, defense-in-depth, fuzzing, jq fixes, and large file support
15
+ - **Defense-in-depth mode** - Opt-in monkey-patching of dangerous JS globals (`JUST_BASH_DEFENSE_IN_DEPTH=true`)
16
+ - **Python support** - Python3 via Pyodide (`JUST_BASH_ENABLE_PYTHON=true`)
17
+ - **Vercel Sandbox API** - Compatible `bash_sandbox_*` tools for isolated execution
18
+ - **oxlint/oxfmt toolchain** - Replaced tsc/biome with faster oxlint and oxfmt
19
+ - **Configurable limits** - Fine-grained control over glob ops, string length, array size, heredoc size, and more
14
20
  - **`rg` (ripgrep)** - Fast regex search with `--files`, `-d`, `--stats`, `-t markdown`
15
21
  - **`tar`** - Archive support with compression
16
22
  - **MountableFS** - Mount multiple filesystems at different paths
17
23
  - **ReadWriteFS** - Direct read-write access to real directories
18
- - **Multi-level glob patterns** - Improved `**/*.ts` style matching
19
24
 
20
25
  ## Features
21
26
 
@@ -120,6 +125,16 @@ Add to your MCP settings:
120
125
  | `JUST_BASH_MAX_CALL_DEPTH` | Maximum function recursion depth | `100` |
121
126
  | `JUST_BASH_MAX_COMMAND_COUNT` | Maximum total commands per execution | `10000` |
122
127
  | `JUST_BASH_MAX_LOOP_ITERATIONS` | Maximum iterations per loop | `10000` |
128
+ | `JUST_BASH_ENABLE_PYTHON` | Enable Python3 via Pyodide (`true`/`false`) | `false` |
129
+ | `JUST_BASH_DEFENSE_IN_DEPTH` | Enable defense-in-depth mode (`true`/`false`) | `false` |
130
+ | `JUST_BASH_DEFENSE_IN_DEPTH_AUDIT` | Audit mode: log violations but don't block | `false` |
131
+ | `JUST_BASH_DEFENSE_IN_DEPTH_LOG` | Log violations to console | `false` |
132
+ | `JUST_BASH_OVERLAY_READ_ONLY` | OverlayFS read-only mode | `false` |
133
+ | `JUST_BASH_MAX_RESPONSE_SIZE` | Max network response body size (bytes) | `10485760` |
134
+ | `JUST_BASH_MAX_FILE_READ_SIZE` | Max file read size for OverlayFs/ReadWriteFs | `10485760` |
135
+ | `JUST_BASH_ALLOWED_COMMANDS` | Comma-separated command allow-list | all |
136
+ | `JUST_BASH_ENABLE_LOGGING` | Enable execution logging | `false` |
137
+ | `JUST_BASH_ENABLE_TRACING` | Enable performance tracing | `false` |
123
138
 
124
139
  ## Tools
125
140
 
@@ -149,9 +164,28 @@ Reset the persistent bash environment, clearing all files and state.
149
164
 
150
165
  File operations in the persistent environment.
151
166
 
167
+ ### `bash_direct_read` / `bash_direct_write`
168
+
169
+ Direct filesystem read/write operations (bypass shell execution).
170
+
152
171
  ### `bash_info`
153
172
 
154
- Get information about the bash environment configuration.
173
+ Get information about the bash environment configuration, including defense-in-depth violation stats.
174
+
175
+ ### `bash_get_cwd` / `bash_get_env`
176
+
177
+ Get current working directory or environment variables.
178
+
179
+ ### Vercel Sandbox API
180
+
181
+ Compatible with the Vercel Sandbox API:
182
+
183
+ - `bash_sandbox_run` - Run a command in the sandbox
184
+ - `bash_sandbox_write_files` - Write multiple files at once
185
+ - `bash_sandbox_read_file` - Read a file (supports base64 encoding)
186
+ - `bash_sandbox_mkdir` - Create a directory
187
+ - `bash_sandbox_stop` - Stop and clean up the sandbox
188
+ - `bash_sandbox_reset` - Reset the sandbox state
155
189
 
156
190
  ## Supported Commands
157
191
 
@@ -235,6 +269,26 @@ Get information about the bash environment configuration.
235
269
  - Execution limits protect against infinite loops and recursion
236
270
  - No binary/WASM execution
237
271
  - Network disabled by default; when enabled, URL and method allow-lists enforced
272
+ - **Defense-in-depth mode** (opt-in): Monkey-patches dangerous JS globals (`Function`, `eval`, `setTimeout`, `process`, etc.) during script execution to block escape vectors
273
+ - **SecurityViolationLogger**: Tracks all defense-in-depth violations with full stats accessible via `bash_info`
274
+ - **Rich network error classification**: `NetworkAccessDeniedError`, `TooManyRedirectsError`, `RedirectNotAllowedError` for precise error messages
275
+
276
+ ## Upstream API Coverage
277
+
278
+ This wrapper integrates the full public API surface of `just-bash` v2.9.6:
279
+
280
+ | Category | Exports Used |
281
+ |----------|-------------|
282
+ | Core | `Bash`, `BashOptions`, `ExecOptions`, `BashExecResult` |
283
+ | Commands | `CommandName`, `AllCommandName`, `getCommandNames`, `getNetworkCommandNames`, `getPythonCommandNames` |
284
+ | Custom Commands | `defineCommand`, `CustomCommand`, `LazyCommand` |
285
+ | Filesystem | `InMemoryFs`, `OverlayFs`, `ReadWriteFs`, `MountableFs`, `IFileSystem` |
286
+ | Network | `NetworkConfig`, `NetworkAccessDeniedError`, `TooManyRedirectsError`, `RedirectNotAllowedError` |
287
+ | Sandbox | `Sandbox`, `SandboxCommand`, `SandboxOptions`, `OutputMessage` |
288
+ | Security | `DefenseInDepthBox`, `SecurityViolationLogger`, `SecurityViolationError`, `createConsoleViolationCallback` |
289
+ | Trace | `TraceCallback`, `TraceEvent` |
290
+
291
+ All types are re-exported from `src/types.ts` for downstream consumers.
238
292
 
239
293
  ## License
240
294
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "just-bash-mcp",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "description": "MCP server providing a sandboxed bash environment using just-bash",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -65,9 +65,9 @@
65
65
  "zod": "^4.3.6"
66
66
  },
67
67
  "devDependencies": {
68
- "@types/node": "^25.2.1",
68
+ "@types/node": "^25.2.2",
69
69
  "oxfmt": "^0.28.0",
70
70
  "oxlint": "^1.43.0",
71
- "oxlint-tsgolint": "^0.11.4"
71
+ "oxlint-tsgolint": "^0.11.5"
72
72
  }
73
73
  }
@@ -7,29 +7,26 @@ import {
7
7
  type BashLogger,
8
8
  type BashOptions,
9
9
  type CommandName,
10
- InMemoryFs,
11
- MountableFs,
10
+ type DefenseInDepthConfig,
12
11
  type MountConfig,
13
12
  type NetworkConfig,
13
+ type TraceCallback,
14
+ type TraceEvent,
14
15
  OverlayFs,
15
16
  ReadWriteFs,
17
+ SecurityViolationLogger,
18
+ createConsoleViolationCallback,
16
19
  } from "just-bash";
17
20
 
21
+ // Re-export upstream types used by other modules
22
+ export type { DefenseInDepthConfig, TraceCallback, TraceEvent };
23
+
18
24
  // ============================================================================
19
25
  // Types
20
26
  // ============================================================================
21
27
 
22
28
  export type HttpMethod = "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS";
23
29
 
24
- export interface TraceEvent {
25
- category: string;
26
- name: string;
27
- durationMs: number;
28
- details?: Record<string, unknown>;
29
- }
30
-
31
- export type TraceCallback = (event: TraceEvent) => void;
32
-
33
30
  // ============================================================================
34
31
  // Environment Variable Parsing
35
32
  // ============================================================================
@@ -89,6 +86,8 @@ export interface Config {
89
86
  readonly ENABLE_TRACING: boolean;
90
87
  readonly ENABLE_PYTHON: boolean;
91
88
  readonly ENABLE_DEFENSE_IN_DEPTH: boolean;
89
+ readonly DEFENSE_IN_DEPTH_AUDIT: boolean;
90
+ readonly DEFENSE_IN_DEPTH_LOG: boolean;
92
91
  readonly OVERLAY_READ_ONLY: boolean;
93
92
  readonly ALLOWED_COMMANDS: CommandName[] | undefined;
94
93
  }
@@ -157,6 +156,8 @@ export const config: Config = {
157
156
  // Feature flags
158
157
  ENABLE_PYTHON: parseEnvBoolean("JUST_BASH_ENABLE_PYTHON", false),
159
158
  ENABLE_DEFENSE_IN_DEPTH: parseEnvBoolean("JUST_BASH_DEFENSE_IN_DEPTH", false),
159
+ DEFENSE_IN_DEPTH_AUDIT: parseEnvBoolean("JUST_BASH_DEFENSE_IN_DEPTH_AUDIT", false),
160
+ DEFENSE_IN_DEPTH_LOG: parseEnvBoolean("JUST_BASH_DEFENSE_IN_DEPTH_LOG", false),
160
161
  OVERLAY_READ_ONLY: parseEnvBoolean("JUST_BASH_OVERLAY_READ_ONLY", false),
161
162
 
162
163
  // Command filtering
@@ -199,6 +200,39 @@ export const traceCallback: TraceCallback | undefined = config.ENABLE_TRACING
199
200
  }
200
201
  : undefined;
201
202
 
203
+ // ============================================================================
204
+ // Defense-in-Depth Configuration
205
+ // ============================================================================
206
+
207
+ /**
208
+ * Shared SecurityViolationLogger instance for tracking violations across
209
+ * all Bash instances. Exposed so info-tools can report violation stats.
210
+ */
211
+ export const violationLogger = new SecurityViolationLogger();
212
+
213
+ /**
214
+ * Build the defense-in-depth configuration from environment variables.
215
+ * Returns `false` when disabled, or a full DefenseInDepthConfig object.
216
+ */
217
+ export function buildDefenseInDepthConfig(): DefenseInDepthConfig | false {
218
+ if (!config.ENABLE_DEFENSE_IN_DEPTH) {
219
+ return false;
220
+ }
221
+
222
+ const consoleCallback = config.DEFENSE_IN_DEPTH_LOG
223
+ ? createConsoleViolationCallback()
224
+ : undefined;
225
+
226
+ return {
227
+ enabled: true,
228
+ auditMode: config.DEFENSE_IN_DEPTH_AUDIT,
229
+ onViolation: (violation) => {
230
+ violationLogger.record(violation);
231
+ consoleCallback?.(violation);
232
+ },
233
+ };
234
+ }
235
+
202
236
  // ============================================================================
203
237
  // Configuration Builders
204
238
  // ============================================================================
@@ -315,6 +349,10 @@ export const ENVIRONMENT_VARIABLES = {
315
349
  JUST_BASH_ENABLE_PYTHON: "Enable python3/python commands via Pyodide (default: false)",
316
350
  JUST_BASH_DEFENSE_IN_DEPTH:
317
351
  "Enable defense-in-depth mode that patches dangerous JS globals (default: false)",
352
+ JUST_BASH_DEFENSE_IN_DEPTH_AUDIT:
353
+ "Audit mode: log violations but don't block them (default: false, requires DEFENSE_IN_DEPTH=true)",
354
+ JUST_BASH_DEFENSE_IN_DEPTH_LOG:
355
+ "Log violations to console via createConsoleViolationCallback (default: false)",
318
356
  } as const;
319
357
 
320
358
  // ============================================================================
@@ -340,19 +378,25 @@ export const COMMAND_CATEGORIES = {
340
378
  // ============================================================================
341
379
 
342
380
  export const FEATURES = {
343
- customCommands: "Define custom TypeScript commands using defineCommand()",
381
+ customCommands:
382
+ "Define custom TypeScript commands using defineCommand() from just-bash, supports lazy-loading via LazyCommand",
344
383
  rawScript: "Preserve leading whitespace in scripts (useful for here-docs)",
345
384
  logger: "Optional execution logging via BashLogger interface",
346
- trace: "Performance profiling via TraceCallback",
385
+ trace: "Performance profiling via TraceCallback (upstream type)",
347
386
  commandFilter: "Restrict available commands via JUST_BASH_ALLOWED_COMMANDS env var",
348
- sandboxApi: "Vercel Sandbox compatible API via bash_sandbox_* tools",
387
+ sandboxApi:
388
+ "Vercel Sandbox compatible API via bash_sandbox_* tools (run, write, read, mkdir, stop, reset)",
349
389
  python: "Python support via Pyodide (opt-in via JUST_BASH_ENABLE_PYTHON=true)",
350
390
  defenseInDepth:
351
- "Defense-in-depth mode that monkey-patches dangerous JS globals during execution (opt-in via JUST_BASH_DEFENSE_IN_DEPTH=true)",
391
+ "Defense-in-depth with SecurityViolationLogger, audit mode, and console logging (opt-in via JUST_BASH_DEFENSE_IN_DEPTH=true)",
352
392
  overlayReadOnly:
353
393
  "Read-only overlay filesystem mode (opt-in via JUST_BASH_OVERLAY_READ_ONLY=true)",
354
394
  networkResponseSize:
355
395
  "Configurable max network response body size via JUST_BASH_MAX_RESPONSE_SIZE",
356
396
  fileReadSizeLimit:
357
397
  "Configurable max file read size for OverlayFs/ReadWriteFs via JUST_BASH_MAX_FILE_READ_SIZE",
398
+ networkErrorHandling:
399
+ "Rich network error classification: NetworkAccessDeniedError, TooManyRedirectsError, RedirectNotAllowedError",
400
+ securityViolationTracking:
401
+ "SecurityViolationLogger tracks all defense-in-depth violations with stats via bash_info",
358
402
  } as const;
package/src/index.ts CHANGED
File without changes