Hello!
In general we don't recommend passing script objects from one engine to another, even if those engines are in the same V8 runtime. ClearScript has some support for this, and even some unit tests, but it doesn't leverage V8's one-shared-heap-per-runtime architecture. That is, an engine may hold a foreign script object, but its access to that object will always be proxied through the managed ClearScript layer, and that involves a lot of overhead. Note that this doesn't apply to host objects, which you can expose in multiple engines without additional overhead.
As for securing your script platform against untrusted scripts, there are things you can do, especially if you're using V8. Some suggestions:
In general we don't recommend passing script objects from one engine to another, even if those engines are in the same V8 runtime. ClearScript has some support for this, and even some unit tests, but it doesn't leverage V8's one-shared-heap-per-runtime architecture. That is, an engine may hold a foreign script object, but its access to that object will always be proxied through the managed ClearScript layer, and that involves a lot of overhead. Note that this doesn't apply to host objects, which you can expose in multiple engines without additional overhead.
As for securing your script platform against untrusted scripts, there are things you can do, especially if you're using V8. Some suggestions:
- Instead of executing untrusted scripts directly within the global context, consider wrapping them within anonymous functions that internally enable strict mode.
-
Use
Object.defineProperty()
andObject.freeze()
to harden your service objects.