Repository navigation
fix(core): return Dates from the single VM as Dates - #98
Merged
frontegg-david merged 1 commit intoOct 4, 2026
Merged
frontegg-david merged 1 commit into
frontegg-david merged 1 commit into
Conversation
|
Warning Review limit reachedYour organization has reached its usage spending cap. Adjust your spending cap in the billing tab. Next included review available in 17 minutes. View limit detailsLimit details: You’ve used all 3 included reviews currently available. Your 43 included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (4)
Comment |
This was referenced Oct 4, 2026
frontegg-david
added this pull request to stack #97
October 4, 2026 00:10
alexmercerpo
approved these changes
Oct 4, 2026
With the double VM off, a script's `new Date(0)` still came back as {}.
The single VM's membrane wraps every Date a script constructs in a
secure proxy, and a proxy has no [[DateValue]] slot, so the sanitizer's
builtin check (#94) refused it and copied it as a plain object.
The membrane now exports unwrapSecureProxy (from its existing
proxy-to-target map; not part of the package API), and sanitizeValue
takes an unwrap option. The single VM passes it for the script result:
the sanitizer recognizes and reads builtins (Date, Map, Set, RegExp)
from the unwrapped target with the captured host builtins and returns
a new host Date. Everything else is still read through the proxy, and
nothing unwrapped is handed back to the sandbox.
Tool arguments were not affected (Dates already arrive as ISO strings,
or as Dates with the direct bridge).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
frontegg-david
force-pushed
the
fix/core-single-vm-builtin-results
branch
from
October 4, 2026 00:23
72aa52d to
31581b4
Compare
This was referenced Oct 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack 6/10:
main← #92 ← #93 ← #94 ← #95 ← #96 ← this ← #99 ← #100 ← #101 ← #102Follow-up to #94, which made the double VM return a script's
Dateas aDatebut left the single VM (doubleVm: { enabled: false }) returning{}.Root cause
The single VM's membrane (
libs/core/src/secure-proxy.ts) wraps every Date a script constructs: theconstructtrap returnsproxyWithDepth(instance). A proxy has no[[DateValue]]slot, so the sanitizer's builtin check from #94 correctly refused it and copied it as a plain object ({}). Maps and Sets are inNON_PROXYABLE_TYPESand were never wrapped, so only Dates (and RegExps, which validated AgentScript can't create) were affected.What I checked on each adapter:
{ date: new Date(0), nested: [new Date(1)] }{ date: {}, nested: [{}] }callTool('t', { when: new Date(2) }), string bridgeFix
unwrapSecureProxy(value)insecure-proxy.tsreturns the object a membrane proxy wraps, from the existingproxyToTargetmap. It's not exported from the package.sanitizeValuetakes anunwrapoption. The unwrapped object is used only to recognize and read builtins (Date, Map, Set, RegExp) with the captured host methods, and the result is a new host value (new Date(time)). Plain objects and arrays are still read through the proxy as before, and nothing unwrapped goes back to the sandbox.VmAdapterpassesunwrap: unwrapSecureProxywhen it sanitizes the script result.Not changed: the
worker_threadsadapterIt has its own result path:
worker-script.ts:413runssanitizeObject(safe-deserialize.ts:175) and sends the result as a JSON string. A Date comes back as{}, and a BigInt result fails the run withDo not know how to serialize a BigInt(core's sanitizer returns'10'). Fixed on top of this stack in #100.Red → green
libs/core/src/__tests__/enclave.result-sanitization.spec.ts: the end-to-end cases now run on the double VM and the single VM, plus 3 unit tests forunwrapSecureProxyand theunwrapoption. Withvm-adapter.tsreverted: the single VM'sreturns a Date as a Datefails (Received value: {}). With the fix: 9 passed.Verification
jest -c libs/core/jest.config.ts --testPathIgnorePatterns /perf/: 66 suites, 2359 passed, 1 skipped; perf suite: 48 passednx lint core,nx build core, prettier: pass🤖 Generated with Claude Code