
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
984
|
Chapter 17: Security
robust actions (talk to a database, create network traffic via HTTP, etc.). In other
scenarios, you can defer these actions if the customer does not wish to grant enough
permissions for these extra services to function.
See Also
See the “WebPermission Class,” “SecurityManager Class,” and “IsGranted Method”
topics in the MSDN documentation.
17.12 Minimizing the Attack Surface of an Assembly
Problem
Someone attacking your assembly will first attempt to find out as many things as
possible about your assembly and then use this information in constructing the
attack(s). The more surface area you give to attackers, the more they have to work
with. You need to minimize what your assembly is allowed to do so that, if an
attacker is successful in taking it over, the attacker will not have the necessary privi-
leges to do any damage to the system.
Solution
Use the SecurityAction.RequestRefuse enumeration member to indicate, at an
assembly level, the permissions that you do not wish this assembly to have. This will
force the CLR to refuse these permissions to your code and will ensure that, even if
another part of the system is compromised, your code cannot be used to perform
functions that it does not need the rights to do.
The following example allows the assembly to perform ...