
Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Peter. Thanks for your response. Your reference to the blog on the
Simple Sandboxing API was interesting; but, I'm dealing with .NET 1.1--the
Simple Sandboxing API is .NET 2.0.
That blog's reference to "Creating an AppDomain with limited permissions"
(http://blogs.msdn.com/shawnfa/archive/2004/10/25/247379.aspx) is one of the
references I've been using; but, as with all of the other references, it does
not provide any example of how to properly use the "restricted domain",
especially with external assemblies (e.g. "addins").
For example, I was under the impression that creating a new AppDomain and
attempting to load an assembly with that object doesn't properly load that
assembly within the restricted domain. I've found other references on doing
that; but, there are no examples on how to use types loaded from that
assembly in the correct domain. Does all access to anything in that domain
have to be marshaled?
For example, some of Shawn Farkas' examples mandate that in order to truly
load the assembly in another domain CreateInstanceAndUnwrap needs to be
called on an internal class and have a method of that class load the
assembly. This seems to work fine; the assembly is loaded within the correct
AppDomain and execution of a method of a type loaded from that assembly is
executed within the correct domain. But, if that type is returned back from
the assembly loader class we're back into the original domain and any calls
into that assembly loaded into a restricted domain are not restricted.
I'm assuming this is because the type has been marshaled back into the
calling domain; which really defeats the purpose of an assembly loader class.
Through trial and error I've found that the permissions required to even
load a type from an assembly are as follows:
FileIOPermission(FileIOPermissionAccess.Read |
FileIOPermissionAccess.PathDiscovery, assemblyDirectory)
FileIOPermission(FileIOPermissionAccess.Read,
System.Runtime.InteropServices.RuntimeEnvironment.SystemConfigurationFile)
For that assembly to do anything else may (probably) requires more
permissions--which are wholly undocumented. For example, given the above
permissions a call to System.Diagnostics.Debug.WriteLine() causes a security
exception; but Diagnostics, Debug, and WriteLine (in 1.1) make no mention of
permission requirements.

Signature
http://www.peterRitchie.com/
> Hi,
>
[quoted text clipped - 18 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" [MSFT] - 23 Jan 2006 08:25 GMT
Hi
Based on my research, it seems that there are no such a complete sandboxing
example to fully address your concern.
Although the blog is discussing the .NET 2.0, the principle is of the same.
Also commonly we did not want the the sandboxing environment to interact
with other assembly.
e.g. Assembly load in AppDomain A, our application loaded in domain B.
If we allow certian method in AppDomain A to call the method in AppDomain
B. Because B have more rights than A, there will be security vulnerable.
The communication between appdomains is using Remoting which is a mechanism
introduced by .NET.
Here is a sampe for your reference.
Plug-in Manager
https://secure.codeproject.com/csharp/DynamicPluginManager.asp
For the detailed information about .NET Security, please post in the .NET
security group.
microsoft.public.dotnet.security
Best regards,
Peter Huang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.