@sysid/sandbox-runtime-improved 0.0.56-sysid.1 → 0.0.64-sysid.1

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 (129) hide show
  1. package/README.md +106 -4
  2. package/dist/cli.js +12 -18
  3. package/dist/cli.js.map +1 -1
  4. package/dist/index.d.ts +5 -5
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +2 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/sandbox/credential-mask-files.d.ts +157 -0
  9. package/dist/sandbox/credential-mask-files.d.ts.map +1 -0
  10. package/dist/sandbox/credential-mask-files.js +298 -0
  11. package/dist/sandbox/credential-mask-files.js.map +1 -0
  12. package/dist/sandbox/credential-sentinel.d.ts +72 -0
  13. package/dist/sandbox/credential-sentinel.d.ts.map +1 -0
  14. package/dist/sandbox/credential-sentinel.js +130 -0
  15. package/dist/sandbox/credential-sentinel.js.map +1 -0
  16. package/dist/sandbox/domain-pattern.d.ts +36 -0
  17. package/dist/sandbox/domain-pattern.d.ts.map +1 -0
  18. package/dist/sandbox/domain-pattern.js +60 -0
  19. package/dist/sandbox/domain-pattern.js.map +1 -0
  20. package/dist/sandbox/http-proxy.d.ts +33 -2
  21. package/dist/sandbox/http-proxy.d.ts.map +1 -1
  22. package/dist/sandbox/http-proxy.js +30 -2
  23. package/dist/sandbox/http-proxy.js.map +1 -1
  24. package/dist/sandbox/linux-sandbox-utils.d.ts +20 -0
  25. package/dist/sandbox/linux-sandbox-utils.d.ts.map +1 -1
  26. package/dist/sandbox/linux-sandbox-utils.js +134 -65
  27. package/dist/sandbox/linux-sandbox-utils.js.map +1 -1
  28. package/dist/sandbox/linux-violation-monitor.d.ts +48 -0
  29. package/dist/sandbox/linux-violation-monitor.d.ts.map +1 -0
  30. package/dist/sandbox/linux-violation-monitor.js +156 -0
  31. package/dist/sandbox/linux-violation-monitor.js.map +1 -0
  32. package/dist/sandbox/listen-in-range.d.ts +12 -0
  33. package/dist/sandbox/listen-in-range.d.ts.map +1 -0
  34. package/dist/sandbox/listen-in-range.js +43 -0
  35. package/dist/sandbox/listen-in-range.js.map +1 -0
  36. package/dist/sandbox/macos-sandbox-utils.d.ts +11 -0
  37. package/dist/sandbox/macos-sandbox-utils.d.ts.map +1 -1
  38. package/dist/sandbox/macos-sandbox-utils.js +72 -17
  39. package/dist/sandbox/macos-sandbox-utils.js.map +1 -1
  40. package/dist/sandbox/mitm-ca.d.ts +69 -2
  41. package/dist/sandbox/mitm-ca.d.ts.map +1 -1
  42. package/dist/sandbox/mitm-ca.js +188 -16
  43. package/dist/sandbox/mitm-ca.js.map +1 -1
  44. package/dist/sandbox/mitm-leaf.d.ts +1 -1
  45. package/dist/sandbox/mitm-leaf.d.ts.map +1 -1
  46. package/dist/sandbox/mitm-leaf.js +26 -19
  47. package/dist/sandbox/mitm-leaf.js.map +1 -1
  48. package/dist/sandbox/mux-proxy.d.ts +59 -0
  49. package/dist/sandbox/mux-proxy.d.ts.map +1 -0
  50. package/dist/sandbox/mux-proxy.js +159 -0
  51. package/dist/sandbox/mux-proxy.js.map +1 -0
  52. package/dist/sandbox/request-filter.d.ts +11 -1
  53. package/dist/sandbox/request-filter.d.ts.map +1 -1
  54. package/dist/sandbox/request-filter.js.map +1 -1
  55. package/dist/sandbox/sandbox-config.d.ts +461 -41
  56. package/dist/sandbox/sandbox-config.d.ts.map +1 -1
  57. package/dist/sandbox/sandbox-config.js +342 -26
  58. package/dist/sandbox/sandbox-config.js.map +1 -1
  59. package/dist/sandbox/sandbox-manager.d.ts +5 -1
  60. package/dist/sandbox/sandbox-manager.d.ts.map +1 -1
  61. package/dist/sandbox/sandbox-manager.js +697 -211
  62. package/dist/sandbox/sandbox-manager.js.map +1 -1
  63. package/dist/sandbox/sandbox-schemas.d.ts +15 -0
  64. package/dist/sandbox/sandbox-schemas.d.ts.map +1 -1
  65. package/dist/sandbox/sandbox-utils.d.ts +55 -6
  66. package/dist/sandbox/sandbox-utils.d.ts.map +1 -1
  67. package/dist/sandbox/sandbox-utils.js +143 -30
  68. package/dist/sandbox/sandbox-utils.js.map +1 -1
  69. package/dist/sandbox/socks-proxy.d.ts +11 -5
  70. package/dist/sandbox/socks-proxy.d.ts.map +1 -1
  71. package/dist/sandbox/socks-proxy.js +13 -81
  72. package/dist/sandbox/socks-proxy.js.map +1 -1
  73. package/dist/sandbox/tls-terminate-proxy.d.ts +2 -2
  74. package/dist/sandbox/tls-terminate-proxy.d.ts.map +1 -1
  75. package/dist/sandbox/tls-terminate-proxy.js +31 -5
  76. package/dist/sandbox/tls-terminate-proxy.js.map +1 -1
  77. package/dist/sandbox/windows-sandbox-utils.d.ts +508 -116
  78. package/dist/sandbox/windows-sandbox-utils.d.ts.map +1 -1
  79. package/dist/sandbox/windows-sandbox-utils.js +721 -209
  80. package/dist/sandbox/windows-sandbox-utils.js.map +1 -1
  81. package/dist/utils/shell-quote.d.ts +27 -0
  82. package/dist/utils/shell-quote.d.ts.map +1 -0
  83. package/dist/utils/shell-quote.js +47 -0
  84. package/dist/utils/shell-quote.js.map +1 -0
  85. package/package.json +7 -6
  86. package/vendor/seccomp/arm64/apply-seccomp +0 -0
  87. package/vendor/seccomp/build.ts +8 -30
  88. package/vendor/seccomp/x64/apply-seccomp +0 -0
  89. package/vendor/srt-win/build.ts +21 -0
  90. package/dist/vendor/seccomp/Dockerfile.build +0 -6
  91. package/dist/vendor/seccomp/arm64/apply-seccomp +0 -0
  92. package/dist/vendor/seccomp/build.ts +0 -91
  93. package/dist/vendor/seccomp/x64/apply-seccomp +0 -0
  94. package/dist/vendor/seccomp-src/apply-seccomp.c +0 -280
  95. package/dist/vendor/seccomp-src/seccomp-unix-block.c +0 -148
  96. package/dist/vendor/srt-win/Cargo.lock +0 -361
  97. package/dist/vendor/srt-win/Cargo.toml +0 -46
  98. package/dist/vendor/srt-win/ci/cleanup.ps1 +0 -49
  99. package/dist/vendor/srt-win/ci/smoke-exec.ps1 +0 -446
  100. package/dist/vendor/srt-win/ci/smoke.ps1 +0 -307
  101. package/dist/vendor/srt-win/src/job.rs +0 -102
  102. package/dist/vendor/srt-win/src/launch.rs +0 -732
  103. package/dist/vendor/srt-win/src/lib.rs +0 -20
  104. package/dist/vendor/srt-win/src/main.rs +0 -669
  105. package/dist/vendor/srt-win/src/self_protect.rs +0 -169
  106. package/dist/vendor/srt-win/src/sid.rs +0 -296
  107. package/dist/vendor/srt-win/src/token.rs +0 -341
  108. package/dist/vendor/srt-win/src/util.rs +0 -42
  109. package/dist/vendor/srt-win/src/wfp.rs +0 -992
  110. package/dist/vendor/srt-win/src/winsta.rs +0 -209
  111. package/dist/vendor/srt-win/tests/sd_access_check_matrix.rs +0 -259
  112. package/vendor/seccomp-src/apply-seccomp.c +0 -280
  113. package/vendor/seccomp-src/seccomp-unix-block.c +0 -148
  114. package/vendor/srt-win/Cargo.lock +0 -361
  115. package/vendor/srt-win/Cargo.toml +0 -46
  116. package/vendor/srt-win/ci/cleanup.ps1 +0 -49
  117. package/vendor/srt-win/ci/smoke-exec.ps1 +0 -446
  118. package/vendor/srt-win/ci/smoke.ps1 +0 -307
  119. package/vendor/srt-win/src/job.rs +0 -102
  120. package/vendor/srt-win/src/launch.rs +0 -732
  121. package/vendor/srt-win/src/lib.rs +0 -20
  122. package/vendor/srt-win/src/main.rs +0 -669
  123. package/vendor/srt-win/src/self_protect.rs +0 -169
  124. package/vendor/srt-win/src/sid.rs +0 -296
  125. package/vendor/srt-win/src/token.rs +0 -341
  126. package/vendor/srt-win/src/util.rs +0 -42
  127. package/vendor/srt-win/src/wfp.rs +0 -992
  128. package/vendor/srt-win/src/winsta.rs +0 -209
  129. package/vendor/srt-win/tests/sd_access_check_matrix.rs +0 -259
@@ -1,8 +1,8 @@
1
1
  import type { Socket } from 'node:net';
2
2
  import type { Duplex } from 'node:stream';
3
3
  import type { Server } from 'node:http';
4
- import type { MitmCA } from './mitm-ca.js';
5
- import { type FilterRequestCallback } from './request-filter.js';
4
+ import { type MitmCA } from './mitm-ca.js';
5
+ import { type FilterRequestCallback, type MutateForwardedHeaders } from './request-filter.js';
6
6
  import type { ResolvedParentProxy } from './parent-proxy.js';
7
7
  export interface HttpProxyServerOptions {
8
8
  filter(port: number, host: string, socket: Socket | Duplex): Promise<boolean> | boolean;
@@ -19,11 +19,42 @@ export interface HttpProxyServerOptions {
19
19
  * config layer (sandbox-manager rejects both being set).
20
20
  */
21
21
  mitmCA?: MitmCA;
22
+ /**
23
+ * Per-host opt-out of TLS termination; consulted only when `mitmCA` is
24
+ * set. Return false to leave that CONNECT as an opaque byte tunnel
25
+ * (still hostname-allowlisted via `filter`, but not content-inspected —
26
+ * the same posture as the non-tlsTerminate path), so the sandboxed
27
+ * client performs its own TLS handshake end-to-end with the upstream.
28
+ *
29
+ * Use for upstreams the proxy must not re-originate: mTLS services
30
+ * (only the in-sandbox client holds the client certificate) and
31
+ * certificate-pinning clients that reject the MITM CA. Note that
32
+ * `filterRequest` and `mutateHeaders` never see the HTTPS traffic to
33
+ * these hosts; plain-HTTP proxy requests to them are unaffected (those
34
+ * are readable without termination and keep the normal request pipeline).
35
+ *
36
+ * Absent, or returning true, means today's behaviour: terminate.
37
+ */
38
+ shouldTerminateTLS?(hostname: string, port: number): boolean;
22
39
  /**
23
40
  * Per-request filter; runs on plain-HTTP proxy requests and on terminated
24
41
  * HTTPS requests. See request-filter.ts.
25
42
  */
26
43
  filterRequest?: FilterRequestCallback;
44
+ /**
45
+ * Mutate forwarded headers on the TLS-terminated path, after the allow
46
+ * decision and before the upstream request is built. The upstream leg is
47
+ * always cert-verified (rejectUnauthorized defaults to true), so the TLS
48
+ * handshake fails before any mutated header bytes reach an unverified
49
+ * server. See {@link MutateForwardedHeaders}.
50
+ */
51
+ mutateHeaders?: MutateForwardedHeaders;
52
+ /**
53
+ * Mutate forwarded headers on the plain-HTTP path. Separate from
54
+ * `mutateHeaders` so callers can wire the TLS path only — credential
55
+ * injection over plaintext is opt-in.
56
+ */
57
+ mutateHeadersPlaintext?: MutateForwardedHeaders;
27
58
  /**
28
59
  * Additional trusted CA(s) for the terminating proxy's outbound TLS leg.
29
60
  * Unset → system roots + NODE_EXTRA_CA_CERTS. Primarily a test seam.
@@ -1 +1 @@
1
- {"version":3,"file":"http-proxy.d.ts","sourceRoot":"","sources":["../../src/sandbox/http-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAE,MAAM,EAAY,MAAM,aAAa,CAAA;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAOvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAA;AAK5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAY5D,MAAM,WAAW,sBAAsB;IACrC,MAAM,CACJ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,MAAM,GACtB,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAA;IAE7B;;;;OAIG;IACH,iBAAiB,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IAEpD;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;OAGG;IACH,aAAa,CAAC,EAAE,qBAAqB,CAAA;IAErC;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAA;IAEjE;;;;OAIG;IACH,WAAW,CAAC,EAAE,mBAAmB,CAAA;IAEjC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CA8T7E"}
1
+ {"version":3,"file":"http-proxy.d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AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CA+V7E"}
@@ -4,6 +4,7 @@ import { request as httpsRequest } from 'node:https';
4
4
  import { connect } from 'node:net';
5
5
  import { URL } from 'node:url';
6
6
  import { logForDebugging } from '../utils/debug.js';
7
+ import { CRL_PATH } from './mitm-ca.js';
7
8
  import { decideAndRespond, } from './request-filter.js';
8
9
  import { peekForClientHello, terminateAndForward, } from './tls-terminate-proxy.js';
9
10
  import { connectViaParentProxy, dialDirect, openConnectTunnel, proxyAuthHeader, selectParentProxyUrl, shouldBypassParentProxy, stripBrackets, stripHopByHop, } from './parent-proxy.js';
@@ -65,7 +66,8 @@ export function createHttpProxyServer(options) {
65
66
  // (tlsTerminate and mitmProxy are mutually exclusive at the config
66
67
  // layer, so the first two never both apply.)
67
68
  let wrote200 = false;
68
- if (options.mitmCA) {
69
+ if (options.mitmCA &&
70
+ (options.shouldTerminateTLS?.(hostname, port) ?? true)) {
69
71
  if (clientGone)
70
72
  return;
71
73
  // We can only terminate TLS. CONNECT also carries non-TLS streams —
@@ -81,12 +83,18 @@ export function createHttpProxyServer(options) {
81
83
  if (clientGone)
82
84
  return;
83
85
  if (peeked.isTLS) {
84
- terminateAndForward(options.mitmCA, options.filterRequest, socket, peeked.head, { hostname, port, upstreamCA: options.tlsTerminateUpstreamCA });
86
+ terminateAndForward(options.mitmCA, options.filterRequest, options.mutateHeaders, socket, peeked.head, { hostname, port, upstreamCA: options.tlsTerminateUpstreamCA });
85
87
  return;
86
88
  }
87
89
  logForDebugging(`[tls-terminate] non-TLS bytes on CONNECT ${hostname}:${port}; opaque-tunnelling`);
88
90
  head = peeked.head;
89
91
  }
92
+ else if (options.mitmCA) {
93
+ // Per-host termination opt-out: the policy exempts this host (mTLS
94
+ // upstream, cert-pinning client), so skip the MITM entirely and
95
+ // take the opaque tunnel below, exactly as if mitmCA were unset.
96
+ logForDebugging(`[tls-terminate] policy exempts ${hostname}:${port}; opaque-tunnelling`);
97
+ }
90
98
  const mitmSocketPath = options.getMitmSocketPath?.(hostname);
91
99
  const parentUrl = !mitmSocketPath &&
92
100
  options.parentProxy &&
@@ -155,6 +163,25 @@ export function createHttpProxyServer(options) {
155
163
  // Handle regular HTTP requests
156
164
  server.on('request', async (req, res) => {
157
165
  try {
166
+ // Serve the empty CRL for Schannel's revocation check on MITM-minted
167
+ // leaves (see MitmCA.crlDer). CryptoAPI fetches the leaf's
168
+ // cRLDistributionPoints URL over plain HTTP with no
169
+ // Proxy-Authorization, so this must precede both the auth check and
170
+ // the `new URL(req.url)` parse below (which requires absolute-form).
171
+ // Match on pathname so both origin-form (`GET /srt.crl`, what
172
+ // CryptoAPI sends) and absolute-form (`GET http://…/srt.crl`, what a
173
+ // proxy-aware fetcher would send) resolve; the base is ignored for
174
+ // the absolute case.
175
+ if (options.mitmCA &&
176
+ req.method === 'GET' &&
177
+ new URL(req.url ?? '', 'http://x').pathname === CRL_PATH) {
178
+ res.writeHead(200, {
179
+ 'Content-Type': 'application/pkix-crl',
180
+ 'Content-Length': options.mitmCA.crlDer.length,
181
+ });
182
+ res.end(options.mitmCA.crlDer);
183
+ return;
184
+ }
158
185
  if (!checkAuth(req.headers['proxy-authorization'])) {
159
186
  res.writeHead(407, { 'Proxy-Authenticate': 'Basic realm="srt"' });
160
187
  res.end();
@@ -184,6 +211,7 @@ export function createHttpProxyServer(options) {
184
211
  if (req.socket.destroyed)
185
212
  return;
186
213
  const fwdHeaders = { ...stripHopByHop(req.headers), host: url.host };
214
+ options.mutateHeadersPlaintext?.(fwdHeaders, hostname);
187
215
  // Decide upstream route: MITM unix socket > parent HTTP proxy > direct.
188
216
  const mitmSocketPath = options.getMitmSocketPath?.(hostname);
189
217
  const parentUrl = !mitmSocketPath &&
@@ -1 +1 @@
1
- {"version":3,"file":"http-proxy.js","sourceRoot":"","sources":["../../src/sandbox/http-proxy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,W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AAC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,KAAK;QAAE,OAAO,SAAS,CAAA;IACzE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,IAAI,EAAE,CAAA;AAClC,CAAC"}
@@ -24,6 +24,21 @@ export interface LinuxSandboxParams {
24
24
  writeConfig?: FsWriteRestrictionConfig;
25
25
  /** Environment variable names to unset inside the sandbox (bwrap --unsetenv) */
26
26
  unsetEnvVars?: string[];
27
+ /** Environment variables to set inside the sandbox (bwrap --setenv NAME VALUE) */
28
+ setEnvVars?: Record<string, string>;
29
+ /**
30
+ * Whole-file credential masks: bind fakePath (sentinel content) over
31
+ * realPath read-only so the sandbox reads the sentinel.
32
+ */
33
+ maskedFileBinds?: Array<{
34
+ realPath: string;
35
+ fakePath: string;
36
+ }>;
37
+ /**
38
+ * Host directory holding the fake files. Ro-bound over itself so the
39
+ * sandbox cannot write the bind sources even if allowWrite covers it.
40
+ */
41
+ maskedFileStoreDir?: string;
27
42
  enableWeakerNestedSandbox?: boolean;
28
43
  allowAllUnixSockets?: boolean;
29
44
  binShell?: string;
@@ -41,6 +56,11 @@ export interface LinuxSandboxParams {
41
56
  bwrapPath?: string;
42
57
  /** Absolute path to the socat binary (default: resolve "socat" via PATH) */
43
58
  socatPath?: string;
59
+ /** Filesystem unix socket bound by the Linux violation monitor. When set,
60
+ * the socket is bind-mounted into the sandbox and apply-seccomp is told
61
+ * (via SRT_OBSERVE_SOCK) to install a USER_NOTIF observation filter and
62
+ * stream observed write-intent paths over that socket as newline JSON. */
63
+ observeSocketPath?: string;
44
64
  /** Abort signal to cancel the ripgrep scan */
45
65
  abortSignal?: AbortSignal;
46
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"linux-sandbox-utils.d.ts","sourceRoot":"","sources":["../../src/sandbox/linux-sandbox-utils.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAYtD,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,EAAE,sBAAsB,GAC5B,qBAAqB,CAWvB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,CAAC,EAAE,sBAAsB,GAC5B,sBAAsB,CA6BxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,4BAA4B,CAChD,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,yBAAyB,CAAC,CAmJpC;AAyhBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,MAAM,CAAC,CAuSjB"}
@@ -1,4 +1,4 @@
1
- import shellquote from 'shell-quote';
1
+ import { quote } from '../utils/shell-quote.js';
2
2
  import { logForDebugging } from '../utils/debug.js';
3
3
  import { whichSync } from '../utils/which.js';
4
4
  import { randomBytes } from 'node:crypto';
@@ -7,7 +7,7 @@ import { spawn } from 'node:child_process';
7
7
  import { tmpdir } from 'node:os';
8
8
  import path, { join } from 'node:path';
9
9
  import { ripGrep } from '../utils/ripgrep.js';
10
- import { generateProxyEnvVars, normalizePathForSandbox, normalizeCaseForComparison, isSymlinkOutsideBoundary, DANGEROUS_FILES, getDangerousDirectories, } from './sandbox-utils.js';
10
+ import { generateProxyEnvVars, normalizePathForSandbox, normalizeCaseForComparison, isSymlinkOutsideBoundary, encodeSandboxedCommand, DANGEROUS_FILES, getDangerousDirectories, } from './sandbox-utils.js';
11
11
  import { getApplySeccompBinaryPath } from './generate-seccomp-filter.js';
12
12
  /** Default max depth for searching dangerous files */
13
13
  const DEFAULT_MANDATORY_DENY_SEARCH_DEPTH = 3;
@@ -365,6 +365,8 @@ export async function initializeLinuxNetworkBridge(httpProxyPort, socksProxyPort
365
365
  const socat = socatPath ?? 'socat';
366
366
  const socketId = randomBytes(8).toString('hex');
367
367
  const httpSocketPath = join(tmpdir(), `claude-http-${socketId}.sock`);
368
+ // Only allocated when ports differ; in the mux case the SOCKS side
369
+ // reuses httpSocketPath.
368
370
  const socksSocketPath = join(tmpdir(), `claude-socks-${socketId}.sock`);
369
371
  // Start HTTP bridge
370
372
  const httpSocatArgs = [
@@ -390,34 +392,48 @@ export async function initializeLinuxNetworkBridge(httpProxyPort, socksProxyPort
390
392
  if (!httpBridgeProcess.pid) {
391
393
  throw new Error('Failed to start HTTP bridge process');
392
394
  }
393
- // Start SOCKS bridge
394
- const socksSocatArgs = [
395
- `UNIX-LISTEN:${socksSocketPath},fork,reuseaddr`,
396
- `TCP:localhost:${socksProxyPort},keepalive,keepidle=10,keepintvl=5,keepcnt=3`,
397
- ];
398
- logForDebugging(`Starting SOCKS bridge: ${socat} ${socksSocatArgs.join(' ')}`);
399
- const socksBridgeProcess = spawn(socat, socksSocatArgs, {
400
- stdio: 'ignore',
401
- });
402
- // Add error and exit handlers to monitor bridge health — registered
403
- // before the !pid check for the same reason as the HTTP bridge above.
404
- socksBridgeProcess.on('error', err => {
405
- logForDebugging(`SOCKS bridge process error: ${err}`, { level: 'error' });
406
- });
407
- socksBridgeProcess.on('exit', (code, signal) => {
408
- logForDebugging(`SOCKS bridge process exited with code ${code}, signal ${signal}`, { level: code === 0 ? 'info' : 'error' });
409
- });
410
- if (!socksBridgeProcess.pid) {
411
- // Clean up HTTP bridge
412
- if (httpBridgeProcess.pid) {
413
- try {
414
- process.kill(httpBridgeProcess.pid, 'SIGTERM');
415
- }
416
- catch {
417
- // Ignore errors
395
+ // SOCKS bridge: when the host serves both protocols on one port (the mux),
396
+ // a second socat to the same TCP target is redundant — reuse the HTTP
397
+ // bridge's process and socket path. Downstream consumers
398
+ // (LinuxNetworkBridgeContext, in-sandbox socat, cleanup) treat duplicate
399
+ // refs idempotently. A separate bridge is only spawned when the ports
400
+ // differ (external proxy override).
401
+ let socksBridgeProcess;
402
+ let socksSockPath;
403
+ if (socksProxyPort === httpProxyPort) {
404
+ socksBridgeProcess = httpBridgeProcess;
405
+ socksSockPath = httpSocketPath;
406
+ }
407
+ else {
408
+ socksSockPath = socksSocketPath;
409
+ const socksSocatArgs = [
410
+ `UNIX-LISTEN:${socksSocketPath},fork,reuseaddr`,
411
+ `TCP:localhost:${socksProxyPort},keepalive,keepidle=10,keepintvl=5,keepcnt=3`,
412
+ ];
413
+ logForDebugging(`Starting SOCKS bridge: ${socat} ${socksSocatArgs.join(' ')}`);
414
+ socksBridgeProcess = spawn(socat, socksSocatArgs, {
415
+ stdio: 'ignore',
416
+ });
417
+ // Add error and exit handlers to monitor bridge health — registered
418
+ // before the !pid check for the same reason as the HTTP bridge above.
419
+ socksBridgeProcess.on('error', err => {
420
+ logForDebugging(`SOCKS bridge process error: ${err}`, { level: 'error' });
421
+ });
422
+ socksBridgeProcess.on('exit', (code, signal) => {
423
+ logForDebugging(`SOCKS bridge process exited with code ${code}, signal ${signal}`, { level: code === 0 ? 'info' : 'error' });
424
+ });
425
+ if (!socksBridgeProcess.pid) {
426
+ // Clean up HTTP bridge
427
+ if (httpBridgeProcess.pid) {
428
+ try {
429
+ process.kill(httpBridgeProcess.pid, 'SIGTERM');
430
+ }
431
+ catch {
432
+ // Ignore errors
433
+ }
418
434
  }
435
+ throw new Error('Failed to start SOCKS bridge process');
419
436
  }
420
- throw new Error('Failed to start SOCKS bridge process');
421
437
  }
422
438
  // Wait for both sockets to be ready
423
439
  const maxAttempts = 5;
@@ -430,7 +446,7 @@ export async function initializeLinuxNetworkBridge(httpProxyPort, socksProxyPort
430
446
  }
431
447
  try {
432
448
  // fs already imported
433
- if (fs.existsSync(httpSocketPath) && fs.existsSync(socksSocketPath)) {
449
+ if (fs.existsSync(httpSocketPath) && fs.existsSync(socksSockPath)) {
434
450
  logForDebugging(`Linux bridges ready after ${i + 1} attempts`);
435
451
  break;
436
452
  }
@@ -464,7 +480,7 @@ export async function initializeLinuxNetworkBridge(httpProxyPort, socksProxyPort
464
480
  }
465
481
  return {
466
482
  httpSocketPath,
467
- socksSocketPath,
483
+ socksSocketPath: socksSockPath,
468
484
  httpBridgeProcess,
469
485
  socksBridgeProcess,
470
486
  httpProxyPort,
@@ -476,7 +492,7 @@ export async function initializeLinuxNetworkBridge(httpProxyPort, socksProxyPort
476
492
  * multicall-binary prefix that dispatches on the ARGV0 env var.
477
493
  *
478
494
  * Returns a shell-ready string ending in a trailing space — callers append
479
- * shellquote.quote([shell, '-c', cmd]). Returns undefined when seccomp is
495
+ * quote([shell, '-c', cmd]). Returns undefined when seccomp is
480
496
  * unavailable (no argv0, no binary found).
481
497
  *
482
498
  * When argv0 is set, applyPath is used verbatim (no existence check); the
@@ -487,10 +503,10 @@ function resolveApplySeccompPrefix(applyPath, argv0) {
487
503
  if (!applyPath) {
488
504
  throw new Error('seccompConfig.argv0 requires seccompConfig.applyPath');
489
505
  }
490
- return `ARGV0=${shellquote.quote([argv0])} ${shellquote.quote([applyPath])} `;
506
+ return `ARGV0=${quote([argv0])} ${quote([applyPath])} `;
491
507
  }
492
508
  const binary = getApplySeccompBinaryPath(applyPath);
493
- return binary ? `${shellquote.quote([binary])} ` : undefined;
509
+ return binary ? `${quote([binary])} ` : undefined;
494
510
  }
495
511
  /**
496
512
  * Build the command that runs inside the sandbox.
@@ -501,7 +517,7 @@ function buildSandboxCommand(httpSocketPath, socksSocketPath, userCommand, apply
501
517
  const shellPath = shell || 'bash';
502
518
  // Host filesystem is bind-mounted into the sandbox, so an explicit
503
519
  // socatPath resolves to the same binary inside bwrap.
504
- const socat = shellquote.quote([socatPath ?? 'socat']);
520
+ const socat = quote([socatPath ?? 'socat']);
505
521
  const socatCommands = [
506
522
  `${socat} TCP-LISTEN:3128,fork,reuseaddr UNIX-CONNECT:${httpSocketPath} >/dev/null 2>&1 &`,
507
523
  `${socat} TCP-LISTEN:1080,fork,reuseaddr UNIX-CONNECT:${socksSocketPath} >/dev/null 2>&1 &`,
@@ -509,16 +525,13 @@ function buildSandboxCommand(httpSocketPath, socksSocketPath, userCommand, apply
509
525
  ];
510
526
  // apply-seccomp runs after socat so socat can still create Unix sockets.
511
527
  if (applySeccompPrefix) {
512
- const applySeccompCmd = applySeccompPrefix + shellquote.quote([shellPath, '-c', userCommand]);
528
+ const applySeccompCmd = applySeccompPrefix + quote([shellPath, '-c', userCommand]);
513
529
  const innerScript = [...socatCommands, applySeccompCmd].join('\n');
514
- return `${shellPath} -c ${shellquote.quote([innerScript])}`;
530
+ return `${shellPath} -c ${quote([innerScript])}`;
515
531
  }
516
532
  else {
517
- const innerScript = [
518
- ...socatCommands,
519
- `eval ${shellquote.quote([userCommand])}`,
520
- ].join('\n');
521
- return `${shellPath} -c ${shellquote.quote([innerScript])}`;
533
+ const innerScript = [...socatCommands, `eval ${quote([userCommand])}`].join('\n');
534
+ return `${shellPath} -c ${quote([innerScript])}`;
522
535
  }
523
536
  }
524
537
  /**
@@ -587,7 +600,7 @@ function pushReadDenyDirMounts(args, normalizedPath, allowedWritePaths, readAllo
587
600
  /**
588
601
  * Generate filesystem bind mount arguments for bwrap
589
602
  */
590
- async function generateFilesystemArgs(readConfig, writeConfig, ripgrepConfig = { command: 'rg' }, mandatoryDenySearchDepth = DEFAULT_MANDATORY_DENY_SEARCH_DEPTH, allowGitConfig = false, abortSignal) {
603
+ async function generateFilesystemArgs(readConfig, writeConfig, maskedFileBinds, maskedFileStoreDir, ripgrepConfig = { command: 'rg' }, mandatoryDenySearchDepth = DEFAULT_MANDATORY_DENY_SEARCH_DEPTH, allowGitConfig = false, abortSignal) {
591
604
  const args = [];
592
605
  // fs already imported
593
606
  // Collect normalized allowed write paths. Populated in the writeConfig
@@ -736,9 +749,12 @@ async function generateFilesystemArgs(readConfig, writeConfig, ripgrepConfig = {
736
749
  // Handle read restrictions by mounting tmpfs over denied paths
737
750
  const readDenyPaths = [];
738
751
  const readAllowPaths = (readConfig?.allowWithinDeny || []).map(p => normalizePathForSandbox(p));
739
- // Files masked by --ro-bind /dev/null below. Used to filter denyWriteArgs so
740
- // that --ro-bind <host> <host> doesn't undo the mask.
741
- const maskedFiles = new Set();
752
+ // Files masked by --ro-bind <source> <dest> below. Map of dest source
753
+ // (/dev/null for read-deny, the sentinel fake for credential mask). Used
754
+ // to filter denyWriteArgs so that --ro-bind <host> <host> doesn't undo
755
+ // the mask, and to re-apply the correct source if a denyWrite ancestor
756
+ // bind re-exposes the dest.
757
+ const maskedFiles = new Map();
742
758
  // Directories masked by --tmpfs below, in emission (shallow-first) order.
743
759
  // Used to filter denyWriteArgs the same way: a dir in both deny lists must
744
760
  // not get its host contents re-bound on top of its own tmpfs.
@@ -763,7 +779,10 @@ async function generateFilesystemArgs(readConfig, writeConfig, ripgrepConfig = {
763
779
  // Always hide /etc/ssh/ssh_config.d to avoid permission issues with OrbStack
764
780
  // SSH is very strict about config file permissions and ownership, and they can
765
781
  // appear wrong inside the sandbox causing "Bad owner or permissions" errors
766
- if (fs.existsSync('/etc/ssh/ssh_config.d')) {
782
+ //
783
+ // Skipped when readConfig is undefined (filesystem.disabled): no read
784
+ // policy means no implicit read denies either.
785
+ if (readConfig && fs.existsSync('/etc/ssh/ssh_config.d')) {
767
786
  readDenyPaths.push('/etc/ssh/ssh_config.d');
768
787
  }
769
788
  // Normalize then sort shallow-first so tmpfs over ancestor dirs lands before
@@ -795,10 +814,25 @@ async function generateFilesystemArgs(readConfig, writeConfig, ripgrepConfig = {
795
814
  // bind destinations, so the deny bind lands on the resolved target.
796
815
  const denyDest = resolveSymlinkDenyDest(normalizedPath);
797
816
  args.push('--ro-bind', '/dev/null', denyDest);
798
- maskedFiles.add(denyDest);
799
- maskedFiles.add(normalizedPath);
817
+ maskedFiles.set(denyDest, '/dev/null');
818
+ maskedFiles.set(normalizedPath, '/dev/null');
800
819
  }
801
820
  }
821
+ // Whole-file credential masks: same bind shape as a file read-deny,
822
+ // but the source is the sentinel-content fake instead of /dev/null.
823
+ // realPath was already normalized (tilde-expanded, realpath'd) by the
824
+ // caller; resolveSymlinkDenyDest covers the symlinked-credential case
825
+ // for the same reason as above. The fake's parent dir is explicitly
826
+ // ro-bound at the end of this function, so the bind source is never
827
+ // writable from inside the sandbox. Adding the dest to maskedFiles
828
+ // ensures a later denyWrite ro-bind over the same path doesn't undo
829
+ // the mask.
830
+ for (const { realPath, fakePath } of maskedFileBinds ?? []) {
831
+ const dest = resolveSymlinkDenyDest(realPath);
832
+ args.push('--ro-bind', fakePath, dest);
833
+ maskedFiles.set(dest, fakePath);
834
+ maskedFiles.set(realPath, fakePath);
835
+ }
802
836
  // Emitting denyWrite last means these ro-binds layer on top of any write
803
837
  // paths the denyRead loop just re-bound. Before this ordering, tmpfs over
804
838
  // an ancestor of cwd would wipe the .git/hooks protection. But skip any
@@ -843,9 +877,10 @@ async function generateFilesystemArgs(readConfig, writeConfig, ripgrepConfig = {
843
877
  pushReadDenyDirMounts(args, tmpfsDir, allowedWritePaths, readAllowPaths);
844
878
  }
845
879
  }
846
- // Same problem for read-denied files: the /dev/null mask landed before the
847
- // denyWrite ancestor bind, so the real file is back. Re-apply the mask.
848
- for (const maskedFile of maskedFiles) {
880
+ // Same problem for masked files: the mask landed before the denyWrite
881
+ // ancestor bind, so the real file is back. Re-apply the mask with its
882
+ // original source (/dev/null for read-deny, the fake for credential mask).
883
+ for (const [maskedFile, source] of maskedFiles) {
849
884
  if (emittedDenyWriteDests.some(dest => maskedFile.startsWith(dest + '/'))) {
850
885
  // maskedFiles holds both the symlink path and its resolved target so
851
886
  // the denyWrite skip-check above matches either. Re-emission must go
@@ -855,10 +890,19 @@ async function generateFilesystemArgs(readConfig, writeConfig, ripgrepConfig = {
855
890
  // ancestor) or its own iteration re-emits it here.
856
891
  if (resolveSymlinkDenyDest(maskedFile) !== maskedFile)
857
892
  continue;
858
- logForDebugging(`[Sandbox Linux] Re-applying denyRead file mask re-exposed by denyWrite bind: ${maskedFile}`);
859
- args.push('--ro-bind', '/dev/null', maskedFile);
893
+ logForDebugging(`[Sandbox Linux] Re-applying file mask re-exposed by denyWrite bind: ${maskedFile}`);
894
+ args.push('--ro-bind', source, maskedFile);
860
895
  }
861
896
  }
897
+ // INVARIANT: the fake-file store directory must never be writable from
898
+ // inside the sandbox. If it were, a sandboxed process could plant a
899
+ // symlink at a fake path and a later host-side write() would follow it,
900
+ // or replace a fake's content so the bind exposes attacker bytes. Emit
901
+ // last so it overlays any earlier --bind that covers the store dir
902
+ // (e.g. allowWrite: ['/tmp'] when the store is under os.tmpdir()).
903
+ if (maskedFileStoreDir !== undefined) {
904
+ args.push('--ro-bind', maskedFileStoreDir, maskedFileStoreDir);
905
+ }
862
906
  return args;
863
907
  }
864
908
  /**
@@ -910,13 +954,15 @@ async function generateFilesystemArgs(readConfig, writeConfig, ripgrepConfig = {
910
954
  * Dependencies are checked by checkLinuxDependencies() before enabling the sandbox.
911
955
  */
912
956
  export async function wrapCommandWithSandboxLinux(params) {
913
- const { command, needsNetworkRestriction, httpSocketPath, socksSocketPath, httpProxyPort, socksProxyPort, proxyAuthToken, caCertPath, readConfig, writeConfig, unsetEnvVars, enableWeakerNestedSandbox, allowAllUnixSockets, binShell, ripgrepConfig = { command: 'rg' }, mandatoryDenySearchDepth = DEFAULT_MANDATORY_DENY_SEARCH_DEPTH, allowGitConfig = false, seccompConfig, bwrapPath, socatPath, abortSignal, } = params;
957
+ const { command, needsNetworkRestriction, httpSocketPath, socksSocketPath, httpProxyPort, socksProxyPort, proxyAuthToken, caCertPath, readConfig, writeConfig, unsetEnvVars, setEnvVars, maskedFileBinds, maskedFileStoreDir, enableWeakerNestedSandbox, allowAllUnixSockets, binShell, ripgrepConfig = { command: 'rg' }, mandatoryDenySearchDepth = DEFAULT_MANDATORY_DENY_SEARCH_DEPTH, allowGitConfig = false, seccompConfig, bwrapPath, socatPath, observeSocketPath, abortSignal, } = params;
914
958
  // Determine if we have restrictions to apply
915
959
  // Read: denyOnly pattern - empty array means no restrictions
916
960
  // Write: allowOnly pattern - undefined means no restrictions, any config means restrictions
917
- const hasReadRestrictions = readConfig && readConfig.denyOnly.length > 0;
961
+ const hasReadRestrictions = (readConfig && readConfig.denyOnly.length > 0) ||
962
+ (maskedFileBinds !== undefined && maskedFileBinds.length > 0);
918
963
  const hasWriteRestrictions = writeConfig !== undefined;
919
- const hasEnvRestrictions = unsetEnvVars !== undefined && unsetEnvVars.length > 0;
964
+ const hasEnvRestrictions = (unsetEnvVars !== undefined && unsetEnvVars.length > 0) ||
965
+ (setEnvVars !== undefined && Object.keys(setEnvVars).length > 0);
920
966
  // Check if we need any sandboxing
921
967
  if (!needsNetworkRestriction &&
922
968
  !hasReadRestrictions &&
@@ -950,15 +996,36 @@ export async function wrapCommandWithSandboxLinux(params) {
950
996
  else {
951
997
  logForDebugging('[Sandbox Linux] Skipping seccomp filter - allowAllUnixSockets is enabled');
952
998
  }
999
+ // ========== VIOLATION OBSERVATION (best-effort) ==========
1000
+ // Only meaningful when apply-seccomp will run — it is the binary that
1001
+ // installs the USER_NOTIF filter and ships the listener fd.
1002
+ if (observeSocketPath && applySeccompPrefix) {
1003
+ if (fs.existsSync(observeSocketPath)) {
1004
+ bwrapArgs.push('--bind', observeSocketPath, observeSocketPath);
1005
+ bwrapArgs.push('--setenv', 'SRT_OBSERVE_SOCK', observeSocketPath);
1006
+ // Tag events with the encoded command so the violation store can
1007
+ // associate them with this invocation (parity with macOS log tag).
1008
+ bwrapArgs.push('--setenv', 'SRT_ENCODED_CMD', encodeSandboxedCommand(command));
1009
+ }
1010
+ else {
1011
+ logForDebugging('[Sandbox Linux] observe socket missing — supervisor not running; ' +
1012
+ 'continuing without violation monitoring');
1013
+ }
1014
+ }
953
1015
  // ========== ENV RESTRICTIONS ==========
954
1016
  // Drop denied credential env vars from the inherited environment. Emitted
955
1017
  // before the proxy --setenv flags below: bwrap applies env operations in
956
1018
  // argument order, so SRT's own proxy plumbing vars survive even if a
957
1019
  // caller lists one of them as a denied credential.
958
1020
  if (hasEnvRestrictions) {
959
- for (const name of unsetEnvVars) {
1021
+ for (const name of unsetEnvVars ?? []) {
960
1022
  bwrapArgs.push('--unsetenv', name);
961
1023
  }
1024
+ // Masked credentials override the inherited real value with a
1025
+ // sentinel; bwrap --setenv replaces any inherited value of NAME.
1026
+ for (const [name, value] of Object.entries(setEnvVars ?? {})) {
1027
+ bwrapArgs.push('--setenv', name, value);
1028
+ }
962
1029
  }
963
1030
  // ========== NETWORK RESTRICTIONS ==========
964
1031
  if (needsNetworkRestriction) {
@@ -980,13 +1047,18 @@ export async function wrapCommandWithSandboxLinux(params) {
980
1047
  }
981
1048
  // Bind both sockets into the sandbox
982
1049
  bwrapArgs.push('--bind', httpSocketPath, httpSocketPath);
983
- bwrapArgs.push('--bind', socksSocketPath, socksSocketPath);
1050
+ // When the mux serves both protocols, socksSocketPath is the same
1051
+ // file as httpSocketPath; bwrap rejects a duplicate --bind of the
1052
+ // same source→target.
1053
+ if (socksSocketPath !== httpSocketPath) {
1054
+ bwrapArgs.push('--bind', socksSocketPath, socksSocketPath);
1055
+ }
984
1056
  // Add proxy environment variables
985
1057
  // HTTP_PROXY points to the socat listener inside the sandbox (port 3128)
986
1058
  // which forwards to the Unix socket that bridges to the host's proxy server
987
1059
  const proxyEnv = generateProxyEnvVars(3128, // Internal HTTP listener port
988
1060
  1080, // Internal SOCKS listener port
989
- caCertPath, proxyAuthToken);
1061
+ caCertPath, proxyAuthToken, writeConfig === undefined);
990
1062
  bwrapArgs.push(...proxyEnv.flatMap((env) => {
991
1063
  const firstEq = env.indexOf('=');
992
1064
  const key = env.slice(0, firstEq);
@@ -1005,7 +1077,7 @@ export async function wrapCommandWithSandboxLinux(params) {
1005
1077
  // If no sockets provided, network is completely blocked (--unshare-net without proxy)
1006
1078
  }
1007
1079
  // ========== FILESYSTEM RESTRICTIONS ==========
1008
- const fsArgs = await generateFilesystemArgs(readConfig, writeConfig, ripgrepConfig, mandatoryDenySearchDepth, allowGitConfig, abortSignal);
1080
+ const fsArgs = await generateFilesystemArgs(readConfig, writeConfig, maskedFileBinds, maskedFileStoreDir, ripgrepConfig, mandatoryDenySearchDepth, allowGitConfig, abortSignal);
1009
1081
  bwrapArgs.push(...fsArgs);
1010
1082
  // Always bind /dev
1011
1083
  bwrapArgs.push('--dev', '/dev');
@@ -1054,16 +1126,13 @@ export async function wrapCommandWithSandboxLinux(params) {
1054
1126
  bwrapArgs.push(sandboxCommand);
1055
1127
  }
1056
1128
  else if (applySeccompPrefix) {
1057
- const applySeccompCmd = applySeccompPrefix + shellquote.quote([shell, '-c', command]);
1129
+ const applySeccompCmd = applySeccompPrefix + quote([shell, '-c', command]);
1058
1130
  bwrapArgs.push(applySeccompCmd);
1059
1131
  }
1060
1132
  else {
1061
1133
  bwrapArgs.push(command);
1062
1134
  }
1063
- const wrappedCommand = shellquote.quote([
1064
- bwrapPath ?? 'bwrap',
1065
- ...bwrapArgs,
1066
- ]);
1135
+ const wrappedCommand = quote([bwrapPath ?? 'bwrap', ...bwrapArgs]);
1067
1136
  const restrictions = [];
1068
1137
  if (needsNetworkRestriction)
1069
1138
  restrictions.push('network');