ALERT

[FREE DEMO] Deploy Your Enterprise Cloud in Minutes

Code Access Security (CAS)

Definition - What does Code Access Security (CAS) mean?

Code access security (CAS) is a security mechanism by which the common language runtime (CLR) of the .NET framework can restrict the managed code to execute operations with a limited set of permissions.

CAS enforces security policies in the .NET framework by preventing unauthorized access to protected resources and operations. Unlike traditional security methods, where user credentials are obtained from the user, CAS is designed to address the issues faced when obtaining code from external sources, which contain bugs and vulnerabilities. These bugs and vulnerabilities may make a user's system vulnerable to malicious code, which may be performing tasks without the user knowing it. CAS actually knows and allows only those operations a given user's code can and cannot perform. This feature is applicable to all managed code targeting the CLR.

CAS provides evidence-based security built on a layer above the security provided by the Windows operating system. While Windows is based on the permissions of the user, CAS is based on the evidence for the assembly. The assembly contains the permissions defined in the security policy and forms the basis for allowing code to execute necessary actions.

Techopedia explains Code Access Security (CAS)

CAS is built on the following elements, among others:

  1. Permissions: These are the basic rights needed to access a protected resource or execute a protected operation.
  2. Permission Set: This is a set of permissions, such "full trust", "nothing", "Internet", "local intranet" and others.
  3. Code Group: This is a logical grouping of code with a specified condition for membership such as LocalIntranet_zone and Internet_zone.
  4. Evidence: This is assembly-related information such as application directory, publisher, URL and security zone.
  5. Security Policy: This is a set of rules configured by an administrator to determine the permissions granted for a code expressed hierarchically at four levels as enterprise, machine, user and application domain.

The code-executing privileged operation demands the CLR for one or more permissions. The actual permission is calculated using the union of permission set in the code groups and then an intersection at the policy level. The CLR ensures the demanded permissions are in the granted permissions of the method of that assembly. If permission is not granted, a security exception will be thrown.

CAS provides two security modes to define permissions for code:

  • Declarative security is implemented by defining security attributes at the assembly level, class level or member level. Declarative mode is used when calls need to be evaluated at compile time.
  • Imperative security uses run time method calls to create instances of security classes. Imperative mode is used when calls need to be evaluated at run time.

CAS has limitations, including the malfunctioning of an application moved to another system when the security policy is different. In addition, there is no control on unmanaged code and no control of the development of applications to cater to the needs of different scenarios of security settings on user systems.

To effectively use the fine-grained security technology of CAS, developers should write type-safe code, use declarative or imperative syntax based on context, request permissions from run time for code to run, and use secure libraries.

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
Tweat cdn.techopedia.com
"Techopedia" on Twitter


'@Techopedia'
Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Resources
The 4th Era of IT Infrastructure: Superconverged Systems
The 4th Era of IT Infrastructure: Superconverged Systems:
Learn the benefits and limitations of the 3 generations of IT infrastructure – siloed, converged and hyperconverged – and discover how the 4th...
Approaches and Benefits of Network Virtualization
Approaches and Benefits of Network Virtualization:
Businesses today aspire to achieve a software-defined datacenter (SDDC) to enhance business agility and reduce operational complexity. However, the...
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.