Replies: 1 comment 4 replies
-
|
It's theoretically possible, but may not be practical. The current .NET libraries are designed for in-process isolation. There may be undiscovered holes that allows accessing wide global state. Limiting access to a narrow range like API of host system and common collections only may work. Besides
Note that auto layout is also safe.
It's covered by the verifiability of IL. However, some modern C# features aren't supported by verification yet. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to be able to compile and execute C# scripts at runtime in a sandbox. I would like to use a system like this:
allowUnsafeset to false.dynamic(as it would block the reflection methods required for dynamic to work).internalcallorpinvokeimpl.Assuming the white-list is secure and enforced correctly, is this a safe way to sandbox scripts? Note that I am not worried about denial of service attacks with infinite loops or crashing, I only care that that code is not able to "infect" the broader system.
I guess the real question is if there is a way to produce unsafe access or reflection without having the assembly reference any types/methods/fields which are not white-listed. As a hypothetical, the
Unsafe.Unboxmethods seems to always compile to thecallCIL instruction, thus can be caught by the checker, but if it was able to compile directly into anunboxinstruction, the whitelist would not be able to identify it as unsafe code.Beta Was this translation helpful? Give feedback.
All reactions