Re: trying to figure out code permissions



Hi;

I'm still not getting something. I now have:
[assembly: UIPermission(SecurityAction.RequestOptional, Window =
UIPermissionWindow.AllWindows)]

And am getting this on startup:
System.Security.SecurityException was unhandled
Message="Request for the permission of type
'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
Source="mscorlib"
GrantedSet="<PermissionSet
class=\"System.Security.PermissionSet\"\r\nversion=\"1\">\r\n<IPermission
class=\"System.Security.Permissions.SecurityPermission, mscorlib,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089\"\r\nversion=\"1\"\r\nFlags=\"Execution\"/>\r\n<IPermission
class=\"System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089\"\r\nversion=\"1\"\r\nWindow=\"AllWindows\"/>\r\n</PermissionSet>\r\n"
PermissionState="<IPermission
class=\"System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089\"\r\nversion=\"1\"\r\nUnrestricted=\"true\"/>\r\n"
RefusedSet=""
Url="file:///C:/src/TestPerm/TestPerm/bin/Debug/TestPerm.EXE"
StackTrace:
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

One of the choices in the debugger prompt was "Add Permission to the
project" - I clicked on that, exited VS2005, started it again, and still get
this.

What am I missing?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




"Dominick Baier" wrote:

RequestMinimum makes sure you have this permission. Not that all others are
disabled.

Try RequestOptional instead.


-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

Hi;

I assumed the following code would not load. And if it loaded, would
throw an exception on the OpenText. However it runs fine.

AssemblyInfo.cs:
// only permission - set to cause all other to be disallowed
[assembly: RegistryPermission(SecurityAction.RequestMinimum)]
Program.cs:
class Program
{
static void Main(string[] args)
{
MyObj obj = new MyObj();
string str = obj.ToString();
File.OpenText(str);
}
}
class MyObj
{
public override string ToString()
{
return "dave.txt";
}
}
Why does this work?

Cubicle Wars - http://www.windwardreports.com/film.htm




.



Relevant Pages

  • Re: Dot Net Limitations
    ... by the way that log report does look like it's a security permission failure ... > permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 ... > at System.Activator.CreateComInstanceFrom(String assemblyName, String ... > at System.AppDomain.CreateComInstanceFrom(String assemblyFile, String ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Dot Net Limitations
    ... by the way that log report does look like it's a security permission failure ... > permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 ... > at System.Activator.CreateComInstanceFrom(String assemblyName, String ... > at System.AppDomain.CreateComInstanceFrom(String assemblyFile, String ...
    (microsoft.public.dotnet.general)
  • Re: Dot Net Limitations
    ... by the way that log report does look like it's a security permission failure ... > permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 ... > at System.Activator.CreateComInstanceFrom(String assemblyName, String ... > at System.AppDomain.CreateComInstanceFrom(String assemblyFile, String ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Dot Net Limitations
    ... by the way that log report does look like it's a security permission failure ... > permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 ... > at System.Activator.CreateComInstanceFrom(String assemblyName, String ... > at System.AppDomain.CreateComInstanceFrom(String assemblyFile, String ...
    (microsoft.public.inetserver.iis)
  • Re: Determine what security permissions are needed
    ... In order to override or call the underlying CreateParams implementation, ... your assembly will need SecurityPermission.UnmanagedCode permission. ... > at System.AppDomain.CreateComInstanceFrom(String assemblyFile, String ...
    (microsoft.public.dotnet.security)