@enclave-vm/core 2.15.1 → 2.15.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/esm/index.mjs CHANGED
@@ -70,6 +70,7 @@ function getBlockedPropertiesForLevel(level) {
70
70
  const blocked = /* @__PURE__ */ new Set();
71
71
  if (level !== "PERMISSIVE") {
72
72
  BLOCKED_PROPERTY_CATEGORIES.PROTOTYPE.forEach((p) => blocked.add(p));
73
+ BLOCKED_PROPERTY_CATEGORIES.DESCRIPTOR_MUTATION.forEach((p) => blocked.add(p));
73
74
  }
74
75
  switch (level) {
75
76
  case "STRICT":
@@ -90,6 +91,7 @@ function buildBlockedPropertiesFromConfig(config) {
90
91
  const blocked = /* @__PURE__ */ new Set();
91
92
  if (config.blockConstructor) {
92
93
  blocked.add("constructor");
94
+ BLOCKED_PROPERTY_CATEGORIES.DESCRIPTOR_MUTATION.forEach((p) => blocked.add(p));
93
95
  }
94
96
  if (config.blockPrototype) {
95
97
  blocked.add("__proto__");
@@ -112,27 +114,35 @@ function createSafeReflect(securityLevel) {
112
114
  dangerousMethods.add("apply");
113
115
  dangerousMethods.add("defineProperty");
114
116
  }
115
- return new Proxy(Reflect, {
116
- get(target, prop) {
117
+ const refuseMutation = () => {
118
+ throw createSafeError("Reflect is read-only in the sandbox", "SecurityError");
119
+ };
120
+ return new Proxy(ReflectObject, {
121
+ set: refuseMutation,
122
+ defineProperty: refuseMutation,
123
+ deleteProperty: refuseMutation,
124
+ setPrototypeOf: refuseMutation,
125
+ preventExtensions: refuseMutation,
126
+ get(_target, prop) {
117
127
  if (typeof prop === "string" && dangerousMethods.has(prop)) {
118
128
  return void 0;
119
129
  }
120
- const value = Reflect.get(target, prop);
130
+ if (!PINNED_REFLECT_VALUES.has(prop)) {
131
+ return void 0;
132
+ }
133
+ const value = PINNED_REFLECT_VALUES.get(prop);
121
134
  if (typeof value === "function" && prop === "construct") {
122
- const safeConstruct = function(ctorTarget, args, newTarget) {
123
- const AsyncFunction = async function() {
124
- }.constructor;
125
- const GeneratorFunction = function* () {
126
- }.constructor;
127
- const AsyncGeneratorFunction = async function* () {
128
- }.constructor;
129
- if (ctorTarget === Function || ctorTarget === AsyncFunction || ctorTarget === GeneratorFunction || ctorTarget === AsyncGeneratorFunction) {
135
+ const safeConstruct = function(ctorTarget, args, ...newTarget) {
136
+ if (ctorTarget === FunctionCtor || ctorTarget === AsyncFunctionCtor || ctorTarget === GeneratorFunctionCtor || ctorTarget === AsyncGeneratorFunctionCtor) {
130
137
  throw createSafeError("Reflect.construct with function constructors is blocked", "SecurityError");
131
138
  }
132
- return Reflect.construct(
139
+ if (newTarget.length === 0) {
140
+ return ReflectConstruct(ctorTarget, args);
141
+ }
142
+ return ReflectConstruct(
133
143
  ctorTarget,
134
144
  args,
135
- newTarget
145
+ newTarget[0]
136
146
  );
137
147
  };
138
148
  return createSecureProxy(safeConstruct);
@@ -169,7 +179,7 @@ function getFullCacheKey(options) {
169
179
  function isProxyable(value) {
170
180
  if (value === null) return false;
171
181
  if (typeof value !== "object" && typeof value !== "function") return false;
172
- const tag = Object.prototype.toString.call(value);
182
+ const tag = ReflectApply(ObjectToString, value, []);
173
183
  if (NON_PROXYABLE_TYPES.has(tag)) {
174
184
  return false;
175
185
  }
@@ -212,7 +222,7 @@ function createSecureProxy(target, options = {}) {
212
222
  const proxy = new Proxy(obj, {
213
223
  get(target2, property, receiver) {
214
224
  const propName = typeof property === "symbol" ? property.toString() : property;
215
- const descriptor = Object.getOwnPropertyDescriptor(target2, property);
225
+ const descriptor = ObjectGetOwnPropertyDescriptor(target2, property);
216
226
  if (descriptor && !descriptor.configurable && descriptor.writable === false && "value" in descriptor) {
217
227
  const exactValue = descriptor.value;
218
228
  if (exactValue !== null && (typeof exactValue === "object" || typeof exactValue === "function")) {
@@ -247,11 +257,11 @@ function createSecureProxy(target, options = {}) {
247
257
  }
248
258
  return void 0;
249
259
  }
250
- const value = Reflect.get(target2, property, receiver);
260
+ const value = ReflectGet(target2, property, receiver);
251
261
  if (typeof value === "function") {
252
- const tag = Object.prototype.toString.call(target2);
262
+ const tag = ReflectApply(ObjectToString, target2, []);
253
263
  if (INTERNAL_SLOT_TYPES.has(tag)) {
254
- const boundMethod = value.bind(target2);
264
+ const boundMethod = ReflectApply(FunctionBind, value, [target2]);
255
265
  return proxyWithDepth(boundMethod, depth + 1);
256
266
  }
257
267
  }
@@ -275,7 +285,7 @@ function createSecureProxy(target, options = {}) {
275
285
  }
276
286
  return false;
277
287
  }
278
- return Reflect.set(target2, property, value, receiver);
288
+ return ReflectSet(target2, property, value, receiver);
279
289
  },
280
290
  // Block defining dangerous properties
281
291
  defineProperty(target2, property, descriptor) {
@@ -292,18 +302,18 @@ function createSecureProxy(target, options = {}) {
292
302
  }
293
303
  return false;
294
304
  }
295
- return Reflect.defineProperty(target2, property, descriptor);
305
+ return ReflectDefineProperty(target2, property, descriptor);
296
306
  },
297
307
  // Filter blocked property names from enumeration (Object.keys, Object.entries, etc.)
298
308
  // Must respect proxy invariants: non-configurable own properties cannot be hidden
299
309
  ownKeys(target2) {
300
- const keys = Reflect.ownKeys(target2);
310
+ const keys = ReflectOwnKeys(target2);
301
311
  return keys.filter((key) => {
302
312
  const keyStr = typeof key === "symbol" ? key.toString() : key;
303
313
  if (typeof keyStr !== "string" || !blockedSet.has(keyStr)) {
304
314
  return true;
305
315
  }
306
- const descriptor = Object.getOwnPropertyDescriptor(target2, key);
316
+ const descriptor = ObjectGetOwnPropertyDescriptor(target2, key);
307
317
  if (descriptor && !descriptor.configurable) {
308
318
  return true;
309
319
  }
@@ -314,7 +324,7 @@ function createSecureProxy(target, options = {}) {
314
324
  // Must respect proxy invariants: non-configurable properties must return actual descriptor
315
325
  getOwnPropertyDescriptor(target2, property) {
316
326
  const propName = typeof property === "symbol" ? property.toString() : property;
317
- const descriptor = Reflect.getOwnPropertyDescriptor(target2, property);
327
+ const descriptor = ReflectGetOwnPropertyDescriptor(target2, property);
318
328
  if (descriptor && !descriptor.configurable && descriptor.writable === false && "value" in descriptor) {
319
329
  const exactValue = descriptor.value;
320
330
  if (exactValue !== null && (typeof exactValue === "object" || typeof exactValue === "function")) {
@@ -373,7 +383,7 @@ function createSecureProxy(target, options = {}) {
373
383
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Proxy handler signature requires any for compatibility
374
384
  apply(target2, thisArg, argArray) {
375
385
  const unwrappedThis = thisArg !== null && (typeof thisArg === "object" || typeof thisArg === "function") && proxyToTarget.has(thisArg) ? proxyToTarget.get(thisArg) : thisArg;
376
- const result = Reflect.apply(target2, unwrappedThis, argArray);
386
+ const result = ReflectApply(target2, unwrappedThis, argArray);
377
387
  if (isProxyable(result)) {
378
388
  return proxyWithDepth(result, depth + 1);
379
389
  }
@@ -384,7 +394,7 @@ function createSecureProxy(target, options = {}) {
384
394
  // host Function constructor — the same escape class the apply trap closes for calls.
385
395
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Proxy handler signature requires any for compatibility
386
396
  construct(target2, argArray, newTarget) {
387
- const instance = Reflect.construct(target2, argArray, newTarget === proxy ? target2 : newTarget);
397
+ const instance = ReflectConstruct(target2, argArray, newTarget === proxy ? target2 : newTarget);
388
398
  if (isProxyable(instance)) {
389
399
  return proxyWithDepth(instance, depth + 1);
390
400
  }
@@ -438,11 +448,33 @@ function isSecureProxy(obj) {
438
448
  }
439
449
  return proxySet.has(obj);
440
450
  }
441
- var MIN_MEMBRANE_RECURSION_DEPTH, BLOCKED_PROPERTY_CATEGORIES, BLOCKED_PROPERTIES, DEFAULT_SECURE_PROXY_CONFIG, FUNCTION_BLOCKED_PROPERTIES, proxyCache, proxySet, proxyToTarget, NON_PROXYABLE_TYPES, INTERNAL_SLOT_TYPES;
451
+ var ObjectGetOwnPropertyDescriptor, ObjectToString, FunctionBind, ReflectGet, ReflectSet, ReflectDefineProperty, ReflectGetOwnPropertyDescriptor, ReflectOwnKeys, ReflectApply, ReflectConstruct, ReflectObject, PINNED_REFLECT_VALUES, FunctionCtor, AsyncFunctionCtor, GeneratorFunctionCtor, AsyncGeneratorFunctionCtor, MIN_MEMBRANE_RECURSION_DEPTH, BLOCKED_PROPERTY_CATEGORIES, BLOCKED_PROPERTIES, DEFAULT_SECURE_PROXY_CONFIG, FUNCTION_BLOCKED_PROPERTIES, proxyCache, proxySet, proxyToTarget, NON_PROXYABLE_TYPES, INTERNAL_SLOT_TYPES;
442
452
  var init_secure_proxy = __esm({
443
453
  "libs/core/src/secure-proxy.ts"() {
444
454
  "use strict";
445
455
  init_safe_error();
456
+ ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
457
+ ObjectToString = Object.prototype.toString;
458
+ FunctionBind = Function.prototype.bind;
459
+ ReflectGet = Reflect.get;
460
+ ReflectSet = Reflect.set;
461
+ ReflectDefineProperty = Reflect.defineProperty;
462
+ ReflectGetOwnPropertyDescriptor = Reflect.getOwnPropertyDescriptor;
463
+ ReflectOwnKeys = Reflect.ownKeys;
464
+ ReflectApply = Reflect.apply;
465
+ ReflectConstruct = Reflect.construct;
466
+ ReflectObject = Reflect;
467
+ PINNED_REFLECT_VALUES = /* @__PURE__ */ new Map();
468
+ for (const key of ReflectOwnKeys(ReflectObject)) {
469
+ PINNED_REFLECT_VALUES.set(key, ReflectGet(ReflectObject, key));
470
+ }
471
+ FunctionCtor = Function;
472
+ AsyncFunctionCtor = async function() {
473
+ }.constructor;
474
+ GeneratorFunctionCtor = function* () {
475
+ }.constructor;
476
+ AsyncGeneratorFunctionCtor = async function* () {
477
+ }.constructor;
446
478
  MIN_MEMBRANE_RECURSION_DEPTH = 256;
447
479
  BLOCKED_PROPERTY_CATEGORIES = {
448
480
  /**
@@ -457,6 +489,23 @@ var init_secure_proxy = __esm({
457
489
  "__lookupGetter__",
458
490
  "__lookupSetter__"
459
491
  ]),
492
+ /**
493
+ * Property-descriptor and prototype MUTATION gadgets. These are the primitives behind the
494
+ * GHSA-3279 membrane self-leak (`Object.defineProperty(Object, 'getOwnPropertyDescriptor', hook)`
495
+ * to intercept the trap's raw target) and classic prototype pollution (`setPrototypeOf`). They
496
+ * are never needed by AgentScript and are already refused by the single-VM SafeObject
497
+ * (`DANGEROUS_OBJECT_STATIC_METHODS`), so they are blocked at every level that blocks the
498
+ * constructor (all except PERMISSIVE). Read-only reflection (getPrototypeOf, keys, entries,
499
+ * getOwnPropertyNames) is intentionally NOT here: the membrane's own getPrototypeOf/ownKeys traps
500
+ * already neutralize it for proxied values, and it has legitimate uses.
501
+ */
502
+ DESCRIPTOR_MUTATION: /* @__PURE__ */ new Set([
503
+ "getOwnPropertyDescriptor",
504
+ "getOwnPropertyDescriptors",
505
+ "defineProperty",
506
+ "defineProperties",
507
+ "setPrototypeOf"
508
+ ]),
460
509
  /**
461
510
  * Node.js 24 Iterator helper method names
462
511
  * Blocked at STRICT/SECURE to prevent prototype chain access via iterators
@@ -498,7 +547,13 @@ var init_secure_proxy = __esm({
498
547
  "__defineGetter__",
499
548
  "__defineSetter__",
500
549
  "__lookupGetter__",
501
- "__lookupSetter__"
550
+ "__lookupSetter__",
551
+ // Descriptor / prototype mutation gadgets (GHSA-3279 self-leak + prototype pollution)
552
+ "getOwnPropertyDescriptor",
553
+ "getOwnPropertyDescriptors",
554
+ "defineProperty",
555
+ "defineProperties",
556
+ "setPrototypeOf"
502
557
  ]);
503
558
  DEFAULT_SECURE_PROXY_CONFIG = {
504
559
  blockConstructor: true,
@@ -674,7 +729,7 @@ var init_reference_config = __esm({
674
729
 
675
730
  // libs/core/src/sidecar/reference-resolver.ts
676
731
  function untrustedLength(value) {
677
- const rawLen = ReflectGet(value, "length");
732
+ const rawLen = ReflectGet2(value, "length");
678
733
  if (typeof rawLen !== "number" || !NumberIsFinite(rawLen) || rawLen < 0) {
679
734
  return 0;
680
735
  }
@@ -691,7 +746,7 @@ function untrustedLength(value) {
691
746
  }
692
747
  function untrustedAt(value, index) {
693
748
  try {
694
- return ReflectGet(value, index);
749
+ return ReflectGet2(value, index);
695
750
  } catch {
696
751
  return void 0;
697
752
  }
@@ -700,12 +755,12 @@ function isCompositeHandle(value) {
700
755
  const obj = value;
701
756
  return typeof value === "object" && value !== null && obj["__type"] === "composite" && Array.isArray(obj["__parts"]);
702
757
  }
703
- var ReflectGet, NumberIsFinite, MathFloor, MAX_TRAVERSAL_LENGTH, ResolutionLimitError, ReferenceResolver;
758
+ var ReflectGet2, NumberIsFinite, MathFloor, MAX_TRAVERSAL_LENGTH, ResolutionLimitError, ReferenceResolver;
704
759
  var init_reference_resolver = __esm({
705
760
  "libs/core/src/sidecar/reference-resolver.ts"() {
706
761
  "use strict";
707
762
  init_reference_config();
708
- ReflectGet = Reflect.get;
763
+ ReflectGet2 = Reflect.get;
709
764
  NumberIsFinite = Number.isFinite;
710
765
  MathFloor = Math.floor;
711
766
  MAX_TRAVERSAL_LENGTH = 1e6;
@@ -977,7 +1032,7 @@ function sanitizeValue(value, options = {}, depth = 0, context = { propCount: {
977
1032
  context.visited.add(value);
978
1033
  }
979
1034
  if (ArrayIsArray(value)) {
980
- const rawLen = ReflectGet2(value, "length");
1035
+ const rawLen = ReflectGet3(value, "length");
981
1036
  const len = typeof rawLen === "number" && NumberIsFinite2(rawLen) && rawLen >= 0 ? MathFloor2(rawLen) : 0;
982
1037
  context.propCount.count += len;
983
1038
  if (context.propCount.count > maxProperties) {
@@ -987,7 +1042,7 @@ function sanitizeValue(value, options = {}, depth = 0, context = { propCount: {
987
1042
  for (let i = 0; i < len; i++) {
988
1043
  let item;
989
1044
  try {
990
- item = ReflectGet2(value, i);
1045
+ item = ReflectGet3(value, i);
991
1046
  } catch {
992
1047
  item = void 0;
993
1048
  }
@@ -996,15 +1051,15 @@ function sanitizeValue(value, options = {}, depth = 0, context = { propCount: {
996
1051
  return result;
997
1052
  }
998
1053
  if (value instanceof Date) {
999
- const time = ReflectApply(DateProtoGetTime, value, []);
1054
+ const time = ReflectApply2(DateProtoGetTime, value, []);
1000
1055
  if (allowDates) {
1001
1056
  return new Date(time);
1002
1057
  }
1003
- return ReflectApply(DateProtoToISOString, value, []);
1058
+ return ReflectApply2(DateProtoToISOString, value, []);
1004
1059
  }
1005
1060
  if (value instanceof Error) {
1006
- const rawName = ReflectGet2(value, "name");
1007
- const rawMessage = ReflectGet2(value, "message");
1061
+ const rawName = ReflectGet3(value, "name");
1062
+ const rawMessage = ReflectGet3(value, "message");
1008
1063
  const name = typeof rawName === "string" ? rawName : "Error";
1009
1064
  const message = typeof rawMessage === "string" ? rawMessage : "";
1010
1065
  if (allowErrors) {
@@ -1017,11 +1072,11 @@ function sanitizeValue(value, options = {}, depth = 0, context = { propCount: {
1017
1072
  return { error: message };
1018
1073
  }
1019
1074
  if (value instanceof RegExp) {
1020
- return ReflectApply(RegExpProtoToString, value, []);
1075
+ return ReflectApply2(RegExpProtoToString, value, []);
1021
1076
  }
1022
1077
  if (value instanceof Map) {
1023
1078
  const sanitizedMap = ObjectCreate(null);
1024
- const entries = ReflectApply(MapProtoEntries, value, []);
1079
+ const entries = ReflectApply2(MapProtoEntries, value, []);
1025
1080
  for (const [key, val] of entries) {
1026
1081
  if (typeof key !== "string") continue;
1027
1082
  if (DANGEROUS_KEYS.has(key)) continue;
@@ -1031,7 +1086,7 @@ function sanitizeValue(value, options = {}, depth = 0, context = { propCount: {
1031
1086
  return sanitizedMap;
1032
1087
  }
1033
1088
  if (value instanceof Set) {
1034
- const iter = ReflectApply(SetProtoValues, value, []);
1089
+ const iter = ReflectApply2(SetProtoValues, value, []);
1035
1090
  const result = [];
1036
1091
  for (const item of iter) {
1037
1092
  context.propCount.count++;
@@ -1052,7 +1107,7 @@ function sanitizeValue(value, options = {}, depth = 0, context = { propCount: {
1052
1107
  }
1053
1108
  let propValue;
1054
1109
  try {
1055
- propValue = ReflectGet2(value, key);
1110
+ propValue = ReflectGet3(value, key);
1056
1111
  } catch {
1057
1112
  continue;
1058
1113
  }
@@ -1190,13 +1245,13 @@ function checkSerializedSize(value, maxBytes) {
1190
1245
  return { ok: false, error: err instanceof Error ? err.message : "Unknown error" };
1191
1246
  }
1192
1247
  }
1193
- var DANGEROUS_KEYS, ReflectApply, ReflectGet2, ArrayIsArray, ObjectKeys, ObjectCreate, NumberIsFinite2, MathFloor2, MapProtoEntries, SetProtoValues, DateProtoGetTime, DateProtoToISOString, RegExpProtoToString;
1248
+ var DANGEROUS_KEYS, ReflectApply2, ReflectGet3, ArrayIsArray, ObjectKeys, ObjectCreate, NumberIsFinite2, MathFloor2, MapProtoEntries, SetProtoValues, DateProtoGetTime, DateProtoToISOString, RegExpProtoToString;
1194
1249
  var init_value_sanitizer = __esm({
1195
1250
  "libs/core/src/value-sanitizer.ts"() {
1196
1251
  "use strict";
1197
1252
  DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor"]);
1198
- ReflectApply = Reflect.apply;
1199
- ReflectGet2 = Reflect.get;
1253
+ ReflectApply2 = Reflect.apply;
1254
+ ReflectGet3 = Reflect.get;
1200
1255
  ArrayIsArray = Array.isArray;
1201
1256
  ObjectKeys = Object.keys;
1202
1257
  ObjectCreate = Object.create;
@@ -2216,6 +2271,29 @@ ${stackTraceHardeningCode}
2216
2271
  } catch (e) { /* ignore */ }
2217
2272
  }
2218
2273
 
2274
+ // SECURITY (GHSA-3279): pin pristine intrinsics BEFORE any sandbox code runs, so the membrane
2275
+ // traps and the error hardening below never re-read a realm global the sandbox can overwrite.
2276
+ // The reported escape replaced Object.getOwnPropertyDescriptor with a hook; the get trap then
2277
+ // called it and handed the attacker the RAW target of a membrane proxy (the host Promise from
2278
+ // callTool), reaching the host Function constructor. The same gadget aimed at the Object.*
2279
+ // mutators below would let an attacker observe safe-error construction or defeat the final
2280
+ // freeze, leaving the returned error with a live prototype and constructor chain. Using
2281
+ // captured references makes a later monkeypatch a no-op.
2282
+ const __ag_getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2283
+ const __ag_defineProperty = Object.defineProperty;
2284
+ const __ag_defineProperties = Object.defineProperties;
2285
+ const __ag_setPrototypeOf = Object.setPrototypeOf;
2286
+ const __ag_objectCreate = Object.create;
2287
+ const __ag_objectFreeze = Object.freeze;
2288
+ const __ag_ReflectGet = Reflect.get;
2289
+ const __ag_ReflectSet = Reflect.set;
2290
+ const __ag_ReflectDefineProperty = Reflect.defineProperty;
2291
+ const __ag_ReflectGetOwnPropertyDescriptor = Reflect.getOwnPropertyDescriptor;
2292
+ const __ag_ReflectOwnKeys = Reflect.ownKeys;
2293
+ const __ag_ReflectApply = Reflect.apply;
2294
+ const __ag_hasOwnProperty = Object.prototype.hasOwnProperty;
2295
+ const __ag_functionBind = Function.prototype.bind;
2296
+
2219
2297
  /**
2220
2298
  * Creates a "safe" error object that cannot be used to escape the sandbox.
2221
2299
  *
@@ -2238,7 +2316,7 @@ ${stackTraceHardeningCode}
2238
2316
  var error = new Error(message);
2239
2317
  // NOTE: Use Object.defineProperty instead of direct assignment because
2240
2318
  // Error.prototype.name is frozen, and in strict mode direct assignment fails.
2241
- Object.defineProperty(error, 'name', {
2319
+ __ag_defineProperty(error, 'name', {
2242
2320
  value: name,
2243
2321
  writable: true,
2244
2322
  enumerable: false,
@@ -2247,12 +2325,12 @@ ${stackTraceHardeningCode}
2247
2325
 
2248
2326
  // CRITICAL: sever the *actual* prototype chain (native getters / Object.getPrototypeOf).
2249
2327
  // A shadowing __proto__ data property is not sufficient.
2250
- Object.setPrototypeOf(error, null);
2328
+ __ag_setPrototypeOf(error, null);
2251
2329
 
2252
2330
  // Create a null-prototype object to use as a safe "constructor"
2253
2331
  // This object has no prototype chain to climb
2254
- var SafeConstructor = Object.create(null);
2255
- Object.defineProperties(SafeConstructor, {
2332
+ var SafeConstructor = __ag_objectCreate(null);
2333
+ __ag_defineProperties(SafeConstructor, {
2256
2334
  // Make constructor point to itself to break the chain
2257
2335
  constructor: {
2258
2336
  value: SafeConstructor,
@@ -2275,11 +2353,11 @@ ${stackTraceHardeningCode}
2275
2353
  configurable: false
2276
2354
  }
2277
2355
  });
2278
- Object.freeze(SafeConstructor);
2356
+ __ag_objectFreeze(SafeConstructor);
2279
2357
 
2280
2358
  // Override the constructor property on the error instance
2281
2359
  // This breaks the prototype chain: err.constructor.constructor no longer reaches Function
2282
- Object.defineProperty(error, 'constructor', {
2360
+ __ag_defineProperty(error, 'constructor', {
2283
2361
  value: SafeConstructor,
2284
2362
  writable: false,
2285
2363
  enumerable: false,
@@ -2288,7 +2366,7 @@ ${stackTraceHardeningCode}
2288
2366
 
2289
2367
  // SECURITY: Override __proto__ on the error instance to prevent prototype chain escape
2290
2368
  // Attack vector blocked: err.__proto__.constructor.constructor('malicious code')()
2291
- Object.defineProperty(error, '__proto__', {
2369
+ __ag_defineProperty(error, '__proto__', {
2292
2370
  value: null,
2293
2371
  writable: false,
2294
2372
  enumerable: false,
@@ -2298,7 +2376,7 @@ ${stackTraceHardeningCode}
2298
2376
  // SECURITY: Remove the stack property to prevent information leakage (Vector 1230)
2299
2377
  // The stack trace can reveal internal implementation details like function names,
2300
2378
  // file paths, and line numbers which can be used for reconnaissance attacks.
2301
- Object.defineProperty(error, 'stack', {
2379
+ __ag_defineProperty(error, 'stack', {
2302
2380
  value: undefined,
2303
2381
  writable: false,
2304
2382
  enumerable: false,
@@ -2307,7 +2385,7 @@ ${stackTraceHardeningCode}
2307
2385
 
2308
2386
  // Add a unique marker to identify this as a safe error from our runtime
2309
2387
  // This is used by suspicious pattern detection to distinguish our errors from user errors
2310
- Object.defineProperty(error, SAFE_ERROR_MARKER, {
2388
+ __ag_defineProperty(error, SAFE_ERROR_MARKER, {
2311
2389
  value: true,
2312
2390
  writable: false,
2313
2391
  enumerable: false,
@@ -2315,7 +2393,7 @@ ${stackTraceHardeningCode}
2315
2393
  });
2316
2394
 
2317
2395
  // Freeze the error to prevent modifications
2318
- Object.freeze(error);
2396
+ __ag_objectFreeze(error);
2319
2397
 
2320
2398
  return error;
2321
2399
  }
@@ -2405,7 +2483,7 @@ ${stackTraceHardeningCode}
2405
2483
  var propName = String(property);
2406
2484
 
2407
2485
  // Check if property is non-configurable (proxy invariant requires returning actual value)
2408
- var descriptor = Object.getOwnPropertyDescriptor(target, property);
2486
+ var descriptor = __ag_getOwnPropertyDescriptor(target, property);
2409
2487
  var isNonConfigurable = descriptor && !descriptor.configurable;
2410
2488
 
2411
2489
  // Proxy invariant: if the target has a non-configurable, non-writable data property,
@@ -2426,15 +2504,14 @@ ${stackTraceHardeningCode}
2426
2504
  return exactValue;
2427
2505
  }
2428
2506
 
2429
- // Block dangerous properties - but respect proxy invariants
2507
+ // Block dangerous properties. The ONLY [[Get]] invariant that forces a specific return
2508
+ // value is for a non-writable + non-configurable DATA property \u2014 already handled above.
2509
+ // Anything reaching here is configurable, a non-configurable WRITABLE data property (such
2510
+ // as a function own prototype), or a non-configurable accessor; the invariant constrains
2511
+ // none of these, so the trap must never hand back the raw value. GHSA-3279: the old
2512
+ // "isNonConfigurable and not host -> return Reflect.get(...)" branch leaked the raw
2513
+ // writable prototype, exposing a parent-realm Object and defeating the membrane.
2430
2514
  if (blockedPropertiesSet.has(propName)) {
2431
- // For non-configurable properties, we MUST return the actual value
2432
- // (JavaScript proxy invariant - can't hide non-configurable properties).
2433
- // Host-owned values instead deny the read: every descriptor shape that could force
2434
- // the trap's result was handled above, so returning undefined is invariant-safe.
2435
- if (isNonConfigurable && !host) {
2436
- return Reflect.get(target, property, receiver);
2437
- }
2438
2515
  if (throwOnBlocked) {
2439
2516
  throw createSafeError(
2440
2517
  "Security violation: Access to '" + propName + "' is blocked. " +
@@ -2444,12 +2521,12 @@ ${stackTraceHardeningCode}
2444
2521
  return undefined;
2445
2522
  }
2446
2523
 
2447
- var value = Reflect.get(target, property, receiver);
2524
+ var value = __ag_ReflectGet(target, property, receiver);
2448
2525
 
2449
2526
  // For function values, bind to target first (preserves internal slot access for Promises, etc.)
2450
2527
  // Then recursively proxy the bound function to block constructor access
2451
2528
  if (typeof value === 'function') {
2452
- var boundMethod = value.bind(target);
2529
+ var boundMethod = __ag_functionBind.call(value, target);
2453
2530
  return createSecureProxy(boundMethod, depth + 1, host);
2454
2531
  }
2455
2532
 
@@ -2472,7 +2549,7 @@ ${stackTraceHardeningCode}
2472
2549
  }
2473
2550
  return false;
2474
2551
  }
2475
- return Reflect.set(target, property, value, receiver);
2552
+ return __ag_ReflectSet(target, property, value, receiver);
2476
2553
  },
2477
2554
  defineProperty: function(target, property, descriptor) {
2478
2555
  var propName = String(property);
@@ -2485,11 +2562,11 @@ ${stackTraceHardeningCode}
2485
2562
  }
2486
2563
  return false;
2487
2564
  }
2488
- return Reflect.defineProperty(target, property, descriptor);
2565
+ return __ag_ReflectDefineProperty(target, property, descriptor);
2489
2566
  },
2490
2567
  getOwnPropertyDescriptor: function(target, property) {
2491
2568
  var propName = String(property);
2492
- var descriptor = Reflect.getOwnPropertyDescriptor(target, property);
2569
+ var descriptor = __ag_ReflectGetOwnPropertyDescriptor(target, property);
2493
2570
 
2494
2571
  // Mirror the get trap's host-owned pinned-value refusal: a non-configurable, non-writable
2495
2572
  // data property must be reported with its exact value (proxy invariant), so on a HOST-owned
@@ -2538,7 +2615,7 @@ ${stackTraceHardeningCode}
2538
2615
  // hands back a raw function that leads to the host Function constructor.
2539
2616
  if (descriptor && (typeof descriptor.get === 'function' || typeof descriptor.set === 'function')) {
2540
2617
  var accessorWrapped = {};
2541
- for (var ak in descriptor) { if (Object.prototype.hasOwnProperty.call(descriptor, ak)) accessorWrapped[ak] = descriptor[ak]; }
2618
+ for (var ak in descriptor) { if (__ag_hasOwnProperty.call(descriptor, ak)) accessorWrapped[ak] = descriptor[ak]; }
2542
2619
  if (typeof descriptor.get === 'function') accessorWrapped.get = createSecureProxy(descriptor.get, depth + 1, host);
2543
2620
  if (typeof descriptor.set === 'function') accessorWrapped.set = createSecureProxy(descriptor.set, depth + 1, host);
2544
2621
  return accessorWrapped;
@@ -2550,7 +2627,7 @@ ${stackTraceHardeningCode}
2550
2627
  var value = descriptor.value;
2551
2628
  if (value !== null && (typeof value === 'object' || typeof value === 'function')) {
2552
2629
  var wrapped = {};
2553
- for (var dk in descriptor) { if (Object.prototype.hasOwnProperty.call(descriptor, dk)) wrapped[dk] = descriptor[dk]; }
2630
+ for (var dk in descriptor) { if (__ag_hasOwnProperty.call(descriptor, dk)) wrapped[dk] = descriptor[dk]; }
2554
2631
  wrapped.value = createSecureProxy(value, depth + 1, host);
2555
2632
  return wrapped;
2556
2633
  }
@@ -2558,7 +2635,7 @@ ${stackTraceHardeningCode}
2558
2635
  return descriptor;
2559
2636
  },
2560
2637
  ownKeys: function(target) {
2561
- var keys = Reflect.ownKeys(target);
2638
+ var keys = __ag_ReflectOwnKeys(target);
2562
2639
  return keys.filter(function(key) {
2563
2640
  var keyStr = String(key);
2564
2641
  // Keep non-blocked properties
@@ -2566,7 +2643,7 @@ ${stackTraceHardeningCode}
2566
2643
  return true;
2567
2644
  }
2568
2645
  // Must keep non-configurable properties (proxy invariant)
2569
- var descriptor = Object.getOwnPropertyDescriptor(target, key);
2646
+ var descriptor = __ag_getOwnPropertyDescriptor(target, key);
2570
2647
  if (descriptor && !descriptor.configurable) {
2571
2648
  return true;
2572
2649
  }
@@ -2587,7 +2664,7 @@ ${stackTraceHardeningCode}
2587
2664
  // Results are re-wrapped at a FRESH depth (0) so a chain of calls such as
2588
2665
  // then().then() cannot inflate depth past the recursion cap and leak an unwrapped value.
2589
2666
  apply: function(target, thisArg, args) {
2590
- return createSecureProxy(Reflect.apply(target, thisArg, args), 0, host);
2667
+ return createSecureProxy(__ag_ReflectApply(target, thisArg, args), 0, host);
2591
2668
  }
2592
2669
  // NOTE: intentionally NO construct trap here (unlike the standalone secure-proxy used
2593
2670
  // for single-VM mode). Every constructor reachable from sandbox code resolves to an
@@ -2746,7 +2823,7 @@ ${stackTraceHardeningCode}
2746
2823
  }
2747
2824
 
2748
2825
  if (response.ok === true) {
2749
- if (Object.prototype.hasOwnProperty.call(response, 'value')) {
2826
+ if (__ag_hasOwnProperty.call(response, 'value')) {
2750
2827
  return response.value;
2751
2828
  }
2752
2829
  return undefined;
@@ -6287,7 +6364,7 @@ var init_errors = __esm({
6287
6364
 
6288
6365
  // libs/core/src/adapters/worker-pool/safe-deserialize.ts
6289
6366
  function mapArraySafely(value, sanitizeItem) {
6290
- const rawLen = ReflectGet3(value, "length");
6367
+ const rawLen = ReflectGet4(value, "length");
6291
6368
  const len = typeof rawLen === "number" && NumberIsFinite3(rawLen) && rawLen >= 0 ? MathFloor3(rawLen) : 0;
6292
6369
  if (len > MAX_ARRAY_LENGTH) {
6293
6370
  throw new MessageValidationError(`Array exceeds maximum length of ${MAX_ARRAY_LENGTH}`);
@@ -6296,7 +6373,7 @@ function mapArraySafely(value, sanitizeItem) {
6296
6373
  for (let i = 0; i < len; i++) {
6297
6374
  let item;
6298
6375
  try {
6299
- item = ReflectGet3(value, i);
6376
+ item = ReflectGet4(value, i);
6300
6377
  } catch {
6301
6378
  item = void 0;
6302
6379
  }
@@ -6371,12 +6448,12 @@ function sanitizeObject(value, depth = 0) {
6371
6448
  }
6372
6449
  return result;
6373
6450
  }
6374
- var ReflectGet3, ArrayIsArray2, NumberIsFinite3, MathFloor3, MAX_ARRAY_LENGTH, DANGEROUS_KEYS2, MAX_DEPTH;
6451
+ var ReflectGet4, ArrayIsArray2, NumberIsFinite3, MathFloor3, MAX_ARRAY_LENGTH, DANGEROUS_KEYS2, MAX_DEPTH;
6375
6452
  var init_safe_deserialize = __esm({
6376
6453
  "libs/core/src/adapters/worker-pool/safe-deserialize.ts"() {
6377
6454
  "use strict";
6378
6455
  init_errors();
6379
- ReflectGet3 = Reflect.get;
6456
+ ReflectGet4 = Reflect.get;
6380
6457
  ArrayIsArray2 = Array.isArray;
6381
6458
  NumberIsFinite3 = Number.isFinite;
6382
6459
  MathFloor3 = Math.floor;
@@ -11328,7 +11405,11 @@ var Interpreter = class {
11328
11405
  const obj = value ?? {};
11329
11406
  for (const prop of pattern.properties) {
11330
11407
  if (prop.type === "RestElement") continue;
11331
- const key = prop.key.name;
11408
+ if (prop.computed) throw new InterpreterError("Computed destructuring keys are not allowed");
11409
+ let key;
11410
+ if (prop.key.type === "Identifier") key = prop.key.name;
11411
+ else if (prop.key.type === "Literal") key = String(prop.key.value);
11412
+ else throw new InterpreterError("Unsupported destructuring key");
11332
11413
  if (BLOCKED_KEYS.has(key)) throw new InterpreterError(`Forbidden destructured key: ${key}`);
11333
11414
  this.bindPattern(prop.value, obj[key], scope, mutable);
11334
11415
  }
package/esm/worker.mjs CHANGED
@@ -526,7 +526,11 @@ var Interpreter = class {
526
526
  const obj = value ?? {};
527
527
  for (const prop of pattern.properties) {
528
528
  if (prop.type === "RestElement") continue;
529
- const key = prop.key.name;
529
+ if (prop.computed) throw new InterpreterError("Computed destructuring keys are not allowed");
530
+ let key;
531
+ if (prop.key.type === "Identifier") key = prop.key.name;
532
+ else if (prop.key.type === "Literal") key = String(prop.key.value);
533
+ else throw new InterpreterError("Unsupported destructuring key");
530
534
  if (BLOCKED_KEYS.has(key)) throw new InterpreterError(`Forbidden destructured key: ${key}`);
531
535
  this.bindPattern(prop.value, obj[key], scope, mutable);
532
536
  }
package/index.js CHANGED
@@ -92,6 +92,7 @@ function getBlockedPropertiesForLevel(level) {
92
92
  const blocked = /* @__PURE__ */ new Set();
93
93
  if (level !== "PERMISSIVE") {
94
94
  BLOCKED_PROPERTY_CATEGORIES.PROTOTYPE.forEach((p) => blocked.add(p));
95
+ BLOCKED_PROPERTY_CATEGORIES.DESCRIPTOR_MUTATION.forEach((p) => blocked.add(p));
95
96
  }
96
97
  switch (level) {
97
98
  case "STRICT":
@@ -112,6 +113,7 @@ function buildBlockedPropertiesFromConfig(config) {
112
113
  const blocked = /* @__PURE__ */ new Set();
113
114
  if (config.blockConstructor) {
114
115
  blocked.add("constructor");
116
+ BLOCKED_PROPERTY_CATEGORIES.DESCRIPTOR_MUTATION.forEach((p) => blocked.add(p));
115
117
  }
116
118
  if (config.blockPrototype) {
117
119
  blocked.add("__proto__");
@@ -134,27 +136,35 @@ function createSafeReflect(securityLevel) {
134
136
  dangerousMethods.add("apply");
135
137
  dangerousMethods.add("defineProperty");
136
138
  }
137
- return new Proxy(Reflect, {
138
- get(target, prop) {
139
+ const refuseMutation = () => {
140
+ throw createSafeError("Reflect is read-only in the sandbox", "SecurityError");
141
+ };
142
+ return new Proxy(ReflectObject, {
143
+ set: refuseMutation,
144
+ defineProperty: refuseMutation,
145
+ deleteProperty: refuseMutation,
146
+ setPrototypeOf: refuseMutation,
147
+ preventExtensions: refuseMutation,
148
+ get(_target, prop) {
139
149
  if (typeof prop === "string" && dangerousMethods.has(prop)) {
140
150
  return void 0;
141
151
  }
142
- const value = Reflect.get(target, prop);
152
+ if (!PINNED_REFLECT_VALUES.has(prop)) {
153
+ return void 0;
154
+ }
155
+ const value = PINNED_REFLECT_VALUES.get(prop);
143
156
  if (typeof value === "function" && prop === "construct") {
144
- const safeConstruct = function(ctorTarget, args, newTarget) {
145
- const AsyncFunction = async function() {
146
- }.constructor;
147
- const GeneratorFunction = function* () {
148
- }.constructor;
149
- const AsyncGeneratorFunction = async function* () {
150
- }.constructor;
151
- if (ctorTarget === Function || ctorTarget === AsyncFunction || ctorTarget === GeneratorFunction || ctorTarget === AsyncGeneratorFunction) {
157
+ const safeConstruct = function(ctorTarget, args, ...newTarget) {
158
+ if (ctorTarget === FunctionCtor || ctorTarget === AsyncFunctionCtor || ctorTarget === GeneratorFunctionCtor || ctorTarget === AsyncGeneratorFunctionCtor) {
152
159
  throw createSafeError("Reflect.construct with function constructors is blocked", "SecurityError");
153
160
  }
154
- return Reflect.construct(
161
+ if (newTarget.length === 0) {
162
+ return ReflectConstruct(ctorTarget, args);
163
+ }
164
+ return ReflectConstruct(
155
165
  ctorTarget,
156
166
  args,
157
- newTarget
167
+ newTarget[0]
158
168
  );
159
169
  };
160
170
  return createSecureProxy(safeConstruct);
@@ -191,7 +201,7 @@ function getFullCacheKey(options) {
191
201
  function isProxyable(value) {
192
202
  if (value === null) return false;
193
203
  if (typeof value !== "object" && typeof value !== "function") return false;
194
- const tag = Object.prototype.toString.call(value);
204
+ const tag = ReflectApply(ObjectToString, value, []);
195
205
  if (NON_PROXYABLE_TYPES.has(tag)) {
196
206
  return false;
197
207
  }
@@ -234,7 +244,7 @@ function createSecureProxy(target, options = {}) {
234
244
  const proxy = new Proxy(obj, {
235
245
  get(target2, property, receiver) {
236
246
  const propName = typeof property === "symbol" ? property.toString() : property;
237
- const descriptor = Object.getOwnPropertyDescriptor(target2, property);
247
+ const descriptor = ObjectGetOwnPropertyDescriptor(target2, property);
238
248
  if (descriptor && !descriptor.configurable && descriptor.writable === false && "value" in descriptor) {
239
249
  const exactValue = descriptor.value;
240
250
  if (exactValue !== null && (typeof exactValue === "object" || typeof exactValue === "function")) {
@@ -269,11 +279,11 @@ function createSecureProxy(target, options = {}) {
269
279
  }
270
280
  return void 0;
271
281
  }
272
- const value = Reflect.get(target2, property, receiver);
282
+ const value = ReflectGet(target2, property, receiver);
273
283
  if (typeof value === "function") {
274
- const tag = Object.prototype.toString.call(target2);
284
+ const tag = ReflectApply(ObjectToString, target2, []);
275
285
  if (INTERNAL_SLOT_TYPES.has(tag)) {
276
- const boundMethod = value.bind(target2);
286
+ const boundMethod = ReflectApply(FunctionBind, value, [target2]);
277
287
  return proxyWithDepth(boundMethod, depth + 1);
278
288
  }
279
289
  }
@@ -297,7 +307,7 @@ function createSecureProxy(target, options = {}) {
297
307
  }
298
308
  return false;
299
309
  }
300
- return Reflect.set(target2, property, value, receiver);
310
+ return ReflectSet(target2, property, value, receiver);
301
311
  },
302
312
  // Block defining dangerous properties
303
313
  defineProperty(target2, property, descriptor) {
@@ -314,18 +324,18 @@ function createSecureProxy(target, options = {}) {
314
324
  }
315
325
  return false;
316
326
  }
317
- return Reflect.defineProperty(target2, property, descriptor);
327
+ return ReflectDefineProperty(target2, property, descriptor);
318
328
  },
319
329
  // Filter blocked property names from enumeration (Object.keys, Object.entries, etc.)
320
330
  // Must respect proxy invariants: non-configurable own properties cannot be hidden
321
331
  ownKeys(target2) {
322
- const keys = Reflect.ownKeys(target2);
332
+ const keys = ReflectOwnKeys(target2);
323
333
  return keys.filter((key) => {
324
334
  const keyStr = typeof key === "symbol" ? key.toString() : key;
325
335
  if (typeof keyStr !== "string" || !blockedSet.has(keyStr)) {
326
336
  return true;
327
337
  }
328
- const descriptor = Object.getOwnPropertyDescriptor(target2, key);
338
+ const descriptor = ObjectGetOwnPropertyDescriptor(target2, key);
329
339
  if (descriptor && !descriptor.configurable) {
330
340
  return true;
331
341
  }
@@ -336,7 +346,7 @@ function createSecureProxy(target, options = {}) {
336
346
  // Must respect proxy invariants: non-configurable properties must return actual descriptor
337
347
  getOwnPropertyDescriptor(target2, property) {
338
348
  const propName = typeof property === "symbol" ? property.toString() : property;
339
- const descriptor = Reflect.getOwnPropertyDescriptor(target2, property);
349
+ const descriptor = ReflectGetOwnPropertyDescriptor(target2, property);
340
350
  if (descriptor && !descriptor.configurable && descriptor.writable === false && "value" in descriptor) {
341
351
  const exactValue = descriptor.value;
342
352
  if (exactValue !== null && (typeof exactValue === "object" || typeof exactValue === "function")) {
@@ -395,7 +405,7 @@ function createSecureProxy(target, options = {}) {
395
405
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Proxy handler signature requires any for compatibility
396
406
  apply(target2, thisArg, argArray) {
397
407
  const unwrappedThis = thisArg !== null && (typeof thisArg === "object" || typeof thisArg === "function") && proxyToTarget.has(thisArg) ? proxyToTarget.get(thisArg) : thisArg;
398
- const result = Reflect.apply(target2, unwrappedThis, argArray);
408
+ const result = ReflectApply(target2, unwrappedThis, argArray);
399
409
  if (isProxyable(result)) {
400
410
  return proxyWithDepth(result, depth + 1);
401
411
  }
@@ -406,7 +416,7 @@ function createSecureProxy(target, options = {}) {
406
416
  // host Function constructor — the same escape class the apply trap closes for calls.
407
417
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Proxy handler signature requires any for compatibility
408
418
  construct(target2, argArray, newTarget) {
409
- const instance = Reflect.construct(target2, argArray, newTarget === proxy ? target2 : newTarget);
419
+ const instance = ReflectConstruct(target2, argArray, newTarget === proxy ? target2 : newTarget);
410
420
  if (isProxyable(instance)) {
411
421
  return proxyWithDepth(instance, depth + 1);
412
422
  }
@@ -460,11 +470,33 @@ function isSecureProxy(obj) {
460
470
  }
461
471
  return proxySet.has(obj);
462
472
  }
463
- var MIN_MEMBRANE_RECURSION_DEPTH, BLOCKED_PROPERTY_CATEGORIES, BLOCKED_PROPERTIES, DEFAULT_SECURE_PROXY_CONFIG, FUNCTION_BLOCKED_PROPERTIES, proxyCache, proxySet, proxyToTarget, NON_PROXYABLE_TYPES, INTERNAL_SLOT_TYPES;
473
+ var ObjectGetOwnPropertyDescriptor, ObjectToString, FunctionBind, ReflectGet, ReflectSet, ReflectDefineProperty, ReflectGetOwnPropertyDescriptor, ReflectOwnKeys, ReflectApply, ReflectConstruct, ReflectObject, PINNED_REFLECT_VALUES, FunctionCtor, AsyncFunctionCtor, GeneratorFunctionCtor, AsyncGeneratorFunctionCtor, MIN_MEMBRANE_RECURSION_DEPTH, BLOCKED_PROPERTY_CATEGORIES, BLOCKED_PROPERTIES, DEFAULT_SECURE_PROXY_CONFIG, FUNCTION_BLOCKED_PROPERTIES, proxyCache, proxySet, proxyToTarget, NON_PROXYABLE_TYPES, INTERNAL_SLOT_TYPES;
464
474
  var init_secure_proxy = __esm({
465
475
  "libs/core/src/secure-proxy.ts"() {
466
476
  "use strict";
467
477
  init_safe_error();
478
+ ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
479
+ ObjectToString = Object.prototype.toString;
480
+ FunctionBind = Function.prototype.bind;
481
+ ReflectGet = Reflect.get;
482
+ ReflectSet = Reflect.set;
483
+ ReflectDefineProperty = Reflect.defineProperty;
484
+ ReflectGetOwnPropertyDescriptor = Reflect.getOwnPropertyDescriptor;
485
+ ReflectOwnKeys = Reflect.ownKeys;
486
+ ReflectApply = Reflect.apply;
487
+ ReflectConstruct = Reflect.construct;
488
+ ReflectObject = Reflect;
489
+ PINNED_REFLECT_VALUES = /* @__PURE__ */ new Map();
490
+ for (const key of ReflectOwnKeys(ReflectObject)) {
491
+ PINNED_REFLECT_VALUES.set(key, ReflectGet(ReflectObject, key));
492
+ }
493
+ FunctionCtor = Function;
494
+ AsyncFunctionCtor = async function() {
495
+ }.constructor;
496
+ GeneratorFunctionCtor = function* () {
497
+ }.constructor;
498
+ AsyncGeneratorFunctionCtor = async function* () {
499
+ }.constructor;
468
500
  MIN_MEMBRANE_RECURSION_DEPTH = 256;
469
501
  BLOCKED_PROPERTY_CATEGORIES = {
470
502
  /**
@@ -479,6 +511,23 @@ var init_secure_proxy = __esm({
479
511
  "__lookupGetter__",
480
512
  "__lookupSetter__"
481
513
  ]),
514
+ /**
515
+ * Property-descriptor and prototype MUTATION gadgets. These are the primitives behind the
516
+ * GHSA-3279 membrane self-leak (`Object.defineProperty(Object, 'getOwnPropertyDescriptor', hook)`
517
+ * to intercept the trap's raw target) and classic prototype pollution (`setPrototypeOf`). They
518
+ * are never needed by AgentScript and are already refused by the single-VM SafeObject
519
+ * (`DANGEROUS_OBJECT_STATIC_METHODS`), so they are blocked at every level that blocks the
520
+ * constructor (all except PERMISSIVE). Read-only reflection (getPrototypeOf, keys, entries,
521
+ * getOwnPropertyNames) is intentionally NOT here: the membrane's own getPrototypeOf/ownKeys traps
522
+ * already neutralize it for proxied values, and it has legitimate uses.
523
+ */
524
+ DESCRIPTOR_MUTATION: /* @__PURE__ */ new Set([
525
+ "getOwnPropertyDescriptor",
526
+ "getOwnPropertyDescriptors",
527
+ "defineProperty",
528
+ "defineProperties",
529
+ "setPrototypeOf"
530
+ ]),
482
531
  /**
483
532
  * Node.js 24 Iterator helper method names
484
533
  * Blocked at STRICT/SECURE to prevent prototype chain access via iterators
@@ -520,7 +569,13 @@ var init_secure_proxy = __esm({
520
569
  "__defineGetter__",
521
570
  "__defineSetter__",
522
571
  "__lookupGetter__",
523
- "__lookupSetter__"
572
+ "__lookupSetter__",
573
+ // Descriptor / prototype mutation gadgets (GHSA-3279 self-leak + prototype pollution)
574
+ "getOwnPropertyDescriptor",
575
+ "getOwnPropertyDescriptors",
576
+ "defineProperty",
577
+ "defineProperties",
578
+ "setPrototypeOf"
524
579
  ]);
525
580
  DEFAULT_SECURE_PROXY_CONFIG = {
526
581
  blockConstructor: true,
@@ -696,7 +751,7 @@ var init_reference_config = __esm({
696
751
 
697
752
  // libs/core/src/sidecar/reference-resolver.ts
698
753
  function untrustedLength(value) {
699
- const rawLen = ReflectGet(value, "length");
754
+ const rawLen = ReflectGet2(value, "length");
700
755
  if (typeof rawLen !== "number" || !NumberIsFinite(rawLen) || rawLen < 0) {
701
756
  return 0;
702
757
  }
@@ -713,7 +768,7 @@ function untrustedLength(value) {
713
768
  }
714
769
  function untrustedAt(value, index) {
715
770
  try {
716
- return ReflectGet(value, index);
771
+ return ReflectGet2(value, index);
717
772
  } catch {
718
773
  return void 0;
719
774
  }
@@ -722,12 +777,12 @@ function isCompositeHandle(value) {
722
777
  const obj = value;
723
778
  return typeof value === "object" && value !== null && obj["__type"] === "composite" && Array.isArray(obj["__parts"]);
724
779
  }
725
- var ReflectGet, NumberIsFinite, MathFloor, MAX_TRAVERSAL_LENGTH, ResolutionLimitError, ReferenceResolver;
780
+ var ReflectGet2, NumberIsFinite, MathFloor, MAX_TRAVERSAL_LENGTH, ResolutionLimitError, ReferenceResolver;
726
781
  var init_reference_resolver = __esm({
727
782
  "libs/core/src/sidecar/reference-resolver.ts"() {
728
783
  "use strict";
729
784
  init_reference_config();
730
- ReflectGet = Reflect.get;
785
+ ReflectGet2 = Reflect.get;
731
786
  NumberIsFinite = Number.isFinite;
732
787
  MathFloor = Math.floor;
733
788
  MAX_TRAVERSAL_LENGTH = 1e6;
@@ -999,7 +1054,7 @@ function sanitizeValue(value, options = {}, depth = 0, context = { propCount: {
999
1054
  context.visited.add(value);
1000
1055
  }
1001
1056
  if (ArrayIsArray(value)) {
1002
- const rawLen = ReflectGet2(value, "length");
1057
+ const rawLen = ReflectGet3(value, "length");
1003
1058
  const len = typeof rawLen === "number" && NumberIsFinite2(rawLen) && rawLen >= 0 ? MathFloor2(rawLen) : 0;
1004
1059
  context.propCount.count += len;
1005
1060
  if (context.propCount.count > maxProperties) {
@@ -1009,7 +1064,7 @@ function sanitizeValue(value, options = {}, depth = 0, context = { propCount: {
1009
1064
  for (let i = 0; i < len; i++) {
1010
1065
  let item;
1011
1066
  try {
1012
- item = ReflectGet2(value, i);
1067
+ item = ReflectGet3(value, i);
1013
1068
  } catch {
1014
1069
  item = void 0;
1015
1070
  }
@@ -1018,15 +1073,15 @@ function sanitizeValue(value, options = {}, depth = 0, context = { propCount: {
1018
1073
  return result;
1019
1074
  }
1020
1075
  if (value instanceof Date) {
1021
- const time = ReflectApply(DateProtoGetTime, value, []);
1076
+ const time = ReflectApply2(DateProtoGetTime, value, []);
1022
1077
  if (allowDates) {
1023
1078
  return new Date(time);
1024
1079
  }
1025
- return ReflectApply(DateProtoToISOString, value, []);
1080
+ return ReflectApply2(DateProtoToISOString, value, []);
1026
1081
  }
1027
1082
  if (value instanceof Error) {
1028
- const rawName = ReflectGet2(value, "name");
1029
- const rawMessage = ReflectGet2(value, "message");
1083
+ const rawName = ReflectGet3(value, "name");
1084
+ const rawMessage = ReflectGet3(value, "message");
1030
1085
  const name = typeof rawName === "string" ? rawName : "Error";
1031
1086
  const message = typeof rawMessage === "string" ? rawMessage : "";
1032
1087
  if (allowErrors) {
@@ -1039,11 +1094,11 @@ function sanitizeValue(value, options = {}, depth = 0, context = { propCount: {
1039
1094
  return { error: message };
1040
1095
  }
1041
1096
  if (value instanceof RegExp) {
1042
- return ReflectApply(RegExpProtoToString, value, []);
1097
+ return ReflectApply2(RegExpProtoToString, value, []);
1043
1098
  }
1044
1099
  if (value instanceof Map) {
1045
1100
  const sanitizedMap = ObjectCreate(null);
1046
- const entries = ReflectApply(MapProtoEntries, value, []);
1101
+ const entries = ReflectApply2(MapProtoEntries, value, []);
1047
1102
  for (const [key, val] of entries) {
1048
1103
  if (typeof key !== "string") continue;
1049
1104
  if (DANGEROUS_KEYS.has(key)) continue;
@@ -1053,7 +1108,7 @@ function sanitizeValue(value, options = {}, depth = 0, context = { propCount: {
1053
1108
  return sanitizedMap;
1054
1109
  }
1055
1110
  if (value instanceof Set) {
1056
- const iter = ReflectApply(SetProtoValues, value, []);
1111
+ const iter = ReflectApply2(SetProtoValues, value, []);
1057
1112
  const result = [];
1058
1113
  for (const item of iter) {
1059
1114
  context.propCount.count++;
@@ -1074,7 +1129,7 @@ function sanitizeValue(value, options = {}, depth = 0, context = { propCount: {
1074
1129
  }
1075
1130
  let propValue;
1076
1131
  try {
1077
- propValue = ReflectGet2(value, key);
1132
+ propValue = ReflectGet3(value, key);
1078
1133
  } catch {
1079
1134
  continue;
1080
1135
  }
@@ -1212,13 +1267,13 @@ function checkSerializedSize(value, maxBytes) {
1212
1267
  return { ok: false, error: err instanceof Error ? err.message : "Unknown error" };
1213
1268
  }
1214
1269
  }
1215
- var DANGEROUS_KEYS, ReflectApply, ReflectGet2, ArrayIsArray, ObjectKeys, ObjectCreate, NumberIsFinite2, MathFloor2, MapProtoEntries, SetProtoValues, DateProtoGetTime, DateProtoToISOString, RegExpProtoToString;
1270
+ var DANGEROUS_KEYS, ReflectApply2, ReflectGet3, ArrayIsArray, ObjectKeys, ObjectCreate, NumberIsFinite2, MathFloor2, MapProtoEntries, SetProtoValues, DateProtoGetTime, DateProtoToISOString, RegExpProtoToString;
1216
1271
  var init_value_sanitizer = __esm({
1217
1272
  "libs/core/src/value-sanitizer.ts"() {
1218
1273
  "use strict";
1219
1274
  DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor"]);
1220
- ReflectApply = Reflect.apply;
1221
- ReflectGet2 = Reflect.get;
1275
+ ReflectApply2 = Reflect.apply;
1276
+ ReflectGet3 = Reflect.get;
1222
1277
  ArrayIsArray = Array.isArray;
1223
1278
  ObjectKeys = Object.keys;
1224
1279
  ObjectCreate = Object.create;
@@ -2238,6 +2293,29 @@ ${stackTraceHardeningCode}
2238
2293
  } catch (e) { /* ignore */ }
2239
2294
  }
2240
2295
 
2296
+ // SECURITY (GHSA-3279): pin pristine intrinsics BEFORE any sandbox code runs, so the membrane
2297
+ // traps and the error hardening below never re-read a realm global the sandbox can overwrite.
2298
+ // The reported escape replaced Object.getOwnPropertyDescriptor with a hook; the get trap then
2299
+ // called it and handed the attacker the RAW target of a membrane proxy (the host Promise from
2300
+ // callTool), reaching the host Function constructor. The same gadget aimed at the Object.*
2301
+ // mutators below would let an attacker observe safe-error construction or defeat the final
2302
+ // freeze, leaving the returned error with a live prototype and constructor chain. Using
2303
+ // captured references makes a later monkeypatch a no-op.
2304
+ const __ag_getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2305
+ const __ag_defineProperty = Object.defineProperty;
2306
+ const __ag_defineProperties = Object.defineProperties;
2307
+ const __ag_setPrototypeOf = Object.setPrototypeOf;
2308
+ const __ag_objectCreate = Object.create;
2309
+ const __ag_objectFreeze = Object.freeze;
2310
+ const __ag_ReflectGet = Reflect.get;
2311
+ const __ag_ReflectSet = Reflect.set;
2312
+ const __ag_ReflectDefineProperty = Reflect.defineProperty;
2313
+ const __ag_ReflectGetOwnPropertyDescriptor = Reflect.getOwnPropertyDescriptor;
2314
+ const __ag_ReflectOwnKeys = Reflect.ownKeys;
2315
+ const __ag_ReflectApply = Reflect.apply;
2316
+ const __ag_hasOwnProperty = Object.prototype.hasOwnProperty;
2317
+ const __ag_functionBind = Function.prototype.bind;
2318
+
2241
2319
  /**
2242
2320
  * Creates a "safe" error object that cannot be used to escape the sandbox.
2243
2321
  *
@@ -2260,7 +2338,7 @@ ${stackTraceHardeningCode}
2260
2338
  var error = new Error(message);
2261
2339
  // NOTE: Use Object.defineProperty instead of direct assignment because
2262
2340
  // Error.prototype.name is frozen, and in strict mode direct assignment fails.
2263
- Object.defineProperty(error, 'name', {
2341
+ __ag_defineProperty(error, 'name', {
2264
2342
  value: name,
2265
2343
  writable: true,
2266
2344
  enumerable: false,
@@ -2269,12 +2347,12 @@ ${stackTraceHardeningCode}
2269
2347
 
2270
2348
  // CRITICAL: sever the *actual* prototype chain (native getters / Object.getPrototypeOf).
2271
2349
  // A shadowing __proto__ data property is not sufficient.
2272
- Object.setPrototypeOf(error, null);
2350
+ __ag_setPrototypeOf(error, null);
2273
2351
 
2274
2352
  // Create a null-prototype object to use as a safe "constructor"
2275
2353
  // This object has no prototype chain to climb
2276
- var SafeConstructor = Object.create(null);
2277
- Object.defineProperties(SafeConstructor, {
2354
+ var SafeConstructor = __ag_objectCreate(null);
2355
+ __ag_defineProperties(SafeConstructor, {
2278
2356
  // Make constructor point to itself to break the chain
2279
2357
  constructor: {
2280
2358
  value: SafeConstructor,
@@ -2297,11 +2375,11 @@ ${stackTraceHardeningCode}
2297
2375
  configurable: false
2298
2376
  }
2299
2377
  });
2300
- Object.freeze(SafeConstructor);
2378
+ __ag_objectFreeze(SafeConstructor);
2301
2379
 
2302
2380
  // Override the constructor property on the error instance
2303
2381
  // This breaks the prototype chain: err.constructor.constructor no longer reaches Function
2304
- Object.defineProperty(error, 'constructor', {
2382
+ __ag_defineProperty(error, 'constructor', {
2305
2383
  value: SafeConstructor,
2306
2384
  writable: false,
2307
2385
  enumerable: false,
@@ -2310,7 +2388,7 @@ ${stackTraceHardeningCode}
2310
2388
 
2311
2389
  // SECURITY: Override __proto__ on the error instance to prevent prototype chain escape
2312
2390
  // Attack vector blocked: err.__proto__.constructor.constructor('malicious code')()
2313
- Object.defineProperty(error, '__proto__', {
2391
+ __ag_defineProperty(error, '__proto__', {
2314
2392
  value: null,
2315
2393
  writable: false,
2316
2394
  enumerable: false,
@@ -2320,7 +2398,7 @@ ${stackTraceHardeningCode}
2320
2398
  // SECURITY: Remove the stack property to prevent information leakage (Vector 1230)
2321
2399
  // The stack trace can reveal internal implementation details like function names,
2322
2400
  // file paths, and line numbers which can be used for reconnaissance attacks.
2323
- Object.defineProperty(error, 'stack', {
2401
+ __ag_defineProperty(error, 'stack', {
2324
2402
  value: undefined,
2325
2403
  writable: false,
2326
2404
  enumerable: false,
@@ -2329,7 +2407,7 @@ ${stackTraceHardeningCode}
2329
2407
 
2330
2408
  // Add a unique marker to identify this as a safe error from our runtime
2331
2409
  // This is used by suspicious pattern detection to distinguish our errors from user errors
2332
- Object.defineProperty(error, SAFE_ERROR_MARKER, {
2410
+ __ag_defineProperty(error, SAFE_ERROR_MARKER, {
2333
2411
  value: true,
2334
2412
  writable: false,
2335
2413
  enumerable: false,
@@ -2337,7 +2415,7 @@ ${stackTraceHardeningCode}
2337
2415
  });
2338
2416
 
2339
2417
  // Freeze the error to prevent modifications
2340
- Object.freeze(error);
2418
+ __ag_objectFreeze(error);
2341
2419
 
2342
2420
  return error;
2343
2421
  }
@@ -2427,7 +2505,7 @@ ${stackTraceHardeningCode}
2427
2505
  var propName = String(property);
2428
2506
 
2429
2507
  // Check if property is non-configurable (proxy invariant requires returning actual value)
2430
- var descriptor = Object.getOwnPropertyDescriptor(target, property);
2508
+ var descriptor = __ag_getOwnPropertyDescriptor(target, property);
2431
2509
  var isNonConfigurable = descriptor && !descriptor.configurable;
2432
2510
 
2433
2511
  // Proxy invariant: if the target has a non-configurable, non-writable data property,
@@ -2448,15 +2526,14 @@ ${stackTraceHardeningCode}
2448
2526
  return exactValue;
2449
2527
  }
2450
2528
 
2451
- // Block dangerous properties - but respect proxy invariants
2529
+ // Block dangerous properties. The ONLY [[Get]] invariant that forces a specific return
2530
+ // value is for a non-writable + non-configurable DATA property \u2014 already handled above.
2531
+ // Anything reaching here is configurable, a non-configurable WRITABLE data property (such
2532
+ // as a function own prototype), or a non-configurable accessor; the invariant constrains
2533
+ // none of these, so the trap must never hand back the raw value. GHSA-3279: the old
2534
+ // "isNonConfigurable and not host -> return Reflect.get(...)" branch leaked the raw
2535
+ // writable prototype, exposing a parent-realm Object and defeating the membrane.
2452
2536
  if (blockedPropertiesSet.has(propName)) {
2453
- // For non-configurable properties, we MUST return the actual value
2454
- // (JavaScript proxy invariant - can't hide non-configurable properties).
2455
- // Host-owned values instead deny the read: every descriptor shape that could force
2456
- // the trap's result was handled above, so returning undefined is invariant-safe.
2457
- if (isNonConfigurable && !host) {
2458
- return Reflect.get(target, property, receiver);
2459
- }
2460
2537
  if (throwOnBlocked) {
2461
2538
  throw createSafeError(
2462
2539
  "Security violation: Access to '" + propName + "' is blocked. " +
@@ -2466,12 +2543,12 @@ ${stackTraceHardeningCode}
2466
2543
  return undefined;
2467
2544
  }
2468
2545
 
2469
- var value = Reflect.get(target, property, receiver);
2546
+ var value = __ag_ReflectGet(target, property, receiver);
2470
2547
 
2471
2548
  // For function values, bind to target first (preserves internal slot access for Promises, etc.)
2472
2549
  // Then recursively proxy the bound function to block constructor access
2473
2550
  if (typeof value === 'function') {
2474
- var boundMethod = value.bind(target);
2551
+ var boundMethod = __ag_functionBind.call(value, target);
2475
2552
  return createSecureProxy(boundMethod, depth + 1, host);
2476
2553
  }
2477
2554
 
@@ -2494,7 +2571,7 @@ ${stackTraceHardeningCode}
2494
2571
  }
2495
2572
  return false;
2496
2573
  }
2497
- return Reflect.set(target, property, value, receiver);
2574
+ return __ag_ReflectSet(target, property, value, receiver);
2498
2575
  },
2499
2576
  defineProperty: function(target, property, descriptor) {
2500
2577
  var propName = String(property);
@@ -2507,11 +2584,11 @@ ${stackTraceHardeningCode}
2507
2584
  }
2508
2585
  return false;
2509
2586
  }
2510
- return Reflect.defineProperty(target, property, descriptor);
2587
+ return __ag_ReflectDefineProperty(target, property, descriptor);
2511
2588
  },
2512
2589
  getOwnPropertyDescriptor: function(target, property) {
2513
2590
  var propName = String(property);
2514
- var descriptor = Reflect.getOwnPropertyDescriptor(target, property);
2591
+ var descriptor = __ag_ReflectGetOwnPropertyDescriptor(target, property);
2515
2592
 
2516
2593
  // Mirror the get trap's host-owned pinned-value refusal: a non-configurable, non-writable
2517
2594
  // data property must be reported with its exact value (proxy invariant), so on a HOST-owned
@@ -2560,7 +2637,7 @@ ${stackTraceHardeningCode}
2560
2637
  // hands back a raw function that leads to the host Function constructor.
2561
2638
  if (descriptor && (typeof descriptor.get === 'function' || typeof descriptor.set === 'function')) {
2562
2639
  var accessorWrapped = {};
2563
- for (var ak in descriptor) { if (Object.prototype.hasOwnProperty.call(descriptor, ak)) accessorWrapped[ak] = descriptor[ak]; }
2640
+ for (var ak in descriptor) { if (__ag_hasOwnProperty.call(descriptor, ak)) accessorWrapped[ak] = descriptor[ak]; }
2564
2641
  if (typeof descriptor.get === 'function') accessorWrapped.get = createSecureProxy(descriptor.get, depth + 1, host);
2565
2642
  if (typeof descriptor.set === 'function') accessorWrapped.set = createSecureProxy(descriptor.set, depth + 1, host);
2566
2643
  return accessorWrapped;
@@ -2572,7 +2649,7 @@ ${stackTraceHardeningCode}
2572
2649
  var value = descriptor.value;
2573
2650
  if (value !== null && (typeof value === 'object' || typeof value === 'function')) {
2574
2651
  var wrapped = {};
2575
- for (var dk in descriptor) { if (Object.prototype.hasOwnProperty.call(descriptor, dk)) wrapped[dk] = descriptor[dk]; }
2652
+ for (var dk in descriptor) { if (__ag_hasOwnProperty.call(descriptor, dk)) wrapped[dk] = descriptor[dk]; }
2576
2653
  wrapped.value = createSecureProxy(value, depth + 1, host);
2577
2654
  return wrapped;
2578
2655
  }
@@ -2580,7 +2657,7 @@ ${stackTraceHardeningCode}
2580
2657
  return descriptor;
2581
2658
  },
2582
2659
  ownKeys: function(target) {
2583
- var keys = Reflect.ownKeys(target);
2660
+ var keys = __ag_ReflectOwnKeys(target);
2584
2661
  return keys.filter(function(key) {
2585
2662
  var keyStr = String(key);
2586
2663
  // Keep non-blocked properties
@@ -2588,7 +2665,7 @@ ${stackTraceHardeningCode}
2588
2665
  return true;
2589
2666
  }
2590
2667
  // Must keep non-configurable properties (proxy invariant)
2591
- var descriptor = Object.getOwnPropertyDescriptor(target, key);
2668
+ var descriptor = __ag_getOwnPropertyDescriptor(target, key);
2592
2669
  if (descriptor && !descriptor.configurable) {
2593
2670
  return true;
2594
2671
  }
@@ -2609,7 +2686,7 @@ ${stackTraceHardeningCode}
2609
2686
  // Results are re-wrapped at a FRESH depth (0) so a chain of calls such as
2610
2687
  // then().then() cannot inflate depth past the recursion cap and leak an unwrapped value.
2611
2688
  apply: function(target, thisArg, args) {
2612
- return createSecureProxy(Reflect.apply(target, thisArg, args), 0, host);
2689
+ return createSecureProxy(__ag_ReflectApply(target, thisArg, args), 0, host);
2613
2690
  }
2614
2691
  // NOTE: intentionally NO construct trap here (unlike the standalone secure-proxy used
2615
2692
  // for single-VM mode). Every constructor reachable from sandbox code resolves to an
@@ -2768,7 +2845,7 @@ ${stackTraceHardeningCode}
2768
2845
  }
2769
2846
 
2770
2847
  if (response.ok === true) {
2771
- if (Object.prototype.hasOwnProperty.call(response, 'value')) {
2848
+ if (__ag_hasOwnProperty.call(response, 'value')) {
2772
2849
  return response.value;
2773
2850
  }
2774
2851
  return undefined;
@@ -6309,7 +6386,7 @@ var init_errors = __esm({
6309
6386
 
6310
6387
  // libs/core/src/adapters/worker-pool/safe-deserialize.ts
6311
6388
  function mapArraySafely(value, sanitizeItem) {
6312
- const rawLen = ReflectGet3(value, "length");
6389
+ const rawLen = ReflectGet4(value, "length");
6313
6390
  const len = typeof rawLen === "number" && NumberIsFinite3(rawLen) && rawLen >= 0 ? MathFloor3(rawLen) : 0;
6314
6391
  if (len > MAX_ARRAY_LENGTH) {
6315
6392
  throw new MessageValidationError(`Array exceeds maximum length of ${MAX_ARRAY_LENGTH}`);
@@ -6318,7 +6395,7 @@ function mapArraySafely(value, sanitizeItem) {
6318
6395
  for (let i = 0; i < len; i++) {
6319
6396
  let item;
6320
6397
  try {
6321
- item = ReflectGet3(value, i);
6398
+ item = ReflectGet4(value, i);
6322
6399
  } catch {
6323
6400
  item = void 0;
6324
6401
  }
@@ -6393,12 +6470,12 @@ function sanitizeObject(value, depth = 0) {
6393
6470
  }
6394
6471
  return result;
6395
6472
  }
6396
- var ReflectGet3, ArrayIsArray2, NumberIsFinite3, MathFloor3, MAX_ARRAY_LENGTH, DANGEROUS_KEYS2, MAX_DEPTH;
6473
+ var ReflectGet4, ArrayIsArray2, NumberIsFinite3, MathFloor3, MAX_ARRAY_LENGTH, DANGEROUS_KEYS2, MAX_DEPTH;
6397
6474
  var init_safe_deserialize = __esm({
6398
6475
  "libs/core/src/adapters/worker-pool/safe-deserialize.ts"() {
6399
6476
  "use strict";
6400
6477
  init_errors();
6401
- ReflectGet3 = Reflect.get;
6478
+ ReflectGet4 = Reflect.get;
6402
6479
  ArrayIsArray2 = Array.isArray;
6403
6480
  NumberIsFinite3 = Number.isFinite;
6404
6481
  MathFloor3 = Math.floor;
@@ -11422,7 +11499,11 @@ var Interpreter = class {
11422
11499
  const obj = value ?? {};
11423
11500
  for (const prop of pattern.properties) {
11424
11501
  if (prop.type === "RestElement") continue;
11425
- const key = prop.key.name;
11502
+ if (prop.computed) throw new InterpreterError("Computed destructuring keys are not allowed");
11503
+ let key;
11504
+ if (prop.key.type === "Identifier") key = prop.key.name;
11505
+ else if (prop.key.type === "Literal") key = String(prop.key.value);
11506
+ else throw new InterpreterError("Unsupported destructuring key");
11426
11507
  if (BLOCKED_KEYS.has(key)) throw new InterpreterError(`Forbidden destructured key: ${key}`);
11427
11508
  this.bindPattern(prop.value, obj[key], scope, mutable);
11428
11509
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enclave-vm/core",
3
- "version": "2.15.1",
3
+ "version": "2.15.2",
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.15.1",
48
- "@enclave-vm/types": "2.15.1",
47
+ "@enclave-vm/ast": "2.15.2",
48
+ "@enclave-vm/types": "2.15.2",
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
@@ -42,6 +42,17 @@ export declare const BLOCKED_PROPERTY_CATEGORIES: {
42
42
  * Core prototype manipulation properties (always blocked except PERMISSIVE)
43
43
  */
44
44
  readonly PROTOTYPE: Set<string>;
45
+ /**
46
+ * Property-descriptor and prototype MUTATION gadgets. These are the primitives behind the
47
+ * GHSA-3279 membrane self-leak (`Object.defineProperty(Object, 'getOwnPropertyDescriptor', hook)`
48
+ * to intercept the trap's raw target) and classic prototype pollution (`setPrototypeOf`). They
49
+ * are never needed by AgentScript and are already refused by the single-VM SafeObject
50
+ * (`DANGEROUS_OBJECT_STATIC_METHODS`), so they are blocked at every level that blocks the
51
+ * constructor (all except PERMISSIVE). Read-only reflection (getPrototypeOf, keys, entries,
52
+ * getOwnPropertyNames) is intentionally NOT here: the membrane's own getPrototypeOf/ownKeys traps
53
+ * already neutralize it for proxied values, and it has legitimate uses.
54
+ */
55
+ readonly DESCRIPTOR_MUTATION: Set<string>;
45
56
  /**
46
57
  * Node.js 24 Iterator helper method names
47
58
  * Blocked at STRICT/SECURE to prevent prototype chain access via iterators
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enclave-vm/core",
3
- "version": "2.15.1",
3
+ "version": "2.15.2",
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.15.1",
50
- "@enclave-vm/types": "2.15.1",
49
+ "@enclave-vm/ast": "2.15.2",
50
+ "@enclave-vm/types": "2.15.2",
51
51
  "@types/estree": "1.0.8",
52
52
  "acorn": "8.15.0",
53
53
  "acorn-walk": "8.3.4",
package/worker.js CHANGED
@@ -565,7 +565,11 @@ var Interpreter = class {
565
565
  const obj = value ?? {};
566
566
  for (const prop of pattern.properties) {
567
567
  if (prop.type === "RestElement") continue;
568
- const key = prop.key.name;
568
+ if (prop.computed) throw new InterpreterError("Computed destructuring keys are not allowed");
569
+ let key;
570
+ if (prop.key.type === "Identifier") key = prop.key.name;
571
+ else if (prop.key.type === "Literal") key = String(prop.key.value);
572
+ else throw new InterpreterError("Unsupported destructuring key");
569
573
  if (BLOCKED_KEYS.has(key)) throw new InterpreterError(`Forbidden destructured key: ${key}`);
570
574
  this.bindPattern(prop.value, obj[key], scope, mutable);
571
575
  }