@anthropic-ai/sandbox-runtime 0.0.1 → 0.0.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.
- package/LICENSE +201 -0
- package/README.md +173 -88
- package/dist/cli.js +72 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/sandbox/generate-seccomp-filter.d.ts +64 -0
- package/dist/sandbox/generate-seccomp-filter.d.ts.map +1 -0
- package/dist/sandbox/generate-seccomp-filter.js +447 -0
- package/dist/sandbox/generate-seccomp-filter.js.map +1 -0
- package/dist/sandbox/linux-sandbox-utils.d.ts +49 -3
- package/dist/sandbox/linux-sandbox-utils.d.ts.map +1 -1
- package/dist/sandbox/linux-sandbox-utils.js +247 -84
- package/dist/sandbox/linux-sandbox-utils.js.map +1 -1
- package/dist/sandbox/macos-sandbox-utils.d.ts +3 -1
- package/dist/sandbox/macos-sandbox-utils.d.ts.map +1 -1
- package/dist/sandbox/macos-sandbox-utils.js +12 -22
- package/dist/sandbox/macos-sandbox-utils.js.map +1 -1
- package/dist/sandbox/sandbox-config.d.ts +122 -0
- package/dist/sandbox/sandbox-config.d.ts.map +1 -0
- package/dist/sandbox/sandbox-config.js +75 -0
- package/dist/sandbox/sandbox-config.js.map +1 -0
- package/dist/sandbox/sandbox-manager.d.ts +3 -3
- package/dist/sandbox/sandbox-manager.d.ts.map +1 -1
- package/dist/sandbox/sandbox-manager.js +143 -236
- package/dist/sandbox/sandbox-manager.js.map +1 -1
- package/dist/sandbox/sandbox-schemas.d.ts +0 -76
- package/dist/sandbox/sandbox-schemas.d.ts.map +1 -1
- package/dist/sandbox/sandbox-schemas.js +1 -230
- package/dist/sandbox/sandbox-schemas.js.map +1 -1
- package/dist/sandbox/sandbox-utils.d.ts.map +1 -1
- package/dist/sandbox/sandbox-utils.js +5 -2
- package/dist/sandbox/sandbox-utils.js.map +1 -1
- package/dist/vendor/seccomp/arm64/unix-block.bpf +0 -0
- package/dist/vendor/seccomp/x64/unix-block.bpf +0 -0
- package/dist/vendor/seccomp-src/apply-seccomp-and-exec.py +111 -0
- package/dist/vendor/seccomp-src/seccomp-unix-block.c +97 -0
- package/package.json +10 -4
- package/vendor/seccomp/arm64/unix-block.bpf +0 -0
- package/vendor/seccomp/x64/unix-block.bpf +0 -0
- package/vendor/seccomp-src/apply-seccomp-and-exec.py +111 -0
- package/vendor/seccomp-src/seccomp-unix-block.c +97 -0
- package/dist/utils/exec.d.ts +0 -13
- package/dist/utils/exec.d.ts.map +0 -1
- package/dist/utils/exec.js +0 -38
- package/dist/utils/exec.js.map +0 -1
- package/dist/utils/settings.d.ts +0 -147
- package/dist/utils/settings.d.ts.map +0 -1
- package/dist/utils/settings.js +0 -244
- package/dist/utils/settings.js.map +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
export interface FsReadRestrictionConfig {
|
|
3
2
|
denyOnly: string[];
|
|
4
3
|
}
|
|
@@ -15,79 +14,4 @@ export type NetworkHostPattern = {
|
|
|
15
14
|
port: number | undefined;
|
|
16
15
|
};
|
|
17
16
|
export type SandboxAskCallback = (params: NetworkHostPattern) => Promise<boolean>;
|
|
18
|
-
export declare function generateHostListSchema(allowedOrDenied: 'allowed' | 'denied'): z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
|
|
19
|
-
/**
|
|
20
|
-
* Safely parse a network restriction pattern.
|
|
21
|
-
* Returns the parsed pattern or an Error.
|
|
22
|
-
*/
|
|
23
|
-
export declare function safeParseRestrictionPattern(pattern: string): NetworkHostPattern | Error;
|
|
24
|
-
/**
|
|
25
|
-
* Schema for command-specific sandbox violation ignore patterns.
|
|
26
|
-
* Maps command patterns to lists of filesystem paths to ignore violations for.
|
|
27
|
-
* The special key "*" matches all commands.
|
|
28
|
-
*
|
|
29
|
-
* Example:
|
|
30
|
-
* {
|
|
31
|
-
* "*": ["/usr/bin", "/System"], // Ignore for all commands
|
|
32
|
-
* "git push": ["/usr/bin/nc"], // Ignore nc errors when running git push
|
|
33
|
-
* "npm": ["/private/tmp"], // Ignore tmp access for npm commands
|
|
34
|
-
* }
|
|
35
|
-
*/
|
|
36
|
-
export declare const IgnoreViolationsSchema: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>;
|
|
37
|
-
export type IgnoreViolationsConfig = z.infer<typeof IgnoreViolationsSchema>;
|
|
38
|
-
export declare const NetworkConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
39
|
-
allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
40
|
-
allowLocalBinding: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
-
httpProxyPort: z.ZodOptional<z.ZodNumber>;
|
|
42
|
-
socksProxyPort: z.ZodOptional<z.ZodNumber>;
|
|
43
|
-
}, "strip", z.ZodTypeAny, {
|
|
44
|
-
allowUnixSockets?: string[] | undefined;
|
|
45
|
-
allowLocalBinding?: boolean | undefined;
|
|
46
|
-
httpProxyPort?: number | undefined;
|
|
47
|
-
socksProxyPort?: number | undefined;
|
|
48
|
-
}, {
|
|
49
|
-
allowUnixSockets?: string[] | undefined;
|
|
50
|
-
allowLocalBinding?: boolean | undefined;
|
|
51
|
-
httpProxyPort?: number | undefined;
|
|
52
|
-
socksProxyPort?: number | undefined;
|
|
53
|
-
}>>;
|
|
54
|
-
export declare const SandboxConfigSchema: z.ZodObject<{
|
|
55
|
-
network: z.ZodOptional<z.ZodObject<{
|
|
56
|
-
allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
57
|
-
allowLocalBinding: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
-
httpProxyPort: z.ZodOptional<z.ZodNumber>;
|
|
59
|
-
socksProxyPort: z.ZodOptional<z.ZodNumber>;
|
|
60
|
-
}, "strip", z.ZodTypeAny, {
|
|
61
|
-
allowUnixSockets?: string[] | undefined;
|
|
62
|
-
allowLocalBinding?: boolean | undefined;
|
|
63
|
-
httpProxyPort?: number | undefined;
|
|
64
|
-
socksProxyPort?: number | undefined;
|
|
65
|
-
}, {
|
|
66
|
-
allowUnixSockets?: string[] | undefined;
|
|
67
|
-
allowLocalBinding?: boolean | undefined;
|
|
68
|
-
httpProxyPort?: number | undefined;
|
|
69
|
-
socksProxyPort?: number | undefined;
|
|
70
|
-
}>>;
|
|
71
|
-
ignoreViolations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
72
|
-
enableWeakerNestedSandbox: z.ZodOptional<z.ZodBoolean>;
|
|
73
|
-
}, "strip", z.ZodTypeAny, {
|
|
74
|
-
network?: {
|
|
75
|
-
allowUnixSockets?: string[] | undefined;
|
|
76
|
-
allowLocalBinding?: boolean | undefined;
|
|
77
|
-
httpProxyPort?: number | undefined;
|
|
78
|
-
socksProxyPort?: number | undefined;
|
|
79
|
-
} | undefined;
|
|
80
|
-
ignoreViolations?: Record<string, string[]> | undefined;
|
|
81
|
-
enableWeakerNestedSandbox?: boolean | undefined;
|
|
82
|
-
}, {
|
|
83
|
-
network?: {
|
|
84
|
-
allowUnixSockets?: string[] | undefined;
|
|
85
|
-
allowLocalBinding?: boolean | undefined;
|
|
86
|
-
httpProxyPort?: number | undefined;
|
|
87
|
-
socksProxyPort?: number | undefined;
|
|
88
|
-
} | undefined;
|
|
89
|
-
ignoreViolations?: Record<string, string[]> | undefined;
|
|
90
|
-
enableWeakerNestedSandbox?: boolean | undefined;
|
|
91
|
-
}>;
|
|
92
|
-
export type SandboxConfig = z.infer<typeof SandboxConfigSchema>;
|
|
93
17
|
//# sourceMappingURL=sandbox-schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-schemas.d.ts","sourceRoot":"","sources":["../../src/sandbox/sandbox-schemas.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"sandbox-schemas.d.ts","sourceRoot":"","sources":["../../src/sandbox/sandbox-schemas.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAED,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B;AAGD,MAAM,WAAW,wBAAwB;IACvC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,CAC/B,MAAM,EAAE,kBAAkB,KACvB,OAAO,CAAC,OAAO,CAAC,CAAA"}
|
|
@@ -1,231 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
export function generateHostListSchema(allowedOrDenied) {
|
|
4
|
-
return z
|
|
5
|
-
.array(z.string())
|
|
6
|
-
.describe(`List of automatically ${allowedOrDenied} network hosts (e.g., ["github.com:443", "api.example.com"])`)
|
|
7
|
-
.transform((patterns) => {
|
|
8
|
-
// Parse and validate each host pattern
|
|
9
|
-
return patterns.map(pattern => {
|
|
10
|
-
const parsed = safeParseRestrictionPattern(pattern);
|
|
11
|
-
if (parsed instanceof Error) {
|
|
12
|
-
throw new Error(`Invalid network host pattern: ${parsed.message}`);
|
|
13
|
-
}
|
|
14
|
-
// Return the original validated string, not the parsed pattern
|
|
15
|
-
return pattern;
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
// Port number schema
|
|
20
|
-
const portNumberSchema = z
|
|
21
|
-
.string()
|
|
22
|
-
.regex(/^\d+$/)
|
|
23
|
-
.transform(val => parseInt(val, 10))
|
|
24
|
-
.refine(port => port >= 1 && port <= 65535, 'Port must be between 1 and 65535');
|
|
25
|
-
// Schema for IPv6 addresses without port
|
|
26
|
-
// Examples: "::1" (IPv6 loopback), "2001:db8::1", "fe80::1"
|
|
27
|
-
const ipv6Schema = z
|
|
28
|
-
.string()
|
|
29
|
-
.refine(val => isIP(val) === 6 && !val.includes('[') && !val.includes(']'))
|
|
30
|
-
.transform((val) => ({
|
|
31
|
-
host: val,
|
|
32
|
-
port: undefined,
|
|
33
|
-
}));
|
|
34
|
-
// Schema for IPv6 addresses with port (requires bracket notation)
|
|
35
|
-
// Examples: "[::1]:8080", "[2001:db8::1]:443", "[fe80::1]:22"
|
|
36
|
-
const ipv6WithPortSchema = z
|
|
37
|
-
.string()
|
|
38
|
-
.regex(/^\[([^\]]+)\]:(\d+)$/)
|
|
39
|
-
.transform((val) => {
|
|
40
|
-
const match = val.match(/^\[([^\]]+)\]:(\d+)$/);
|
|
41
|
-
const host = match[1];
|
|
42
|
-
const portStr = match[2];
|
|
43
|
-
// Validate that the host part is actually an IPv6 address
|
|
44
|
-
if (isIP(host) !== 6) {
|
|
45
|
-
throw new Error('Invalid IPv6 address in bracket notation');
|
|
46
|
-
}
|
|
47
|
-
// Parse and validate port
|
|
48
|
-
const portResult = portNumberSchema.safeParse(portStr);
|
|
49
|
-
if (!portResult.success) {
|
|
50
|
-
throw new Error('Invalid port number');
|
|
51
|
-
}
|
|
52
|
-
const port = portResult.data;
|
|
53
|
-
return { host, port };
|
|
54
|
-
});
|
|
55
|
-
// Schema for IPv4 addresses without port
|
|
56
|
-
// Examples: "192.168.1.1", "127.0.0.1", "10.0.0.1"
|
|
57
|
-
const ipv4Schema = z
|
|
58
|
-
.string()
|
|
59
|
-
.refine(val => isIP(val) === 4)
|
|
60
|
-
.transform((val) => ({
|
|
61
|
-
host: val,
|
|
62
|
-
port: undefined,
|
|
63
|
-
}));
|
|
64
|
-
// Schema for IPv4 addresses with port
|
|
65
|
-
// Examples: "192.168.1.1:8080", "127.0.0.1:443", "10.0.0.1:22"
|
|
66
|
-
const ipv4WithPortSchema = z
|
|
67
|
-
.string()
|
|
68
|
-
.regex(/^(\d+\.\d+\.\d+\.\d+):(\d+)$/)
|
|
69
|
-
.transform((val) => {
|
|
70
|
-
const match = val.match(/^(\d+\.\d+\.\d+\.\d+):(\d+)$/);
|
|
71
|
-
const host = match[1];
|
|
72
|
-
const portStr = match[2];
|
|
73
|
-
// Validate that the host part is actually an IPv4 address
|
|
74
|
-
if (isIP(host) !== 4) {
|
|
75
|
-
throw new Error('Invalid IPv4 address format');
|
|
76
|
-
}
|
|
77
|
-
// Parse and validate port
|
|
78
|
-
const portResult = portNumberSchema.safeParse(portStr);
|
|
79
|
-
if (!portResult.success) {
|
|
80
|
-
throw new Error('Invalid port number');
|
|
81
|
-
}
|
|
82
|
-
const port = portResult.data;
|
|
83
|
-
return { host, port };
|
|
84
|
-
});
|
|
85
|
-
// Base schema for validating domain names (not IP addresses)
|
|
86
|
-
// Examples: "example.com", "localhost", "*.example.com", "sub.domain.com"
|
|
87
|
-
const domainNameSchema = z.string().refine(val => {
|
|
88
|
-
// Basic format checks
|
|
89
|
-
if (val.length === 0 ||
|
|
90
|
-
val.includes(':') || // No colons (would indicate port or IPv6)
|
|
91
|
-
val.includes('/') || // No paths or protocol prefixes
|
|
92
|
-
val.includes('?') || // No query strings
|
|
93
|
-
val.includes('#') || // No fragments
|
|
94
|
-
isIP(val) // Not an IP address
|
|
95
|
-
) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
// Special case: localhost is always valid
|
|
99
|
-
if (val === 'localhost') {
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
// Wildcard domains: *.example.com (must have dot after wildcard)
|
|
103
|
-
if (val.startsWith('*.')) {
|
|
104
|
-
const domainPart = val.slice(2);
|
|
105
|
-
return (domainPart.includes('.') &&
|
|
106
|
-
!domainPart.startsWith('.') &&
|
|
107
|
-
!domainPart.endsWith('.'));
|
|
108
|
-
}
|
|
109
|
-
// Regular domains: must contain at least one dot and not start/end with dot
|
|
110
|
-
return val.includes('.') && !val.startsWith('.') && !val.endsWith('.');
|
|
111
|
-
});
|
|
112
|
-
// Schema for domain name without port
|
|
113
|
-
// Examples: "example.com", "*.example.com", "localhost"
|
|
114
|
-
const hostnameSchema = domainNameSchema.transform((val) => ({
|
|
115
|
-
host: val,
|
|
116
|
-
port: undefined,
|
|
117
|
-
}));
|
|
118
|
-
// Schema for domain name with port
|
|
119
|
-
// Examples: "example.com:8080", "localhost:3000", "*.example.com:443"
|
|
120
|
-
const hostnameWithPortSchema = z
|
|
121
|
-
.string()
|
|
122
|
-
.regex(/^([^:]+):(\d+)$/)
|
|
123
|
-
.transform((val) => {
|
|
124
|
-
const match = val.match(/^([^:]+):(\d+)$/);
|
|
125
|
-
const host = match[1];
|
|
126
|
-
const portStr = match[2];
|
|
127
|
-
// Validate that the host part is a valid domain name
|
|
128
|
-
const hostResult = domainNameSchema.safeParse(host);
|
|
129
|
-
if (!hostResult.success) {
|
|
130
|
-
throw new Error('Invalid domain name');
|
|
131
|
-
}
|
|
132
|
-
// Parse and validate port
|
|
133
|
-
const portResult = portNumberSchema.safeParse(portStr);
|
|
134
|
-
if (!portResult.success) {
|
|
135
|
-
throw new Error('Invalid port number');
|
|
136
|
-
}
|
|
137
|
-
const port = portResult.data;
|
|
138
|
-
return { host, port };
|
|
139
|
-
});
|
|
140
|
-
// Combined schema that tries each pattern in order
|
|
141
|
-
const hostPatternSchema = z.union([
|
|
142
|
-
ipv6WithPortSchema,
|
|
143
|
-
ipv6Schema,
|
|
144
|
-
ipv4WithPortSchema,
|
|
145
|
-
ipv4Schema,
|
|
146
|
-
hostnameWithPortSchema,
|
|
147
|
-
hostnameSchema,
|
|
148
|
-
]);
|
|
149
|
-
/**
|
|
150
|
-
* Safely parse a network restriction pattern.
|
|
151
|
-
* Returns the parsed pattern or an Error.
|
|
152
|
-
*/
|
|
153
|
-
export function safeParseRestrictionPattern(pattern) {
|
|
154
|
-
const result = hostPatternSchema.safeParse(pattern);
|
|
155
|
-
if (!result.success) {
|
|
156
|
-
// Provide helpful error messages for common mistakes
|
|
157
|
-
if (pattern.startsWith('http://') || pattern.startsWith('https://')) {
|
|
158
|
-
return Error(`Invalid network restriction: "${pattern}" - remove the protocol (http:// or https://)`);
|
|
159
|
-
}
|
|
160
|
-
if (pattern.includes('/')) {
|
|
161
|
-
return Error(`Invalid network restriction: "${pattern}" - paths are not allowed, only hosts`);
|
|
162
|
-
}
|
|
163
|
-
if (pattern === '') {
|
|
164
|
-
return Error(`Invalid network restriction: empty string - please provide a host`);
|
|
165
|
-
}
|
|
166
|
-
if (pattern.endsWith(':')) {
|
|
167
|
-
return Error(`Invalid network restriction: "${pattern}" - incomplete port specification`);
|
|
168
|
-
}
|
|
169
|
-
return Error(`Invalid network restriction: "${pattern}"`);
|
|
170
|
-
}
|
|
171
|
-
return result.data;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Schema for command-specific sandbox violation ignore patterns.
|
|
175
|
-
* Maps command patterns to lists of filesystem paths to ignore violations for.
|
|
176
|
-
* The special key "*" matches all commands.
|
|
177
|
-
*
|
|
178
|
-
* Example:
|
|
179
|
-
* {
|
|
180
|
-
* "*": ["/usr/bin", "/System"], // Ignore for all commands
|
|
181
|
-
* "git push": ["/usr/bin/nc"], // Ignore nc errors when running git push
|
|
182
|
-
* "npm": ["/private/tmp"], // Ignore tmp access for npm commands
|
|
183
|
-
* }
|
|
184
|
-
*/
|
|
185
|
-
export const IgnoreViolationsSchema = z
|
|
186
|
-
.record(z.string(), z
|
|
187
|
-
.array(z.string())
|
|
188
|
-
.describe('List of filesystem paths to ignore sandbox violations for when this command pattern matches'))
|
|
189
|
-
.describe('Map of command patterns to filesystem paths to ignore violations for. Use "*" to match all commands');
|
|
190
|
-
// ============================================================================
|
|
191
|
-
// COMBINED SCHEMAS
|
|
192
|
-
// ============================================================================
|
|
193
|
-
// Network restriction schemas
|
|
194
|
-
export const NetworkConfigSchema = z
|
|
195
|
-
.object({
|
|
196
|
-
allowUnixSockets: z
|
|
197
|
-
.array(z.string())
|
|
198
|
-
.optional()
|
|
199
|
-
.describe('Allow Unix domain sockets for local IPC (SSH agent, Docker, etc.). Provide an array of specific paths. Defaults to blocking if not specified'),
|
|
200
|
-
allowLocalBinding: z
|
|
201
|
-
.boolean()
|
|
202
|
-
.optional()
|
|
203
|
-
.describe('Allow binding to local network addresses (e.g., localhost ports). Defaults to false if not specified'),
|
|
204
|
-
httpProxyPort: z
|
|
205
|
-
.number()
|
|
206
|
-
.int()
|
|
207
|
-
.min(1)
|
|
208
|
-
.max(65535)
|
|
209
|
-
.optional()
|
|
210
|
-
.describe('HTTP proxy port to use for network filtering. If not specified, a proxy server will be started automatically'),
|
|
211
|
-
socksProxyPort: z
|
|
212
|
-
.number()
|
|
213
|
-
.int()
|
|
214
|
-
.min(1)
|
|
215
|
-
.max(65535)
|
|
216
|
-
.optional()
|
|
217
|
-
.describe('SOCKS proxy port to use for network filtering. If not specified, a proxy server will be started automatically'),
|
|
218
|
-
})
|
|
219
|
-
.optional();
|
|
220
|
-
// Complete sandbox config schema
|
|
221
|
-
export const SandboxConfigSchema = z.object({
|
|
222
|
-
network: NetworkConfigSchema,
|
|
223
|
-
ignoreViolations: IgnoreViolationsSchema.optional(),
|
|
224
|
-
enableWeakerNestedSandbox: z
|
|
225
|
-
.boolean()
|
|
226
|
-
.optional()
|
|
227
|
-
.describe('Enable weaker sandbox mode for unprivileged docker environments where --proc mounting fails. ' +
|
|
228
|
-
'This significantly reduces the strength of the sandbox and should only be used when this risk is acceptable.' +
|
|
229
|
-
'Default: false (secure).'),
|
|
230
|
-
});
|
|
1
|
+
export {};
|
|
231
2
|
//# sourceMappingURL=sandbox-schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-schemas.js","sourceRoot":"","sources":["../../src/sandbox/sandbox-schemas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sandbox-schemas.js","sourceRoot":"","sources":["../../src/sandbox/sandbox-schemas.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-utils.d.ts","sourceRoot":"","sources":["../../src/sandbox/sandbox-utils.ts"],"names":[],"mappings":"AAyCA;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAO9D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CA8BnE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"sandbox-utils.d.ts","sourceRoot":"","sources":["../../src/sandbox/sandbox-utils.ts"],"names":[],"mappings":"AAyCA;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAO9D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CA8BnE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAiB/C;AAED;;;;GAIG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAqKrE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,CAAC,EAAE,MAAM,EACtB,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,EAAE,CA6FV;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAG9D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAErE"}
|
|
@@ -109,7 +109,10 @@ export function getDefaultWritePaths() {
|
|
|
109
109
|
'/dev/tty',
|
|
110
110
|
'/dev/dtracehelper',
|
|
111
111
|
'/dev/autofs_nowait',
|
|
112
|
+
'/tmp/claude',
|
|
113
|
+
'/private/tmp/claude',
|
|
112
114
|
path.join(homeDir, '.npm/_logs'),
|
|
115
|
+
path.join(homeDir, '.claude/debug'),
|
|
113
116
|
'.',
|
|
114
117
|
];
|
|
115
118
|
return recommendedPaths;
|
|
@@ -258,8 +261,8 @@ export async function getMandatoryDenyWithinAllow() {
|
|
|
258
261
|
* Generate proxy environment variables for sandboxed processes
|
|
259
262
|
*/
|
|
260
263
|
export function generateProxyEnvVars(httpProxyPort, socksProxyPort) {
|
|
261
|
-
const envVars = [`SANDBOX_RUNTIME=1`];
|
|
262
|
-
// If no proxy ports provided, return
|
|
264
|
+
const envVars = [`SANDBOX_RUNTIME=1`, `TMPDIR=/tmp/claude`];
|
|
265
|
+
// If no proxy ports provided, return minimal env vars
|
|
263
266
|
if (!httpProxyPort && !socksProxyPort) {
|
|
264
267
|
return envVars;
|
|
265
268
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-utils.js","sourceRoot":"","sources":["../../src/sandbox/sandbox-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAC5B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE7C;;;GAGG;AACH,MAAM,eAAe,GAAG;IACtB,YAAY;IACZ,aAAa;IACb,SAAS;IACT,eAAe;IACf,QAAQ;IACR,WAAW;IACX,UAAU;IACV,YAAY;IACZ,WAAW;CACH,CAAA;AAEV;;;GAGG;AACH,MAAM,qBAA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;QAED,+BAA+B;QAC/B,4DAA4D;QAE5D,kDAAkD;QAClD,uEAAuE;QAEvE,6CAA6C;QAC7C,OAAO,CAAC,IAAI,CAAC,kCAAkC,cAAc,EAAE,CAAC,CAAA;QAChE,OAAO,CAAC,IAAI,CAAC,kCAAkC,cAAc,EAAE,CAAC,CAAA;IAClE,CAAC;IAED,8FAA8F;IAC9F,4FAA4F;IAC5F,mGAAmG;IAEnG,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,MAAM,gBAAgB,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAC9C,OAAO,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AACzD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,cAAsB;IAC3D,OAAO,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AAC/D,CAAC"}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Apply seccomp filter and exec command
|
|
4
|
+
|
|
5
|
+
This helper script loads a compiled seccomp BPF filter, applies it to the
|
|
6
|
+
current process using prctl, and then execs the specified command. This enables
|
|
7
|
+
two-stage seccomp application: infrastructure code runs without the filter,
|
|
8
|
+
then the user command runs with the filter active.
|
|
9
|
+
|
|
10
|
+
Usage:
|
|
11
|
+
./apply-seccomp-and-exec.py <filter-file> -- <command> [args...]
|
|
12
|
+
|
|
13
|
+
The filter file should contain a compiled BPF program (struct sock_fprog).
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import sys
|
|
17
|
+
import os
|
|
18
|
+
import ctypes
|
|
19
|
+
import ctypes.util
|
|
20
|
+
|
|
21
|
+
# Constants
|
|
22
|
+
PR_SET_NO_NEW_PRIVS = 38
|
|
23
|
+
PR_SET_SECCOMP = 22
|
|
24
|
+
SECCOMP_MODE_FILTER = 2
|
|
25
|
+
|
|
26
|
+
# Define sock_filter structure (8 bytes)
|
|
27
|
+
class sock_filter(ctypes.Structure):
|
|
28
|
+
_fields_ = [
|
|
29
|
+
("code", ctypes.c_uint16),
|
|
30
|
+
("jt", ctypes.c_uint8),
|
|
31
|
+
("jf", ctypes.c_uint8),
|
|
32
|
+
("k", ctypes.c_uint32),
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
# Define sock_fprog structure
|
|
36
|
+
class sock_fprog(ctypes.Structure):
|
|
37
|
+
_fields_ = [
|
|
38
|
+
("len", ctypes.c_uint16),
|
|
39
|
+
("filter", ctypes.POINTER(sock_filter)),
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
def load_filter(path):
|
|
43
|
+
"""Load BPF filter from file"""
|
|
44
|
+
try:
|
|
45
|
+
with open(path, 'rb') as f:
|
|
46
|
+
data = f.read()
|
|
47
|
+
except IOError as e:
|
|
48
|
+
print(f"Error: Failed to open filter file {path}: {e}", file=sys.stderr)
|
|
49
|
+
sys.exit(1)
|
|
50
|
+
|
|
51
|
+
# Verify size is valid
|
|
52
|
+
filter_size = ctypes.sizeof(sock_filter)
|
|
53
|
+
if len(data) == 0 or len(data) % filter_size != 0:
|
|
54
|
+
print(f"Error: Invalid filter file size: {len(data)}", file=sys.stderr)
|
|
55
|
+
sys.exit(1)
|
|
56
|
+
|
|
57
|
+
# Parse filter data into array
|
|
58
|
+
num_filters = len(data) // filter_size
|
|
59
|
+
filter_array = (sock_filter * num_filters)()
|
|
60
|
+
ctypes.memmove(filter_array, data, len(data))
|
|
61
|
+
|
|
62
|
+
# Create fprog structure
|
|
63
|
+
prog = sock_fprog()
|
|
64
|
+
prog.len = num_filters
|
|
65
|
+
prog.filter = ctypes.cast(filter_array, ctypes.POINTER(sock_filter))
|
|
66
|
+
|
|
67
|
+
return prog, filter_array # Keep array alive
|
|
68
|
+
|
|
69
|
+
def main():
|
|
70
|
+
if len(sys.argv) < 4:
|
|
71
|
+
print(f"Usage: {sys.argv[0]} <filter-file> -- <command> [args...]", file=sys.stderr)
|
|
72
|
+
print("\nApplies seccomp filter and execs the command", file=sys.stderr)
|
|
73
|
+
sys.exit(1)
|
|
74
|
+
|
|
75
|
+
# Check for separator
|
|
76
|
+
if sys.argv[2] != '--':
|
|
77
|
+
print("Error: Expected '--' as second argument", file=sys.stderr)
|
|
78
|
+
sys.exit(1)
|
|
79
|
+
|
|
80
|
+
filter_path = sys.argv[1]
|
|
81
|
+
command_argv = sys.argv[3:]
|
|
82
|
+
|
|
83
|
+
# Load the BPF filter
|
|
84
|
+
prog, filter_array = load_filter(filter_path)
|
|
85
|
+
|
|
86
|
+
# Load libc
|
|
87
|
+
libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
|
|
88
|
+
|
|
89
|
+
# Set no_new_privs (required for unprivileged processes)
|
|
90
|
+
ret = libc.prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)
|
|
91
|
+
if ret < 0:
|
|
92
|
+
errno = ctypes.get_errno()
|
|
93
|
+
print(f"Error: Failed to set no_new_privs: {os.strerror(errno)}", file=sys.stderr)
|
|
94
|
+
sys.exit(1)
|
|
95
|
+
|
|
96
|
+
# Apply the seccomp filter
|
|
97
|
+
ret = libc.prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, ctypes.byref(prog), 0, 0)
|
|
98
|
+
if ret < 0:
|
|
99
|
+
errno = ctypes.get_errno()
|
|
100
|
+
print(f"Error: Failed to apply seccomp filter: {os.strerror(errno)}", file=sys.stderr)
|
|
101
|
+
sys.exit(1)
|
|
102
|
+
|
|
103
|
+
# Filter is now active - exec the command
|
|
104
|
+
try:
|
|
105
|
+
os.execvp(command_argv[0], command_argv)
|
|
106
|
+
except OSError as e:
|
|
107
|
+
print(f"Error: Failed to exec {command_argv[0]}: {e}", file=sys.stderr)
|
|
108
|
+
sys.exit(1)
|
|
109
|
+
|
|
110
|
+
if __name__ == '__main__':
|
|
111
|
+
main()
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Seccomp BPF filter generator to block Unix domain socket creation
|
|
3
|
+
*
|
|
4
|
+
* This program generates a seccomp-bpf filter that blocks the socket() syscall
|
|
5
|
+
* when called with AF_UNIX as the domain argument. This prevents creation of
|
|
6
|
+
* Unix domain sockets while allowing all other socket types (AF_INET, AF_INET6, etc.)
|
|
7
|
+
* and all other syscalls.
|
|
8
|
+
*
|
|
9
|
+
* The filter is exported in a format compatible with bubblewrap's --seccomp flag.
|
|
10
|
+
*
|
|
11
|
+
* SECURITY LIMITATION - 32-bit x86 (ia32):
|
|
12
|
+
* TODO: This filter does NOT block socketcall() syscall, which is a security issue
|
|
13
|
+
* on 32-bit x86 systems. On ia32, the socket() syscall doesn't exist - instead,
|
|
14
|
+
* all socket operations are multiplexed through socketcall():
|
|
15
|
+
* - socketcall(SYS_SOCKET, [AF_UNIX, ...]) - can bypass this filter
|
|
16
|
+
* - socketcall(SYS_SOCKETPAIR, [AF_UNIX, ...]) - can bypass this filter
|
|
17
|
+
*
|
|
18
|
+
* To fix this, we need to add conditional rules that:
|
|
19
|
+
* 1. Check if socketcall() exists on the current architecture (32-bit x86 only)
|
|
20
|
+
* 2. Block socketcall(SYS_SOCKET, ...) when first arg of sub-call is AF_UNIX
|
|
21
|
+
* 3. Block socketcall(SYS_SOCKETPAIR, ...) when first arg of sub-call is AF_UNIX
|
|
22
|
+
*
|
|
23
|
+
* This requires inspecting the arguments passed to socketcall, which is more
|
|
24
|
+
* complex BPF logic. For now, 32-bit x86 is not supported.
|
|
25
|
+
*
|
|
26
|
+
* Compilation:
|
|
27
|
+
* gcc -o seccomp-unix-block seccomp-unix-block.c -lseccomp
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
* ./seccomp-unix-block <output-file>
|
|
31
|
+
*
|
|
32
|
+
* Dependencies:
|
|
33
|
+
* - libseccomp (libseccomp-dev package on Debian/Ubuntu)
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
#include <errno.h>
|
|
37
|
+
#include <fcntl.h>
|
|
38
|
+
#include <stdio.h>
|
|
39
|
+
#include <stdlib.h>
|
|
40
|
+
#include <string.h>
|
|
41
|
+
#include <unistd.h>
|
|
42
|
+
#include <seccomp.h>
|
|
43
|
+
#include <sys/socket.h>
|
|
44
|
+
#include <sys/stat.h>
|
|
45
|
+
#include <sys/types.h>
|
|
46
|
+
|
|
47
|
+
int main(int argc, char *argv[]) {
|
|
48
|
+
scmp_filter_ctx ctx;
|
|
49
|
+
int rc;
|
|
50
|
+
|
|
51
|
+
if (argc != 2) {
|
|
52
|
+
fprintf(stderr, "Usage: %s <output-file>\n", argv[0]);
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const char *output_file = argv[1];
|
|
57
|
+
|
|
58
|
+
/* Create seccomp context with default action ALLOW */
|
|
59
|
+
ctx = seccomp_init(SCMP_ACT_ALLOW);
|
|
60
|
+
if (ctx == NULL) {
|
|
61
|
+
fprintf(stderr, "Error: Failed to initialize seccomp context\n");
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Add rule to block socket(AF_UNIX, ...) */
|
|
66
|
+
/* socket() syscall signature: int socket(int domain, int type, int protocol) */
|
|
67
|
+
/* arg0 = domain (AF_UNIX = 1) */
|
|
68
|
+
rc = seccomp_rule_add(ctx, SCMP_ACT_ERRNO(EPERM), SCMP_SYS(socket), 1,
|
|
69
|
+
SCMP_A0(SCMP_CMP_EQ, AF_UNIX));
|
|
70
|
+
if (rc < 0) {
|
|
71
|
+
fprintf(stderr, "Error: Failed to add seccomp rule: %s\n", strerror(-rc));
|
|
72
|
+
seccomp_release(ctx);
|
|
73
|
+
return 1;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* Export the filter to a file */
|
|
77
|
+
int fd = open(output_file, O_CREAT | O_WRONLY | O_TRUNC, 0600);
|
|
78
|
+
if (fd < 0) {
|
|
79
|
+
fprintf(stderr, "Error: Failed to open output file: %s\n", strerror(errno));
|
|
80
|
+
seccomp_release(ctx);
|
|
81
|
+
return 1;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
rc = seccomp_export_bpf(ctx, fd);
|
|
85
|
+
if (rc < 0) {
|
|
86
|
+
fprintf(stderr, "Error: Failed to export seccomp filter: %s\n", strerror(-rc));
|
|
87
|
+
close(fd);
|
|
88
|
+
seccomp_release(ctx);
|
|
89
|
+
return 1;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Clean up */
|
|
93
|
+
close(fd);
|
|
94
|
+
seccomp_release(ctx);
|
|
95
|
+
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anthropic-ai/sandbox-runtime",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Anthropic Sandbox Runtime (ASRT) - A general-purpose tool for wrapping security boundaries around arbitrary processes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,7 +13,12 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "tsc",
|
|
16
|
+
"postbuild": "[ -d vendor ] && cp -r vendor dist/ || true",
|
|
17
|
+
"build:seccomp": "scripts/build-seccomp-binaries.sh",
|
|
16
18
|
"clean": "rm -rf dist",
|
|
19
|
+
"test": "bun test",
|
|
20
|
+
"test:unit": "bun test test/config-validation.test.ts test/sandbox/seccomp-filter.test.ts",
|
|
21
|
+
"test:integration": "bun test test/sandbox/integration.test.ts",
|
|
17
22
|
"typecheck": "tsc --noEmit",
|
|
18
23
|
"lint": "eslint 'src/**/*.ts' --fix --cache --cache-location=node_modules/.cache/.eslintcache",
|
|
19
24
|
"lint:check": "eslint 'src/**/*.ts' --cache --cache-location=node_modules/.cache/.eslintcache",
|
|
@@ -45,6 +50,7 @@
|
|
|
45
50
|
},
|
|
46
51
|
"files": [
|
|
47
52
|
"dist",
|
|
53
|
+
"vendor",
|
|
48
54
|
"README.md",
|
|
49
55
|
"LICENSE"
|
|
50
56
|
],
|
|
@@ -63,10 +69,10 @@
|
|
|
63
69
|
"license": "Apache-2.0",
|
|
64
70
|
"repository": {
|
|
65
71
|
"type": "git",
|
|
66
|
-
"url": "git+https://github.com/
|
|
72
|
+
"url": "git+https://github.com/anthropic-experimental/sandbox-runtime.git"
|
|
67
73
|
},
|
|
68
74
|
"bugs": {
|
|
69
|
-
"url": "https://github.com/
|
|
75
|
+
"url": "https://github.com/anthropic-experimental/sandbox-runtime/issues"
|
|
70
76
|
},
|
|
71
|
-
"homepage": "https://github.com/
|
|
77
|
+
"homepage": "https://github.com/anthropic-experimental/sandbox-runtime#readme"
|
|
72
78
|
}
|