11.07.2015 Views

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

How To: Use Code Access <strong>Security</strong> Policy to Constrain an Assembly 8297. Enter c:\temp in the File Path column <strong>and</strong> select Read <strong>and</strong> Path Disc(path discovery.)Path discovery permissions are required by the Path.GetFullPath function that isused by the FileIO assembly to canonicalize <strong>and</strong> validate the supplied filename.Read permissions are required by the File.OpenRead method, which is used bythe FileIO assembly to open the text file.8. Click OK.9. Select <strong>Security</strong> from the Available Permissions list <strong>and</strong> click Add.The FileIO assembly also needs the permission to execute in additionto the FileIOPermission. The permission to execute is represented by<strong>Security</strong>Permission with its Flags property set to<strong>Security</strong>PermissionFlag.Execution.10. Click Enable assembly execution, <strong>and</strong> then click OK.11. Click Finish to complete the creation of the permission set.You have now created a new permission set called RestrictedFileIO that containsa restricted FileIOPermission, which allows read <strong>and</strong> path discovery to theC:\Temp directory, <strong>and</strong> a restricted <strong>Security</strong>Permission, which allows assemblyexecution. To create a new code group1. Exp<strong>and</strong> Code Groups, <strong>and</strong> then exp<strong>and</strong> All_Code.2. Right-click All_Code, <strong>and</strong> then click New.3. Enter FileIOAssembly as the code group name, <strong>and</strong> then click Next.4. Select StrongName from the Choose the condition type for this code groupdrop-down list.You use this code group to apply specific permissions as defined by theRestrictedFileIO permission set to the FileIO assembly. A strong name providescryptographically strong evidence to uniquely identify an assembly.5. To specify the FileIO assembly’s public key, (which it has because it contains astrong name), click Import, <strong>and</strong> then browse to the project output folder thatcontains FileIO.dll. Click Open to extract the public key from the assembly.6. Click Next, <strong>and</strong> then select RestrictedFileIO from the Use existing permission setdrop-down list.7. Click Next <strong>and</strong> then Finish to complete the creation of the code group.You have now created a new code group that applies the permissions defined bythe RestrictedFileIO permission set to the FileIO assembly.8. In the right window, select the FileIOAssembly code group, <strong>and</strong> then click EditCode Group Properties.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!