I have a C++ program that allows user to input arbitrary C# (.NET compatible) scripts, which are then interpreted at runtime and which allow the user to customize my program's functionality to a certain extent, through my program's C# (.NET) API.
When a user saves their work in my program, their scripts are saved with their file and automatically executed/interpreted next time the program is run and their file is loaded.
Obviously if a user wants to destroy their own machine with malicious code, more power to them. However, due to the nature of my software their is strong potential for users to share their files with each other...and thus the possibility of users sending malicious code to other users exists (through this C# scripting interface).
Some workarounds might be to warn users if a file contains a script, before automatically executing it, etc...but that still leaves room for error....if a user mistakenly ignores such warnings, they still leave themselves open to attack.
Is there a way to take a bunch of arbitrary C# code, and figure out if it contains any code which could be used to delete/rename/move/modify/harm system files? Basically a way to ensure that some arbitrary c# code doesn't try to change any files on the system? Or maybe a way to simply prevent any file-access .NET assemblies from being loaded by the interpreter?