@enclave-vm/core 2.14.1 → 2.15.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enclave-vm/core",
3
- "version": "2.14.1",
3
+ "version": "2.15.1",
4
4
  "description": "Sandbox runtime for secure JavaScript code execution",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "homepage": "https://github.com/agentfront/enclave",
@@ -44,8 +44,8 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@babel/standalone": "^7.29.0",
47
- "@enclave-vm/ast": "2.14.1",
48
- "@enclave-vm/types": "2.14.1",
47
+ "@enclave-vm/ast": "2.15.1",
48
+ "@enclave-vm/types": "2.15.1",
49
49
  "@types/estree": "1.0.8",
50
50
  "acorn": "8.15.0",
51
51
  "acorn-walk": "8.3.4",
package/secure-proxy.d.ts CHANGED
@@ -15,6 +15,23 @@
15
15
  * @packageDocumentation
16
16
  */
17
17
  import type { SecureProxyLevelConfig, SecurityLevel } from './types';
18
+ /**
19
+ * Absolute floor for the membrane recursion cap.
20
+ *
21
+ * The recursion counter is a stack-safety backstop, NOT a security control: every level of the
22
+ * membrane already blocks the dangerous properties, so the cap value never decides whether an
23
+ * escape is possible. Its only job is to stop pathological recursion. It must therefore sit
24
+ * comfortably above the deepest value that can legitimately reach the membrane (a tool result is
25
+ * pre-sanitized to at most `maxSanitizeDepth`, which peaks at 50), or legitimate deep data would
26
+ * be rejected (custom host globals are not sanitize-bounded, hence the generous ~5x headroom).
27
+ * The membrane is lazy (one property access = one wrap = O(1) synchronous stack), so a large
28
+ * value costs nothing. Exceeding the cap fails CLOSED (throws) — it must never hand back a raw
29
+ * target.
30
+ *
31
+ * Exported so tests can derive their traversal depth from the real cap instead of hardcoding a
32
+ * value that would silently rot if the cap changed.
33
+ */
34
+ export declare const MIN_MEMBRANE_RECURSION_DEPTH = 256;
18
35
  /**
19
36
  * Categorized blocked properties for defense-in-depth
20
37
  *
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enclave-vm/core",
3
- "version": "2.14.1",
3
+ "version": "2.15.1",
4
4
  "description": "Sandbox runtime for secure JavaScript code execution",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "homepage": "https://github.com/agentfront/enclave",
@@ -46,8 +46,8 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@babel/standalone": "^7.29.0",
49
- "@enclave-vm/ast": "2.14.1",
50
- "@enclave-vm/types": "2.14.1",
49
+ "@enclave-vm/ast": "2.15.1",
50
+ "@enclave-vm/types": "2.15.1",
51
51
  "@types/estree": "1.0.8",
52
52
  "acorn": "8.15.0",
53
53
  "acorn-walk": "8.3.4",
@@ -57,6 +57,29 @@ var MessageSizeError = class extends WorkerPoolError {
57
57
  };
58
58
 
59
59
  // libs/core/src/adapters/worker-pool/safe-deserialize.ts
60
+ var ReflectGet = Reflect.get;
61
+ var ArrayIsArray = Array.isArray;
62
+ var NumberIsFinite = Number.isFinite;
63
+ var MathFloor = Math.floor;
64
+ var MAX_ARRAY_LENGTH = 1e6;
65
+ function mapArraySafely(value, sanitizeItem) {
66
+ const rawLen = ReflectGet(value, "length");
67
+ const len = typeof rawLen === "number" && NumberIsFinite(rawLen) && rawLen >= 0 ? MathFloor(rawLen) : 0;
68
+ if (len > MAX_ARRAY_LENGTH) {
69
+ throw new MessageValidationError(`Array exceeds maximum length of ${MAX_ARRAY_LENGTH}`);
70
+ }
71
+ const out = [];
72
+ for (let i = 0; i < len; i++) {
73
+ let item;
74
+ try {
75
+ item = ReflectGet(value, i);
76
+ } catch {
77
+ item = void 0;
78
+ }
79
+ out[i] = sanitizeItem(item);
80
+ }
81
+ return out;
82
+ }
60
83
  var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
61
84
  var MAX_DEPTH = 50;
62
85
  function safeDeserialize(raw, maxSizeBytes) {
@@ -86,8 +109,8 @@ function sanitizeObjectWithDepthCheck(value, depth) {
86
109
  if (typeof value !== "object") {
87
110
  return value;
88
111
  }
89
- if (Array.isArray(value)) {
90
- return value.map((item) => sanitizeObjectWithDepthCheck(item, depth + 1));
112
+ if (ArrayIsArray(value)) {
113
+ return mapArraySafely(value, (item) => sanitizeObjectWithDepthCheck(item, depth + 1));
91
114
  }
92
115
  const result = /* @__PURE__ */ Object.create(null);
93
116
  for (const key of Object.keys(value)) {
@@ -115,8 +138,8 @@ function sanitizeObject(value, depth = 0) {
115
138
  if (typeof value !== "object") {
116
139
  return value;
117
140
  }
118
- if (Array.isArray(value)) {
119
- return value.map((item) => sanitizeObject(item, depth + 1));
141
+ if (ArrayIsArray(value)) {
142
+ return mapArraySafely(value, (item) => sanitizeObject(item, depth + 1));
120
143
  }
121
144
  const result = /* @__PURE__ */ Object.create(null);
122
145
  for (const key of Object.keys(value)) {