The preceding sections describe what permissions are; this section talks about what permissions are used for.
Security policy decides on an appropriate set of permissions to grant any managed code that runs. Certain operations on protected resources – for example reading a file – require that the code by granted permission to read the specific file or else a security exception is raised. Thus, by properly configuring policy to assign permissions based on trust, security can be enforced to allow highly trusted code to do many things, and less trusted code is suitably restricted in what it can do.
Security permissions are enforced on managed code that is verifiably typesafe, which ensures that code can only access memory through well-defined interfaces and cannot use any objects outside of these bounds. The verification and execution within the EE combine to provide a security boundary as strong as ring-based security systems, without overhead of security boundary transitions. This allows different code (by assembly granularity) to be assigned potentially different permissions, all running together in the same app domain. Since the interfaces between classes of different assemblies are well-defined, code may call other code of different levels of trust in a controlled fashion.