mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-06 16:06:07 +02:00
Links: .NET Desktop - framework\wpf (#109)
* Links: .NET Desktop - framework\wpf * Apply suggestions from code review Co-authored-by: Andy De George <[email protected]>
This commit is contained in:
co-authored by
Andy De George
parent
c1d6e1d23e
commit
674b773578
@@ -19,6 +19,7 @@ helpviewer_keywords:
|
||||
ms.assetid: 2a39a054-3e2a-4659-bcb7-8bcea490ba31
|
||||
---
|
||||
# WPF Security Strategy - Platform Security
|
||||
|
||||
While Windows Presentation Foundation (WPF) provides a variety of security services, it also leverages the security features of the underlying platform, which includes the operating system, the CLR, and Internet Explorer. These layers combine to provide WPF a strong, defense-in-depth security model that attempts to avoid any single point of failure, as shown in the following figure:
|
||||
|
||||

|
||||
@@ -26,9 +27,11 @@ While Windows Presentation Foundation (WPF) provides a variety of security servi
|
||||
The remainder of this topic discusses the features in each of these layers that pertain to WPF specifically.
|
||||
|
||||
## Operating System Security
|
||||
|
||||
The core of Windows provides several security features that form the security foundation for all Windows applications, including those built with WPF. This topic discusses the breadth of these security features that are important to WPF, as well as how WPF integrates with them to provide further defense-in-depth.
|
||||
|
||||
### Microsoft Windows XP Service Pack 2 (SP2)
|
||||
|
||||
In addition to a general review and strengthening of Windows, there are three key features from Windows XP SP2 that we will discuss in this topic:
|
||||
|
||||
- /GS compilation
|
||||
@@ -36,6 +39,7 @@ The core of Windows provides several security features that form the security fo
|
||||
- Microsoft Windows Update.
|
||||
|
||||
#### /GS Compilation
|
||||
|
||||
Windows XP SP2 provides protection by recompiling many core system libraries, including all of the WPF dependencies such as the CLR, to help mitigate buffer overruns. This is achieved by using the /GS parameter with the C/C++ command-line compiler. Although buffer overruns should be explicitly avoided, /GS compilation provides an example of a defense-in-depth against potential vulnerabilities that are inadvertently or maliciously created by them.
|
||||
|
||||
Historically, buffer overruns have been the cause of many high-impact security exploits. A buffer overrun occurs when an attacker takes advantage of a code vulnerability that allows the injection of malicious code that writes past the boundaries of a buffer. This then allows an attacker to hijack the process in which the code is executing by overwriting the return address of a function to cause the execution of the attacker's code. The result is malicious code that executes arbitrary code with the same privileges as the hijacked process.
|
||||
@@ -45,9 +49,11 @@ The core of Windows provides several security features that form the security fo
|
||||
WPF is compiled with the /GS flag to add yet another layer of defense to WPF applications.
|
||||
|
||||
### Windows Vista
|
||||
|
||||
WPF users on Windows Vista will benefit from the operating system's additional security enhancements, including "Least-Privilege User Access", code integrity checks, and privilege isolation.
|
||||
|
||||
#### User Account Control (UAC)
|
||||
|
||||
Today, Windows users tend to run with administrator privileges because many applications require them for either installation or execution, or both. Being able to write default application settings to the Registry is one example.
|
||||
|
||||
Running with administrator privileges really means that applications execute from processes that are granted administrator privileges. The security impact of this is that any malicious code that hijacks a process running with administrator privileges will automatically inherit those privileges, including access to critical system resources.
|
||||
@@ -59,19 +65,23 @@ WPF users on Windows Vista will benefit from the operating system's additional s
|
||||
- To provide compatibility solutions like virtualization. For example, many applications try to write to restricted locations like C:\Program Files. For applications executing under UAC, an alternative per-user location exists that does not require administrator privileges to write to. For applications running under UAC, UAC virtualizes C:\Program Files so that applications who think they are writing to it are actually writing to the alternative, per-user location. This kind of compatibility work enables the operating system to run many applications that couldn't previously run in UAC.
|
||||
|
||||
#### Code Integrity Checks
|
||||
|
||||
Windows Vista incorporates deeper code integrity checks to help prevent malicious code from being injected into system files or into the kernel at load/run time. This goes beyond system file protection.
|
||||
|
||||
### Limited Rights Process for Browser-Hosted Applications
|
||||
|
||||
Browser-hosted WPF applications execute within the Internet zone sandbox. WPF integration with Microsoft Internet Explorer extends this protection with additional support.
|
||||
|
||||
Since XAML browser applications (XBAPs) are generally sandboxed by the Internet zone permission set, removing these privileges does not harm XAML browser applications (XBAPs) from a compatibility perspective. Instead, an additional defense-in-depth layer is created; if a sandboxed application is able to exploit other layers and hijack the process, the process will still only have limited privileges.
|
||||
|
||||
See [Using a Least-Privileged User Account](https://docs.microsoft.com/previous-versions/tn-archive/cc700846%28v=technet.10%29).
|
||||
See [Using a Least-Privileged User Account](/previous-versions/tn-archive/cc700846%28v=technet.10%29).
|
||||
|
||||
## Common Language Runtime Security
|
||||
|
||||
The common language runtime (CLR) offers a number of key security benefits that include validation and verification, Code Access Security (CAS), and the Security Critical Methodology.
|
||||
|
||||
### Validation and Verification
|
||||
|
||||
To provide assembly isolation and integrity, the CLR uses a process of validation. CLR validation ensures that assemblies are isolated by validating their Portable Executable (PE) file format for addresses that point outside the assembly. CLR validation also validates the integrity of the metadata that is embedded within an assembly.
|
||||
|
||||
To ensure type safety, help prevent common security issues (e.g. buffer overruns), and enable sandboxing through sub-process isolation, CLR security uses the concept of verification.
|
||||
@@ -89,6 +99,7 @@ WPF users on Windows Vista will benefit from the operating system's additional s
|
||||
The advantage of verifiable code is a key reason why WPF builds on the .NET Framework. To the extent that verifiable code is used, the possibility of exploiting possible vulnerabilities is greatly lowered.
|
||||
|
||||
### Code Access Security
|
||||
|
||||
A client machine exposes a wide variety of resources that a managed application can have access to, including the file system, the Registry, printing services, the user interface, reflection, and environment variables. Before a managed application can access any of the resources on a client machine, it must have .NET Framework permission to do so. A permission in CAS is a subclass of the <xref:System.Security.CodeAccessPermission>; CAS implements one subclass for each resource that managed applications can access.
|
||||
|
||||
The set of permissions that a managed application is granted by CAS when it starts executing is known as a permission set and is determined by evidence provided by the application. For WPF applications, the evidence that is provided is the location, or zone, from which the applications are launched. CAS identifies the following zones:
|
||||
@@ -148,11 +159,13 @@ WPF users on Windows Vista will benefit from the operating system's additional s
|
||||
From a platform perspective, WPF is responsible for using **Assert** correctly; an incorrect use of **Assert** could enable malicious code to elevate privileges. Consequently, it is important then to only call **Assert** when needed, and to ensure that sandbox restrictions remain intact. For example, sandboxed code is not allowed to open random files, but it is allowed to use fonts. WPF enables sandboxed applications to use font functionality by calling **Assert**, and for WPF to read files known to contain those fonts on behalf of the sandboxed application.
|
||||
|
||||
### ClickOnce Deployment
|
||||
|
||||
ClickOnce is a comprehensive deployment technology that is included with .NET Framework, and integrates with Visual Studio (see [ClickOnce security and deployment](/visualstudio/deployment/clickonce-security-and-deployment) for detailed information). Standalone WPF applications can be deployed using ClickOnce, while browser-hosted applications must be deployed with ClickOnce.
|
||||
|
||||
Applications deployed using ClickOnce are given an additional security layer over Code Access Security (CAS); essentially, ClickOnce deployed applications request the permissions that they need. They are granted only those permissions if they do not exceed the set of permissions for the zone from which the application is deployed. By reducing the set of permissions to only those that are needed, even if they are less than those provided by the launch zone's permission set, the number of resources that the application has access to is reduced to a bare minimum. Consequently, if the application is hijacked, the potential for damage to the client machine is reduced.
|
||||
|
||||
### Security-Critical Methodology
|
||||
|
||||
The WPF code that uses permissions to enable the Internet zone sandbox for XBAP applications must be held to highest possible degree of security audit and control. To facilitate this requirement, .NET Framework provides new support for managing code that elevates privilege. Specifically, the CLR enables you to identify code that elevates privilege and mark it with the <xref:System.Security.SecurityCriticalAttribute>; any code not marked with <xref:System.Security.SecurityCriticalAttribute> becomes *transparent* using this methodology. Conversely, managed code that is not marked with <xref:System.Security.SecurityCriticalAttribute> is prevented from elevating privilege.
|
||||
|
||||
The Security-Critical Methodology allows the organization of WPF code that elevates privilege into *security-critical kernel*, with the remainder being transparent. Isolating the security-critical code enables the WPF engineering team focus an additional security analysis and source control on the security-critical kernel above and beyond standard security practices (see [WPF Security Strategy - Security Engineering](wpf-security-strategy-security-engineering.md)).
|
||||
@@ -160,6 +173,7 @@ WPF users on Windows Vista will benefit from the operating system's additional s
|
||||
Note that .NET Framework permits trusted code to extend the XBAP Internet zone sandbox by allowing developers to write managed assemblies that are marked with <xref:System.Security.AllowPartiallyTrustedCallersAttribute> (APTCA) and deployed to the user's Global Assembly Cache (GAC). Marking an assembly with APTCA is a highly sensitive security operation as it allows any code to call that assembly, including malicious code from the Internet. Extreme caution and best practices must be used when doing this and users must choose to trust that software in order for it to be installed.
|
||||
|
||||
## Microsoft Internet Explorer Security
|
||||
|
||||
Beyond reducing security issues and simplifying security configuration, Microsoft Internet Explorer 6 (SP2) contains several features that security improvements that enhance security for users of XAML browser applications (XBAPs). The thrust of these features attempts to allow users greater control over their browsing experience.
|
||||
|
||||
Prior to IE6 SP2, users could be subject to any of the following:
|
||||
|
||||
Reference in New Issue
Block a user