@voratiq/sandbox-runtime 0.7.0-voratiq1

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 (81) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +11 -0
  4. package/README.md +17 -0
  5. package/dist/cli.d.ts +3 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +243 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/index.d.ts +8 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +7 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/sandbox/generate-seccomp-filter.d.ts +56 -0
  14. package/dist/sandbox/generate-seccomp-filter.d.ts.map +1 -0
  15. package/dist/sandbox/generate-seccomp-filter.js +158 -0
  16. package/dist/sandbox/generate-seccomp-filter.js.map +1 -0
  17. package/dist/sandbox/http-proxy.d.ts +12 -0
  18. package/dist/sandbox/http-proxy.d.ts.map +1 -0
  19. package/dist/sandbox/http-proxy.js +489 -0
  20. package/dist/sandbox/http-proxy.js.map +1 -0
  21. package/dist/sandbox/linux-sandbox-utils.d.ts +111 -0
  22. package/dist/sandbox/linux-sandbox-utils.d.ts.map +1 -0
  23. package/dist/sandbox/linux-sandbox-utils.js +518 -0
  24. package/dist/sandbox/linux-sandbox-utils.js.map +1 -0
  25. package/dist/sandbox/macos-sandbox-utils.d.ts +54 -0
  26. package/dist/sandbox/macos-sandbox-utils.d.ts.map +1 -0
  27. package/dist/sandbox/macos-sandbox-utils.js +559 -0
  28. package/dist/sandbox/macos-sandbox-utils.js.map +1 -0
  29. package/dist/sandbox/sandbox-config.d.ts +170 -0
  30. package/dist/sandbox/sandbox-config.d.ts.map +1 -0
  31. package/dist/sandbox/sandbox-config.js +126 -0
  32. package/dist/sandbox/sandbox-config.js.map +1 -0
  33. package/dist/sandbox/sandbox-manager.d.ts +35 -0
  34. package/dist/sandbox/sandbox-manager.d.ts.map +1 -0
  35. package/dist/sandbox/sandbox-manager.js +666 -0
  36. package/dist/sandbox/sandbox-manager.js.map +1 -0
  37. package/dist/sandbox/sandbox-schemas.d.ts +17 -0
  38. package/dist/sandbox/sandbox-schemas.d.ts.map +1 -0
  39. package/dist/sandbox/sandbox-schemas.js +2 -0
  40. package/dist/sandbox/sandbox-schemas.js.map +1 -0
  41. package/dist/sandbox/sandbox-utils.d.ts +53 -0
  42. package/dist/sandbox/sandbox-utils.d.ts.map +1 -0
  43. package/dist/sandbox/sandbox-utils.js +368 -0
  44. package/dist/sandbox/sandbox-utils.js.map +1 -0
  45. package/dist/sandbox/sandbox-violation-store.d.ts +19 -0
  46. package/dist/sandbox/sandbox-violation-store.d.ts.map +1 -0
  47. package/dist/sandbox/sandbox-violation-store.js +54 -0
  48. package/dist/sandbox/sandbox-violation-store.js.map +1 -0
  49. package/dist/sandbox/socks-proxy.d.ts +18 -0
  50. package/dist/sandbox/socks-proxy.d.ts.map +1 -0
  51. package/dist/sandbox/socks-proxy.js +242 -0
  52. package/dist/sandbox/socks-proxy.js.map +1 -0
  53. package/dist/utils/debug.d.ts +7 -0
  54. package/dist/utils/debug.d.ts.map +1 -0
  55. package/dist/utils/debug.js +22 -0
  56. package/dist/utils/debug.js.map +1 -0
  57. package/dist/utils/platform.d.ts +6 -0
  58. package/dist/utils/platform.d.ts.map +1 -0
  59. package/dist/utils/platform.js +16 -0
  60. package/dist/utils/platform.js.map +1 -0
  61. package/dist/utils/ripgrep.d.ts +20 -0
  62. package/dist/utils/ripgrep.d.ts.map +1 -0
  63. package/dist/utils/ripgrep.js +51 -0
  64. package/dist/utils/ripgrep.js.map +1 -0
  65. package/dist/utils/telemetry.d.ts +67 -0
  66. package/dist/utils/telemetry.d.ts.map +1 -0
  67. package/dist/utils/telemetry.js +249 -0
  68. package/dist/utils/telemetry.js.map +1 -0
  69. package/dist/vendor/seccomp/arm64/apply-seccomp +0 -0
  70. package/dist/vendor/seccomp/arm64/unix-block.bpf +0 -0
  71. package/dist/vendor/seccomp/x64/apply-seccomp +0 -0
  72. package/dist/vendor/seccomp/x64/unix-block.bpf +0 -0
  73. package/dist/vendor/seccomp-src/apply-seccomp.c +98 -0
  74. package/dist/vendor/seccomp-src/seccomp-unix-block.c +97 -0
  75. package/package.json +80 -0
  76. package/vendor/seccomp/arm64/apply-seccomp +0 -0
  77. package/vendor/seccomp/arm64/unix-block.bpf +0 -0
  78. package/vendor/seccomp/x64/apply-seccomp +0 -0
  79. package/vendor/seccomp/x64/unix-block.bpf +0 -0
  80. package/vendor/seccomp-src/apply-seccomp.c +98 -0
  81. package/vendor/seccomp-src/seccomp-unix-block.c +97 -0
@@ -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
+ }