You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vm module regression in v18: setting properties on global proxy breaks jsdom #42962
changed the title [-]vm module regression in in v18: setting properties on global proxy breaks jsdom[/-][+]vm module regression in v18: setting properties on global proxy breaks jsdom[/+]on May 4, 2022
The problem seems to be with named interceptors in node_contextify.cc. What's happening is that the setter interceptor, even when setting the property on the backing sandbox object, does not signal that the assignment is in fact now intercepted. So V8 tries to redo the assignment, which uses define semantics when interceptors are present, and doesn't allow redefines to accessors. I don't really grok the interceptor stuff, and since it's special V8 embedder stuff, I'm not entirely surprised it's behaving very weirdly from a JS MOP perspective.
As a fix/workaround, reading https://github.com/nodejs/node/blob/master/src/node_contextify.cc#L461, ISTM the intention is that this interceptor intends to handle the assignment at that point. I.e., V8 should consider the assignment complete and not continue if execution reaches L461 of that setter interceptor. If that's the case, then args.GetReturnValue() should be set with a non-null value to short-circuit, as per the API.
cc @joyeecheung to see if the suggested fix above makes sense.
The behavior change is from https://bugs.chromium.org/p/chromium/issues/detail?id=1309225 (you might not be able to see this due to security sensitivity), where for a security fix it looks like setter interceptors behavior was perhaps inadvertently changed.
I'll try to follow up internally with V8 to understand the behavior of interceptors.
Reacted by Chengzhong Wu, William Chan, Sébastien Doeraene, Yahor Siarheyenka and Huáng Jùnliàng
Activity
[-]vm module regression in in v18: setting properties on global proxy breaks jsdom[/-][+]vm module regression in v18: setting properties on global proxy breaks jsdom[/+]legendecas commentedon May 4, 2022
Bisected into history I found that #42657 introduced the breakage. Will try to dig out the related V8 changes.
syg commentedon May 4, 2022
The problem seems to be with named interceptors in node_contextify.cc. What's happening is that the setter interceptor, even when setting the property on the backing sandbox object, does not signal that the assignment is in fact now intercepted. So V8 tries to redo the assignment, which uses define semantics when interceptors are present, and doesn't allow redefines to accessors. I don't really grok the interceptor stuff, and since it's special V8 embedder stuff, I'm not entirely surprised it's behaving very weirdly from a JS MOP perspective.
As a fix/workaround, reading https://github.com/nodejs/node/blob/master/src/node_contextify.cc#L461, ISTM the intention is that this interceptor intends to handle the assignment at that point. I.e., V8 should consider the assignment complete and not continue if execution reaches L461 of that setter interceptor. If that's the case, then
args.GetReturnValue()should be set with a non-null value to short-circuit, as per the API.cc @joyeecheung to see if the suggested fix above makes sense.
The behavior change is from https://bugs.chromium.org/p/chromium/issues/detail?id=1309225 (you might not be able to see this due to security sensitivity), where for a security fix it looks like setter interceptors behavior was perhaps inadvertently changed.
I'll try to follow up internally with V8 to understand the behavior of interceptors.
targos commentedon May 4, 2022
#42963
@syg looks like it works!
@domenic I used your example as a test case.
src: always signal V8 for intercepted properties
src: always signal V8 for intercepted properties
src: always signal V8 for intercepted properties
src: always signal V8 for intercepted properties
src: always signal V8 for intercepted properties