This may not be the best answer, but I try. You can check security permissions as a starting point and from there access rights to the code can be of interest.
As with any form of defense, you must make the attack surface as small as possible. This means that you should not worry about all possible permission attacks, but, by default, reject all permissions. You will only allow the minimum necessary permissions required to run the application. If you have a small set of permissions, you can ask a narrower question.
To configure AppDomain, you can define PermissionSet and Evidence security settings before creating a new domain. Once a domain is created, it is theoretically impossible to escalate these privileges.
var setup = new AppDomainSetup { ApplicationBase = Path.GetDirectoryName(platform.Location) }; PermissionSet permissionSet = new PermissionSet(); permissionSet.AddPermission( new FileIOPermission(FileIOPermissionAccess.Read | FileIOPermissionAccess.PathDiscovery, Path.GetDirectoryName(platform.Location))); permissionSet.AddPermission( new SecurityPermission(SecurityPermissionFlag.Execution)); var sandbox = AppDomain.CreateDomain(name, null, setup, permissionSet);
The code taken from here , the evidence-based security model , and Creating an AppDomain with limited rights may also interest you.
source share