Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@
**Vulnerability:** The redaction regex `KV_PATTERN` failed to match and redact quoted secret values (e.g., `password="mysecret"`), potentially leaking credentials in audit logs.
**Learning:** Regular expressions for sanitizing key=value pairs must account for quoted values by explicitly including `"[^"]*"` and `'[^']*'` in the matching group.
**Prevention:** When writing regex for secrets matching, always include patterns for both quoted and unquoted strings to prevent simple bypasses.

## 2026-10-24 - Fix execa extendEnv for missing sanitizeEnvironment
**Vulnerability:** Found more instances where execa is called with `extendEnv: false` missing and process.env is exposed directly via the default extendEnv, specifically in runner capabilities and CLI auth scripts.
**Learning:** `execa` defaulting to `extendEnv: true` is a very dangerous default since we have secret env keys.
**Prevention:** Make sure all references to `execa` get `extendEnv: false` combined with `sanitizeEnvironment`.
3 changes: 3 additions & 0 deletions src/cli/authorization/non-interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
import {
getLogger,
McpConnectionManager,
sanitizeEnvironment,
} from '../../core/facades/cli-authorization-non-interactive.js';
import { isRecord } from '../../core/facades/cli-utils-serialize.js';
import { text } from '../locales/index.js';
Expand Down Expand Up @@ -101,6 +102,8 @@ export async function requestNonInteractiveAuthorizationDecision(params: {
shell: true,
timeout: timeoutMs,
reject: false,
env: sanitizeEnvironment(process.env),
extendEnv: false,
});

if (typeof res.exitCode === 'number' && res.exitCode !== 0) {
Expand Down
1 change: 1 addition & 0 deletions src/core/facades/cli-authorization-non-interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export type {
AuthorizationDecision,
ToolAuthorizationRequest,
} from '../tools/authorization/types.js';
export { sanitizeEnvironment } from '../utils/sanitizer.js';
5 changes: 4 additions & 1 deletion src/core/tools/capability/runner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { execa } from 'execa';

import { sanitizeEnvironment } from '../../utils/sanitizer.js';

import { ExecOpts, ExecResult } from './types.js';

/**
Expand All @@ -15,7 +17,8 @@ export function createControlledRunner() {
cwd: opts?.cwd,
timeout: opts?.timeoutMs,
maxBuffer: opts?.maxStdoutBytes,
env: opts?.env,
env: sanitizeEnvironment(opts?.env ? { ...process.env, ...opts.env } : process.env),
extendEnv: false,
reject: false, // Backends should handle exit codes themselves
});

Expand Down
4 changes: 3 additions & 1 deletion tests/helpers/bun-test-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ export function restoreConsoleOutputs() {

export function clearMockState() {
mock.restore();
mock.clearAllMocks();
if (typeof mock.clearAllMocks === 'function') {
mock.clearAllMocks();
}
auditTrail.clearAuditTrail();
}

Expand Down
Loading