Don t Be Afraid to Refuse Permissions

Don t Be Afraid to Refuse Permissions

If you know that from a security viewpoint your code is limited in scope and you are concerned that your code might be used to access system resources maliciously, you can request that it never be granted specific permissions. The following example shows how you can configure an application to disallow environment access and native code access, which is otherwise known as unmanaged code:

using System; using System.IO; using System.Security; using System.Security.Permissions; [assembly:EnvironmentPermission( SecurityAction.RequestRefuse, Unrestricted = true)] [assembly:SecurityPermission( SecurityAction.RequestRefuse, UnmanagedCode = true)] namespace Perms { class ReadConfig {  }  }



Writing Secure Code
Writing Secure Code, Second Edition
ISBN: 0735617228
EAN: 2147483647
Year: 2005
Pages: 153

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net