<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Security for Canadian Developers : Security Testing</title><link>http://blogs.msdn.com/s4cd/archive/tags/Security+Testing/default.aspx</link><description>Tags: Security Testing</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Security Development Lifecycle Webcast</title><link>http://blogs.msdn.com/s4cd/archive/2007/06/11/security-development-lifecycle-webcast.aspx</link><pubDate>Mon, 11 Jun 2007 22:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3234629</guid><dc:creator>jldavid</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/s4cd/comments/3234629.aspx</comments><wfw:commentRss>http://blogs.msdn.com/s4cd/commentrss.aspx?PostID=3234629</wfw:commentRss><description>&lt;P&gt;On June 20th, we will be putting&amp;nbsp;on a webcast entitled "&lt;A class="" href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032329026&amp;amp;EventCategory=4&amp;amp;culture=en-CA&amp;amp;CountryCode=CA" target=_blank mce_href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032329026&amp;amp;EventCategory=4&amp;amp;culture=en-CA&amp;amp;CountryCode=CA"&gt;The Microsoft Security Development Lifecycle (SDL) - Continuous Improvement and Demonstrated Results&lt;/A&gt;". The Security Development Lifecycle is a process that is constantly evolving and has two main goals: reducing coding and design defects, and reduce the severity of defects that are remaining. Security expert &lt;A class="" href="http://blogs.msdn.com/michael_howard/default.aspx" target=_blank mce_href="http://blogs.msdn.com/michael_howard/default.aspx"&gt;Michael Howard&lt;/A&gt; has written a &lt;A class="" href="http://www.microsoft.com/MSPress/books/8753.aspx" target=_blank mce_href="http://www.microsoft.com/MSPress/books/8753.aspx"&gt;great MSPress book&lt;/A&gt; and &lt;A class="" href="http://msdn.microsoft.com/msdnmag/issues/05/11/SDL/" target=_blank mce_href="http://msdn.microsoft.com/msdnmag/issues/05/11/SDL/"&gt;MSDN article&lt;/A&gt; on the subject if you are interested. Here is the abstract for the webcast:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;"Microsoft's SDL reflects the knowledge and best practices learned from focused security efforts across all phases of the software development lifecycle and is a mechanism to ensure continuous improvement and demonstrated results.&amp;nbsp; This session provides an overview of what the SDL means for you and your customers, and explains what's new in the SDL. In addition, the session details Microsoft's commitment to helping customers emulate our processes and build more secure software, including the resources we have available today."&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Sign up for the &lt;A class="" href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032329026&amp;amp;EventCategory=4&amp;amp;culture=en-CA&amp;amp;CountryCode=CA" target=_blank mce_href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032329026&amp;amp;EventCategory=4&amp;amp;culture=en-CA&amp;amp;CountryCode=CA"&gt;webcast here&lt;/A&gt;!&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3234629" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/s4cd/archive/tags/Security+Testing/default.aspx">Security Testing</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Announcements/default.aspx">Announcements</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Webcasts/default.aspx">Webcasts</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Security+On+The+Brain/default.aspx">Security On The Brain</category></item><item><title>8 Simple Rules For Developing More Secure Code</title><link>http://blogs.msdn.com/s4cd/archive/2007/05/28/8-simple-rules-for-developing-more-secure-code.aspx</link><pubDate>Mon, 28 May 2007 18:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2947471</guid><dc:creator>jldavid</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/s4cd/comments/2947471.aspx</comments><wfw:commentRss>http://blogs.msdn.com/s4cd/commentrss.aspx?PostID=2947471</wfw:commentRss><description>While surfing the Web, I came across the following article written by Michael Howard. The article really resonated for me because it covered the following &lt;SPAN class=clsSearchBox&gt;points:&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;
&lt;DIV class=clsDiscuss&gt;
&lt;UL&gt;
&lt;LI class=clsInfoBox&gt;Using analysis tools and experts to review your code (which can be accomplished with tools such as FxCop, AppVerifier&amp;nbsp;and PREfast) 
&lt;LI class=clsInfoBox&gt;Reducing risk using fuzzing and threat modeling&amp;nbsp; (the ACE team has written a great threat modeling tool that I demoed at the Toronto ISC2 conference recently) 
&lt;LI class=clsInfoBox&gt;Keeping bad input out of your applications 
&lt;LI class=clsInfoBox&gt;Learning all you can about security concepts&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;
&lt;P&gt;It's a good read. Check out the article here:&lt;BR&gt;&lt;A href="http://msdn.microsoft.com/msdnmag/issues/06/11/SecureHabits/default.aspx" mce_href="http://msdn.microsoft.com/msdnmag/issues/06/11/SecureHabits/default.aspx"&gt;http://msdn.microsoft.com/msdnmag/issues/06/11/SecureHabits/default.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Are you interested in writing a post on this blog? &lt;A class="" href="http://blogs.msdn.com/cdndevs/contact.aspx" target=_blank mce_href="http://blogs.msdn.com/cdndevs/contact.aspx"&gt;Contact me here&lt;/A&gt; and I'd be glad to review and put up your security oriented article. Cheers!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2947471" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/s4cd/archive/tags/ASP.NET+2.0/default.aspx">ASP.NET 2.0</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Security+Testing/default.aspx">Security Testing</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Security+On+The+Brain/default.aspx">Security On The Brain</category></item><item><title>Developer Windows Vista Security Webcast in May</title><link>http://blogs.msdn.com/s4cd/archive/2007/04/16/developer-windows-vista-security-webcast-in-may.aspx</link><pubDate>Mon, 16 Apr 2007 19:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2155186</guid><dc:creator>jldavid</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/s4cd/comments/2155186.aspx</comments><wfw:commentRss>http://blogs.msdn.com/s4cd/commentrss.aspx?PostID=2155186</wfw:commentRss><description>&lt;P&gt;As you can tell, there is a lot of activity going on with regards to Windows Vista. On May 23rd, we will be running a webcast entitled "&lt;A class="" href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032336165&amp;amp;EventCategory=4&amp;amp;culture=en-CA&amp;amp;CountryCode=CA" target=_blank mce_href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032336165&amp;amp;EventCategory=4&amp;amp;culture=en-CA&amp;amp;CountryCode=CA"&gt;&lt;STRONG&gt;Writing Secure Applications for Windows Vista&lt;/STRONG&gt;&lt;/A&gt;". Here is an abstract of the presentation:&lt;BR&gt;&lt;BR&gt;Have you tested your application on Windows Vista? If not, it’s important that you do as it will impact the experience your users will have with the software you have developed. This is especially the case if your application writes to the registry or requires elevated privileges.&lt;/P&gt;
&lt;P&gt;The primary objective of this session is to provide developers with the necessary knowledge to successfully write secure application on Windows Vista and get familiarized with Vista’s new security model and features such as Least-privileged User Accounts (LUA), virtualization, and the User Account Control (UAC).&amp;nbsp; This session will be of interest to all &lt;BR&gt;Windows developers.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Value proposition&lt;/STRONG&gt;:&lt;BR&gt;Windows Vista incorporates many new and innovative security features. This session will provide the attendees with the following information:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;How Vista’s security enhancements may affect their application development environment&amp;nbsp; &lt;/LI&gt;
&lt;LI&gt;How to successfully write Windows Vista applications leveraging features such as UAC &lt;/LI&gt;
&lt;LI&gt;The use of tools such as FxCop and PreFAST to identify compatible issues in existing applications or in the development process.&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Call to Action&lt;/STRONG&gt;:&lt;BR&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Start developing secure applications on Windows Vista &lt;/LI&gt;
&lt;LI&gt;Use tools like FxCop to find compatible issues with existing applications or new applications in development &lt;/LI&gt;
&lt;LI&gt;Take advantage of the new security tidbits added to Windows Vista&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;To sign up for the event, click on this link: &lt;A href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032336165&amp;amp;EventCategory=4&amp;amp;culture=en-CA&amp;amp;CountryCode=CA"&gt;http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032336165&amp;amp;EventCategory=4&amp;amp;culture=en-CA&amp;amp;CountryCode=CA&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2155186" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/s4cd/archive/tags/Annoucements/default.aspx">Annoucements</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Security+Testing/default.aspx">Security Testing</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Announcements/default.aspx">Announcements</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Webcasts/default.aspx">Webcasts</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Windows+Vista/default.aspx">Windows Vista</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Security+On+The+Brain/default.aspx">Security On The Brain</category></item><item><title>[Guest Blog] User Account Control for Developers</title><link>http://blogs.msdn.com/s4cd/archive/2007/04/16/guest-blog-user-account-control-for-developers.aspx</link><pubDate>Mon, 16 Apr 2007 17:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2155068</guid><dc:creator>jldavid</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/s4cd/comments/2155068.aspx</comments><wfw:commentRss>http://blogs.msdn.com/s4cd/commentrss.aspx?PostID=2155068</wfw:commentRss><description>&lt;FONT size=2&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;A class="" href="http://www.kennyandkarin.com/Kenny/biography.htm" target=_blank mce_href="http://www.kennyandkarin.com/Kenny/biography.htm"&gt;Kenny Kerr&lt;/A&gt; is our guest blogger this month. Here is his bio: Kenny Kerr is a founding employee and Chief Software Architect at PlateSpin Ltd. where he designs and builds new products and helps drive the technical direction for PlateSpin’s market-leading product family. Prior to PlateSpin, Kenny has worked for leading software companies in Africa, the United States, and Canada. With a specialty in commercial software development, he focuses on designing distributed systems, open APIs, performance tuning, Windows systems programming, and most notably secure design and programming practices around C++.&lt;BR&gt;&lt;BR&gt;---&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Since the release of Windows 2000, the developers working on Windows have been trying to create an environment where users can work safely and securely. Windows 2000 introduced techniques for creating restricted tokens that can effectively limit the permissions and privileges afforded to an application. Windows XP introduced further improvements but it has simply not been pervasive enough to make any real difference for the average user... until now. Whatever your initial reaction, User Account Control (UAC) is here to stay and really isn’t as bad as critics make it out to be. As developers we have a responsibility to embrace it so that the applications we develop don’t annoy and desensitize our users with needless prompts. In this article we are taking a practical look at UAC and specifically what can be done programmatically with respect to elevation and integrity control.&lt;/P&gt;&lt;B&gt;
&lt;P&gt;What is security context?&lt;/P&gt;&lt;/B&gt;
&lt;P&gt;Security context refers to those things that define and constrain what a process or thread can do in terms of permissions and privileges. A security context on Windows is defined in terms of a logon session and these are manipulated via tokens. As its name suggests, a logon session represents a specific session on a single computer for a given user. Programmers interact with logon sessions by means of tokens. Any number of tokens can be created that refer to the same logon session. These tokens can offer different sets of permissions and privileges based on a subset of those provided by the logon session. This is really the key to how UAC works or at least a big part of it.&lt;/P&gt;&lt;B&gt;
&lt;P&gt;So how does UAC work?&lt;/P&gt;&lt;/B&gt;
&lt;P&gt;On Windows Vista there are two predominant types of user accounts, standard users and administrators. The first user account that you can create will be an administrator at least initially and any subsequent user accounts will be standard users by default. Standard user accounts are for those people who you do not trust with complete control over the computer. Administrator accounts are for those users who also enjoy complete control over the computer. Unlike previous versions of Windows, you don’t have to logon as a standard user to protect yourself from malicious code that may find its way to your computer. The logon sessions created for standard users and administrators are equally capable of protecting from such threats.&lt;/P&gt;
&lt;P&gt;When a standard user logs on to a computer a new logon session is created and they are presented with a shell application such as Windows Explorer that was created by the system and associated with the user’s newly created logon session by means of a token. This effectively limits what the user can do since Windows Explorer can only run those applications and access those resources that the user’s logon session permits based on the permissions and privileges specified by the token.&lt;/P&gt;
&lt;P&gt;When an administrator logs on to a computer things are a little different and this is where Windows Vista differs dramatically from previous versions. Although the system creates a new logon session, it creates not one but two different tokens representing the same logon session. The first token grants all the permissions and privileges afforded to the administrator while the second token is a restricted token, sometimes called a filtered token, offering far fewer permissions and privileges. This restricted token offers practically the same capabilities and constraints as would be granted to a standard user. The system then creates the shell application using the restricted token. This means that although the user is logged on as an administrator, applications are by default run with limited permissions and privileges.&lt;/P&gt;
&lt;P&gt;When the administrator needs to perform some task that requires additional permissions or privileges not granted to the restricted token, he or she can elect to run an application using the full security context provided by the unrestricted token. What protects the administrator from malicious code is that this elevation to the unrestricted token is only allowed after the administrator has confirmed the desire to use the unrestricted token by means of a secure prompt provided by the system. Malicious code cannot suppress this prompt and thereby gain complete control over the computer without the user’s knowledge. As I hinted at before, restricted tokens are not new Windows Vista but it is in Windows Vista that they are finally being used in an integrated way in the shell to provide a more secure environment for users to work (and play).&lt;/P&gt;&lt;B&gt;
&lt;P&gt;Restricted tokens&lt;/P&gt;&lt;/B&gt;
&lt;P&gt;Although you will typically not have to create restricted tokens yourself, it is useful to understand how it’s done so that you have a better idea of what is being done on your behalf and so that you can have more insight into the environment in which your application will run. As a developer you may also find yourself needing to create an even more restrictive environment than what is provided by UAC in which case knowing how to create restricted tokens is a must. The aptly named CreateRestrictedToken function creates a new token that is a duplicate of an existing token with certain restrictions. This function can restrict the toke in a number of ways:&lt;/P&gt;
&lt;P&gt;• By specifying deny-only security identifiers (SIDs) that can only be used to deny access to securable resources.&lt;/P&gt;
&lt;P&gt;• By specifying restricting SIDs that will be used as an additional access check.&lt;/P&gt;
&lt;P&gt;• By deleting privileges.&lt;/P&gt;
&lt;P&gt;The restricted token used by UAC is created by adding deny-only SIDs and deleting privileges. Restricted SIDs are not used. Let’s walk through a simple example. The first thing we need is a token to duplicate and restrict. Let’s grab the process token:&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;CHandle processToken;&lt;/P&gt;
&lt;P&gt;VERIFY(::OpenProcessToken(::GetCurrentProcess(),&lt;/P&gt;
&lt;P&gt;TOKEN_DUPLICATE | TOKEN_ASSIGN_PRIMARY | TOKEN_QUERY,&lt;/P&gt;
&lt;P&gt;&amp;amp;processToken.m_h));&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;Next we need an array of SIDs to disable. This ensures that they can never be used to allow access. The following code uses my handy WellKnownSid class to construct the SID for the built-in Administrators group. The WellKnownSid class is available with the download for this article.&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;WellKnownSid administratorsSid = WellKnownSid::Administrators();&lt;BR&gt;SID_AND_ATTRIBUTES sidsToDisable[] = &lt;BR&gt;{&lt;BR&gt;&amp;amp;administratorsSid, 0&lt;BR&gt;// add additional SIDs to disable here&lt;BR&gt;};&lt;/P&gt;
&lt;P&gt;Next we need an array of privileges to delete. We first need to look up the privilege’s LUID value:&lt;/P&gt;
&lt;P&gt;LUID shutdownPrivilege = { 0 };&lt;BR&gt;VERIFY(::LookupPrivilegeValue(0, // local system&lt;BR&gt;SE_SHUTDOWN_NAME,&lt;BR&gt;&amp;amp;shutdownPrivilege));&lt;/P&gt;
&lt;P&gt;LUID_AND_ATTRIBUTES privilegesToDelete[] = &lt;BR&gt;{&lt;BR&gt;shutdownPrivilege, 0&lt;BR&gt;// add additional privileges to delete here&lt;BR&gt;};&lt;/P&gt;
&lt;P&gt;Finally, we can call CreateRestrictedToken to create the restricted token:&lt;/P&gt;
&lt;P&gt;CHandle restrictedToken;&lt;BR&gt;VERIFY(::CreateRestrictedToken(processToken,&lt;BR&gt;0, // flags&lt;BR&gt;_countof(sidsToDisable),&lt;BR&gt;sidsToDisable,&lt;BR&gt;_countof(privilegesToDelete),&lt;BR&gt;privilegesToDelete,&lt;BR&gt;0, // number of SIDs to restrict,&lt;BR&gt;0, // no SIDs to restrict,&lt;BR&gt;&amp;amp;restrictedToken.m_h));&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;The resulting token’s group SIDs will have an entry for the built-in Administrators group with the SE_GROUP_USE_FOR_DENY_ONLY flag making sure that the SID is used to deny access but not allow access. The token will also be stripped of the SeShutdownPrivilege privilege ensuring that the token cannot be used to restart, sleep, or shutdown the computer. If this sounds interesting you can try a quick experiment. Copy the code above to a console application and then add the following call to the CreateProcessAsUser function, updating the path to the Windows Explorer executable as appropriate:&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;STARTUPINFO startupInfo = { sizeof (STARTUPINFO) };&lt;BR&gt;ProcessInfo processInfo;&lt;BR&gt;VERIFY(::CreateProcessAsUser(restrictedToken,&lt;BR&gt;L"C:\\Windows\\Explorer.exe",&lt;BR&gt;0, // cmd line&lt;BR&gt;0, // process attributes&lt;BR&gt;0, // thread attributes&lt;BR&gt;FALSE, // don't inherit handles&lt;BR&gt;0, // flags&lt;BR&gt;0, // inherit environment&lt;BR&gt;0, // inherit current directory&lt;BR&gt;&amp;amp;startupInfo,&lt;BR&gt;&amp;amp;processInfo));&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;Now kill any existing Explorer.exe process on your computer and run the code. You should notice that you can no longer use Explorer to restart, sleep, or shutdown the computer. These options in the Start menu should be disabled.&lt;/P&gt;
&lt;P&gt;Finally, there is a function called IsTokenRestricted. It does not however tell you whether the token was created using the CreateRestrictedToken function but merely reports on whether the token contains restricted SIDs. So unless you’re using restricted SIDs it is not a very useful function.&lt;/P&gt;&lt;B&gt;
&lt;P&gt;Integrity levels&lt;/P&gt;&lt;/B&gt;
&lt;P&gt;One aspect of UAC that gets very little attention is a concept called Mandatory Integrity Control. This is a new authorization feature added to processes and security descriptors. Securable resources can specify an integrity level in their security descriptors. Each process on the system is also marked with an integrity level which is then validated against the integrity level of the resource as an added authorization step. Despite its relative simplicity, it is a surprisingly useful feature as it allows you to very simply and effectively partition what a particular process can access.&lt;/P&gt;
&lt;P&gt;Imagine you are developing an application that must routinely deal with data from untrusted sources such as the Internet. Since it may be possible for malicious code to circumvent any steps you may have taken to protect the computer, it is helpful to add a certain amount of "defense in depth" as an added layer of protection. One extremely effective solution was described in the previous section using restricted tokens. It can however be complicated to figure out exactly what SIDs to allow and what SIDs to deny access to certain resources and specifically what permissions to grant each identity considering that the application itself still needs certain permissions to function. This is where integrity levels come in. Integrity levels are primarily used to prevent write access while allowing read and execute access. By allowing read and execute access you allow applications to continue to perform the majority of their functions but preventing write access limits the harm they can cause by overwriting system files or tainting the user’s search paths as an example. This is exactly what Internet Explorer 7 does. It runs portions of the browser in a separate process with low integrity and there are only a handful of file system locations that provide write access to low integrity applications.&lt;/P&gt;
&lt;P&gt;There are four integrity levels available to user-mode processes:&lt;/P&gt;
&lt;P&gt;• Low&lt;/P&gt;
&lt;P&gt;• Medium&lt;/P&gt;
&lt;P&gt;• High&lt;/P&gt;
&lt;P&gt;• System&lt;/P&gt;
&lt;P&gt;Standard user tokens as well as restricted (non-elevated) administrator tokens have an integrity level of Medium. Unrestricted (elevated) administrator tokens have an integrity level of High. Processes running under the Local System account have an integrity level of System. The Internet Explorer process token has an integrity level of Low. A simple way to see the integrity levels for various processes is to get the latest version of Process Explorer which includes an optional column to display the integrity level of each process.&lt;/P&gt;
&lt;P&gt;A child process will by default inherit the integrity level of the parent. You can change the integrity level when a process is created but not once it has been created. Further, you cannot raise the integrity level of a child process to anything higher than that of the parent. This avoids code with lower integrity from gaining higher integrity. Let’s first take a look at how to query and set the integrity level for a process and then we’ll examine how to set the integrity level for securable resources.&lt;/P&gt;&lt;B&gt;
&lt;P&gt;Process integrity levels&lt;/P&gt;&lt;/B&gt;
&lt;P&gt;You can determine the integrity level for a process by examining the process token. The GetTokenInformation function returns different classes of information. For example, to determine the user account represented by the token you specify the TokenUser class. GetTokenInformation will then populate a TOKEN_USER structure based on the information in the token. Similarly the TokenIntegrityLevel class can be specified to query the integrity level of the process and a TOKEN_MANDATORY_LABEL structure will be produced. Most of the structures populated by GetTokenInformation are variable length structures and since only GetTokenInformation knows how much space is required you need to follow a rigid pattern for calling this function. Since most of the low-level security functions use LocalAlloc and LocalFree to allocate and release memory, I use a LocalMemory class template along with a GetTokenInformation function template to simplify matters dramatically. You can find these templates in the download that accompanies this article. Here we will simply focus on the subject at hand:&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;CHandle processToken;&lt;BR&gt;VERIFY(::OpenProcessToken(::GetCurrentProcess(),&lt;BR&gt;TOKEN_QUERY,&lt;BR&gt;&amp;amp;processToken.m_h));&lt;BR&gt;LocalMemory&amp;lt;PTOKEN_MANDATORY_LABEL&amp;gt;info;&lt;BR&gt;COM_VERIFY(GetTokenInformation(processToken,&lt;BR&gt;TokenIntegrityLevel,&lt;BR&gt;info));&lt;BR&gt;SID* sid = static_cast&amp;lt;SID*&amp;gt;(info-&amp;gt;Label.Sid);&lt;BR&gt;DWORD rid = sid-&amp;gt;SubAuthority[0];&lt;BR&gt;switch (rid)&lt;BR&gt;{&lt;BR&gt;case SECURITY_MANDATORY_LOW_RID:&lt;BR&gt;{&lt;BR&gt;// Low integrity process&lt;BR&gt;break;&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;case SECURITY_MANDATORY_MEDIUM_RID:&lt;BR&gt;{&lt;BR&gt;// Medium integrity process&lt;BR&gt;break;&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;case SECURITY_MANDATORY_HIGH_RID:&lt;BR&gt;{&lt;BR&gt;// High integrity process&lt;BR&gt;break;&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;case SECURITY_MANDATORY_SYSTEM_RID:&lt;BR&gt;{&lt;BR&gt;// System integrity level&lt;BR&gt;break;&lt;BR&gt;}&lt;BR&gt;default:&lt;BR&gt;{&lt;BR&gt;ASSERT(false);&lt;BR&gt;}&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;Here OpenProcessToken is used again to get the process token to query. My GetTokenInformation function template is then called with the appropriate information class and LocalMemory class template specifying the information type. The populated TOKEN_MANDATORY_LABEL structure contains a SID that represents the integrity level. Dissecting it will give you the relative identifier (RID) representing the integrity level that you program against.&lt;/P&gt;
&lt;P&gt;To set the integrity level for a child process is pretty straightforward. Start by creating a duplicate of the parent process token. Then simply set the integrity level using the same information class and data structure used to query the integrity level in the previous example. The SetTokenInformation function comes in handy for this. Finally you can call CreateProcessAsUser to create the child process using the modified token. Here’s an example:&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;CHandle processToken;&lt;BR&gt;VERIFY(::OpenProcessToken(::GetCurrentProcess(),&lt;BR&gt;TOKEN_DUPLICATE,&lt;BR&gt;&amp;amp;processToken.m_h));&lt;BR&gt;CHandle duplicateToken;&lt;BR&gt;VERIFY(::DuplicateTokenEx(processToken,&lt;BR&gt;MAXIMUM_ALLOWED,&lt;BR&gt;0, // token attributes&lt;BR&gt;SecurityAnonymous,&lt;BR&gt;TokenPrimary,&lt;BR&gt;&amp;amp;duplicateToken.m_h));&lt;BR&gt;WellKnownSid integrityLevelSid(WellKnownSid::MandatoryLabelAuthority,&lt;BR&gt;SECURITY_MANDATORY_LOW_RID);&lt;BR&gt;TOKEN_MANDATORY_LABEL tokenIntegrityLevel = { 0 };&lt;BR&gt;tokenIntegrityLevel.Label.Attributes = SE_GROUP_INTEGRITY;&lt;BR&gt;tokenIntegrityLevel.Label.Sid = &amp;amp;integrityLevelSid;&lt;BR&gt;VERIFY(::SetTokenInformation(duplicateToken,&lt;BR&gt;TokenIntegrityLevel,&lt;BR&gt;&amp;amp;tokenIntegrityLevel,&lt;BR&gt;sizeof (TOKEN_MANDATORY_LABEL) + ::GetLengthSid(&amp;amp;integrityLevelSid)));&lt;BR&gt;STARTUPINFO startupInfo = { sizeof (STARTUPINFO) };&lt;BR&gt;ProcessInfo processInfo;&lt;BR&gt;VERIFY(::CreateProcessAsUser(duplicateToken,&lt;BR&gt;L"C:\\Windows\\Notepad.exe",&lt;BR&gt;0, // cmd line&lt;BR&gt;0, // process attributes&lt;BR&gt;0, // thread attributes&lt;BR&gt;FALSE, // don't inherit handles&lt;BR&gt;0, // flags&lt;BR&gt;0, // inherit environment&lt;BR&gt;0, // inherit current directory&lt;BR&gt;&amp;amp;startupInfo,&lt;BR&gt;&amp;amp;processInfo));&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;This example launches Notepad. Give it a try. You should notice that although Notepad can open text files in most locations, it cannot save to any location that is not marked with a low integrity level. Finally, you can get a display name for integrity levels using the LookupAccountSid function, but they’re not all that user friendly so you’re better off using a string table with values like "Low", "Medium", "High", and "System". The token created by the system for standard users has an integrity level of Medium. The restricted, or filtered, token created by the system for administrators also has an integrity level of Medium, but the unrestricted administrator token has an integrity level of High. Now let’s examine how to set the integrity level for a particular resource.&lt;/P&gt;&lt;B&gt;
&lt;P&gt;Resource integrity levels&lt;/P&gt;&lt;/B&gt;
&lt;P&gt;The integrity level for a resource is stored in a special access control entry (ACE) in the system access control list (SACL) of the resource’s security descriptor. The simplest way to set or update this value for system resources is using the SetNamedSecurityInfo function. AddMandatoryAce is a new function provided by Windows Vista to add the special ACE, known as a mandatory ACE, to an ACL. Remember, security is all about confusing people with acronyms…&lt;/P&gt;
&lt;P&gt;Seriously, the code is quite simple if you’re familiar with programming security descriptors. Start off by preparing an ACL pointing to a buffer that is just large enough to hold a single ACE. This is achieved using the InitializeAcl function. Next the SID representing the integrity level is created and added to the ACL using the AddMandatoryAce function. Finally the integrity level is updated using the SetNamedSecurityInfo function. Notice the new LABEL_SECURITY_INFORMATION flag being used in the sample below:&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;LocalMemory&amp;lt;PACL&amp;gt; acl;&lt;BR&gt;const DWORD bufferSize = 64;&lt;BR&gt;COM_VERIFY(acl.Allocate(bufferSize));&lt;BR&gt;VERIFY(::InitializeAcl(acl.m_p,&lt;BR&gt;bufferSize,&lt;BR&gt;ACL_REVISION));&lt;BR&gt;WellKnownSid sid(WellKnownSid::MandatoryLabelAuthority,&lt;BR&gt;SECURITY_MANDATORY_LOW_RID);&lt;BR&gt;COM_VERIFY(Kerr::AddMandatoryAce(acl.m_p,&lt;BR&gt;&amp;amp;sid));&lt;BR&gt;CString path = L"C:\\SampleFolder";&lt;BR&gt;DWORD result = ::SetNamedSecurityInfo(const_cast&amp;lt;PWSTR&amp;gt;(path.GetString()),&lt;BR&gt;SE_FILE_OBJECT,&lt;BR&gt;LABEL_SECURITY_INFORMATION,&lt;BR&gt;0, // owner&lt;BR&gt;0, // group&lt;BR&gt;0, // dacl&lt;BR&gt;acl.m_p); // sacl&lt;BR&gt;ASSERT(ERROR_SUCCESS == result);&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;Retrieving the integrity level of a resource is equally simple provided you realize that most resources won’t have an integrity level set explicitly. Rather the system interprets the absence of an integrity label as if the resource were marked with "Medium" integrity. Start by calling GetNamedSecurityInfo with the same security information flag namely LABEL_SECURITY_INFORMATION. If a valid ACL pointer is returned and contains an ACE then you know the integrity level is set explicitly. Now simply call the GetAce function to retrieve a pointer to the ACE storing the integrity level SID and read the RID value to determine the integrity level. Here is an example:&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;CString path = L"C:\\SampleFolder";&lt;BR&gt;LocalMemory&amp;lt;PSECURITY_DESCRIPTOR&amp;gt;descriptor;&lt;BR&gt;PACL acl = 0;&lt;BR&gt;DWORD result = ::GetNamedSecurityInfo(const_cast&amp;lt;PWSTR&amp;gt;(path.GetString()),&lt;BR&gt;SE_FILE_OBJECT,&lt;BR&gt;LABEL_SECURITY_INFORMATION,&lt;BR&gt;0,&lt;BR&gt;0,&lt;BR&gt;0,&lt;BR&gt;&amp;amp;acl,&lt;BR&gt;&amp;amp;descriptor.m_p);&lt;BR&gt;ASSERT(ERROR_SUCCESS == result);&lt;BR&gt;DWORD integrityLevel = SECURITY_MANDATORY_MEDIUM_RID;&lt;BR&gt;if (0 != acl &amp;amp;&amp;amp; 0 &amp;lt; acl-&amp;gt;AceCount)&lt;BR&gt;{&lt;BR&gt;ASSERT(1 == acl-&amp;gt;AceCount);&lt;BR&gt;SYSTEM_MANDATORY_LABEL_ACE* ace = 0;&lt;BR&gt;VERIFY(::GetAce(acl,&lt;BR&gt;0,&lt;BR&gt;reinterpret_cast&amp;lt;void**&amp;gt;(&amp;amp;ace)));&lt;BR&gt;ASSERT(0 != ace);&lt;BR&gt;SID* sid = reinterpret_cast&amp;lt;SID*&amp;gt;(&amp;amp;ace-&amp;gt;SidStart);&lt;BR&gt;integrityLevel = sid-&amp;gt;SubAuthority[0];&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;ASSERT(SECURITY_MANDATORY_LOW_RID == integrityLevel);&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;B&gt;
&lt;P&gt;Run as administrator&lt;/P&gt;&lt;/B&gt;
&lt;P&gt;So far we’ve looked at some of the individual building blocks that make up UAC such as restricted tokens and integrity levels. Let’s now take a look at what it means to "Run as administrator" and how this can be done programmatically. You have probably noticed that you can right-click an application or shortcut and select a context menu option entitled "Run as administrator". This is available for both standard users and administrators. The concept of running as an administrator is more commonly referred to simply as elevation or creating an elevated process. Standard users are prompted for administrator credentials while administrators are simply prompted for permission to elevate. Either way the end result is a new process running with an unrestricted administrator token and all the permissions and privileges it affords.&lt;/P&gt;
&lt;P&gt;The process of elevation is a bit complicated but fortunately much of the complexity is hidden behind an updated ShellExecute(Ex) function. ShellExecute on Windows Vista makes use of the new Application Information (appinfo) service to perform elevation through an undocumented COM interface. ShellExecute first calls CreateProcess to attempt to create the new process. CreateProcess does all the work of checking application compatibility settings, application manifests, runtime loaders, etc. If it determines that the application requires elevation but the calling process is not elevated then CreateProcess fails with ERROR_ELEVATION_REQUIRED. ShellExecute then calls the Application Information service to handle the elevation prompt and creation of the elevated process since the calling process obviously doesn’t have the necessary permissions to perform such a task. The Application Information service ultimately calls CreateProcessAsUser with an unrestricted administrator token.&lt;/P&gt;
&lt;P&gt;If on the other hand you want to create an elevated process regardless of what application information is available then you can specify the little-known "runas" verb with ShellExecute. This has the effect of requesting elevation regardless of what an application’s manifest and compatibility information might prescribe. The runas verb is not actually new to Windows Vista. It was available on Windows XP and Windows 2003 and was often used to create a restricted token directly from the shell. This behavior has however changed. Here is a simple example:&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;::ShellExecute(0, // owner window&lt;BR&gt;L"runas",&lt;BR&gt;L"C:\\Windows\\Notepad.exe",&lt;BR&gt;0, // params&lt;BR&gt;0, // directory&lt;BR&gt;SW_SHOWNORMAL);&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;Considering how much is going on behind the scenes, aren’t you glad this is all the code you need to write? Although creating a new elevated process is reasonable, it’s not always the most appropriate solution if you only need to elevate temporarily. Enter elevated COM objects.&lt;/P&gt;&lt;B&gt;
&lt;P&gt;Creating an elevated COM object&lt;/P&gt;&lt;/B&gt;
&lt;P&gt;If you invested heavily in the COM era you’ll know that COM supports creating COM servers hosted in a surrogate process. Well this technique has been augmented to allow COM servers to be created in an elevated surrogate process. This is extremely useful since you can simply create the COM object on the fly in your application without having to create a whole new process directly. The hardest part about using this technique is registering the COM server correctly to indicate that it should be loaded in a surrogate process and support elevation since the COM object needs to specifically declare its cooperation. &lt;/P&gt;
&lt;P&gt;This first thing to do is update the COM registration to declare that your library (DLL) server can be run in a surrogate process. All you need to do is add the "DllSurrogate" named value under your server’s AppID registry key. In ATL you simply update the project’s main RGS file to look something like this:&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;HKCR&lt;BR&gt;{&lt;BR&gt;NoRemove AppID&lt;BR&gt;{&lt;BR&gt;'%APPID%' = s 'SampleServer'&lt;BR&gt;{&lt;BR&gt;val DllSurrogate = s ''&lt;BR&gt;}&lt;BR&gt;'SampleServer.DLL'&lt;BR&gt;{&lt;BR&gt;val AppID = s '%APPID%'&lt;BR&gt;}&lt;BR&gt;}&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;An empty value for DllSurrogate indicates that the system-supplied surrogate is to be used. The COM client can now specify the CLSCTX_LOCAL_SERVER execution context to create the COM server in the surrogate process:&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;CComPtr&amp;lt;ISampleServer&amp;gt;server;&lt;BR&gt;COM_VERIFY(server.CoCreateInstance(__uuidof(SampleServer),&lt;BR&gt;0,&lt;BR&gt;CLSCTX_LOCAL_SERVER));&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;The next step is to enable elevated launch of the COM class. This involves adding entries to the COM class registration script. An elevation key is added to indicate that elevation is supported for this particular COM class and a "LocalizedString" named value is also required and provides the display name used by the UAC prompt. An ATL COM class registration script should look something like this:&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;HKCR&lt;BR&gt;{&lt;BR&gt;SampleServer.SampleServer.1 = s 'SampleServer Class'&lt;BR&gt;{&lt;BR&gt;CLSID = s '{91C5423A-CF90-4E62-93AD-E5B922AE8681}'&lt;BR&gt;}&lt;BR&gt;SampleServer.SampleServer = s 'SampleServer Class'&lt;BR&gt;{&lt;BR&gt;CLSID = s '{91C5423A-CF90-4E62-93AD-E5B922AE8681}'&lt;BR&gt;CurVer = s 'SampleServer.SampleServer.1'&lt;BR&gt;}&lt;BR&gt;NoRemove CLSID&lt;BR&gt;{&lt;BR&gt;ForceRemove {91C5423A-CF90-4E62-93AD-E5B922AE8681} = s 'SampleServer Class'&lt;BR&gt;{&lt;BR&gt;ProgID = s 'SampleServer.SampleServer.1'&lt;BR&gt;VersionIndependentProgID = s 'SampleServer.SampleServer'&lt;BR&gt;InprocServer32 = s '%MODULE%'&lt;BR&gt;{&lt;BR&gt;val ThreadingModel = s 'Neutral'&lt;BR&gt;}&lt;BR&gt;val AppID = s '%APPID%'&lt;BR&gt;'TypeLib' = s '{A43B074B-0452-4FF4-8308-6B0BF641C3AE}'&lt;BR&gt;Elevation&lt;BR&gt;{&lt;BR&gt;val Enabled = d 1&lt;BR&gt;}&lt;BR&gt;val LocalizedString = s '@%MODULE%,-101'&lt;BR&gt;}&lt;BR&gt;}&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;Don’t forget to add a string to your string table for the localized name. The COM client can now launch the elevated COM server. As with CreateProcess, the CoCreateInstance function won’t create an elevated COM object directly. Instead you need to use the COM elevation moniker. This is most easily achieved using the CoGetObject function to build the moniker and return a proxy to the object that is ultimately created:&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;template &amp;lt;typename T&amp;gt;&lt;BR&gt;HRESULT CreateElevatedInstance(HWND window,&lt;BR&gt;REFCLSID classId,&lt;BR&gt;T** object)&lt;BR&gt;{&lt;BR&gt;BIND_OPTS3 bindOptions;&lt;BR&gt;::ZeroMemory(&amp;amp;bindOptions, sizeof (BIND_OPTS3));&lt;BR&gt;bindOptions.cbStruct = sizeof (BIND_OPTS3);&lt;BR&gt;bindOptions.hwnd = window;&lt;BR&gt;bindOptions.dwClassContext = CLSCTX_LOCAL_SERVER;&lt;BR&gt;CString string;&lt;BR&gt;const int guidLength = 39;&lt;BR&gt;COM_VERIFY(::StringFromGUID2(classId,&lt;BR&gt;string.GetBufferSetLength(guidLength),&lt;BR&gt;guidLength));&lt;BR&gt;string.ReleaseBuffer();&lt;BR&gt;string.Insert(0, L"Elevation:Administrator!new:");&lt;BR&gt;return ::CoGetObject(string,&lt;BR&gt;&amp;amp;bindOptions,&lt;BR&gt;__uuidof(T),&lt;BR&gt;reinterpret_cast&amp;lt;void**&amp;gt;(object));&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;Using the function template is just as simple as calling CoCreateInstance:&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;CComPtr&amp;lt;ISampleServer&amp;gt;server;&lt;BR&gt;COM_VERIFY(CreateElevatedInstance(0, // window&lt;BR&gt;__uuidof(SampleServer),&lt;BR&gt;&amp;amp;server);&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;As with ShellExecute, the window handle is used by UAC to determine whether the prompt will steal the focus or whether it will be waiting for the user in the background.&lt;/P&gt;&lt;B&gt;
&lt;P&gt;Using application manifests&lt;/P&gt;&lt;/B&gt;
&lt;P&gt;Remember when I said that CreateProcess checks application compatibility settings and application manifests among other things? As it turns out, Windows Vista goes to great lengths to ensure that legacy 32-bit applications run properly. This involves a tremendous amount of plumbing to virtualize areas of the file system and registry that applications traditionally had full access to but no longer do under the more restrictive environment imposed by UAC. As impressive as all this virtualization is, the key is to avoid it if at all possible. It’s meant for legacy applications. If you’re writing an application today make sure to provide an application manifest which is the surest way to make sure that virtualization is not applied to your application. Indeed Microsoft is planning on removing the virtualization capabilities in a future version of Windows.&lt;/P&gt;
&lt;P&gt;The application manifest schemas have received an upgrade in Windows Vista to allow them to express the application’s requested security context. What makes it a little more complicated is that Visual C++ by default automatically generates an application manifest. This is actually a very good thing. The linker is keenly aware of the dependencies of your application and the manifest is used to define dependencies on side-by-side assemblies. Fortunately it also provides an option for merging in additional manifest files into the manifest that is ultimately embedded into the application executable. The Visual C++ project’s "Additional Manifest Files" setting is just the thing. Here’s a simple manifest file that declares a dependency on Common Controls 6.0 and specifies a desired security context:&lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;
&lt;P&gt;&amp;lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&amp;gt;&lt;BR&gt;&amp;lt;assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"&amp;gt;&lt;BR&gt;&amp;lt;dependency&amp;gt;&lt;BR&gt;&amp;lt;dependentAssembly&amp;gt;&lt;BR&gt;&amp;lt;assemblyIdentity&lt;BR&gt;type="win32"&lt;BR&gt;name="Microsoft.Windows.Common-Controls"&lt;BR&gt;version="6.0.0.0"&lt;BR&gt;processorArchitecture="*"&lt;BR&gt;publicKeyToken="6595b64144ccf1df"&lt;BR&gt;language="*"&lt;BR&gt;/&amp;gt;&lt;BR&gt;&amp;lt;/dependentAssembly&amp;gt;&lt;BR&gt;&amp;lt;/dependency&amp;gt;&lt;BR&gt;&amp;lt;v3:trustInfo xmlns:v3="urn:schemas-microsoft-com:asm.v3"&amp;gt;&lt;BR&gt;&amp;lt;v3:security&amp;gt;&lt;BR&gt;&amp;lt;v3:requestedPrivileges&amp;gt;&lt;BR&gt;&amp;lt;!-- level can be "asInvoker", "highestAvailable", or "requireAdministrator" --&amp;gt;&lt;BR&gt;&amp;lt;v3:requestedExecutionLevel level="highestAvailable" /&amp;gt;&lt;BR&gt;&amp;lt;/v3:requestedPrivileges&amp;gt;&lt;BR&gt;&amp;lt;/v3:security&amp;gt;&lt;BR&gt;&amp;lt;/v3:trustInfo&amp;gt;&lt;BR&gt;&amp;lt;/assembly&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;The requested execution level can specify one of three values. "asInvoker" is the default and a new process will simply inherit the token of the parent process. "highestAvailable" indicates that the application is requesting the most unrestictive security context available to the user. For standard users this is the same as "asInvoker" but for administrators this is a demand for the unrestricted token. "requireAdministrator" indicates that a unrestricted administrator token is needed. Standard users will be prompted for administrator credentials and administrators will be prompted for consent to elevate.&lt;/P&gt;
&lt;P&gt;Remember, CreateProcess will check the manifest and fail to create the process if the requested execution level does not match that of the parent process. Only ShellExecute makes use of the Application Information service to perform elevation.&lt;/P&gt;&lt;B&gt;
&lt;P&gt;Am I already elevated?&lt;/P&gt;&lt;/B&gt;
&lt;P&gt;Finally, if all you need is to determine whether or not you are currently elevated you can simply call the IsUserAnAdmin function. If you need more precision you can also use GetTokenInformation but in most cases that is overkill.&lt;/P&gt;&lt;B&gt;
&lt;P&gt;Conclusion&lt;/P&gt;&lt;/B&gt;
&lt;P&gt;That’s it for UAC. I hope you’ve found this helpful. Very little of what I’ve described is currently documented. Hopefully that will change. I should add that all the samples I present typically use assertions and similar macros to check for errors. I do this to identify where error handling is necessary. If you use some of the code in your own applications, be sure to replace these macros with whatever error handling strategy you use, whether its exceptions, HRESULTs or something else.&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2155068" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/s4cd/archive/tags/Guest+Bloggers/default.aspx">Guest Bloggers</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Security+Testing/default.aspx">Security Testing</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Windows+Vista/default.aspx">Windows Vista</category></item><item><title>IT Professional Security Webcasts</title><link>http://blogs.msdn.com/s4cd/archive/2007/04/16/it-professional-security-webcasts.aspx</link><pubDate>Mon, 16 Apr 2007 17:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2154185</guid><dc:creator>jldavid</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/s4cd/comments/2154185.aspx</comments><wfw:commentRss>http://blogs.msdn.com/s4cd/commentrss.aspx?PostID=2154185</wfw:commentRss><description>&lt;P&gt;&lt;A class="" href="http://blogs.technet.com/canitpro/" target=_blank mce_href="http://blogs.technet.com/canitpro/"&gt;Rodney Buike&lt;/A&gt;, my counterpart on the IT Pro team has set up a security webcast series which may be interesting to you. Here is a description of the series and the events:&lt;/P&gt;
&lt;P&gt;With every new OS release security is improved and refined and with Windows Vista this is still the case.&amp;nbsp;There are a number of new and improved security tools and features built into Windows Vista, and a number of new tools and resources to integrate Vista into your existing environment.&amp;nbsp;Learning what these features are, how to plan for them, deploy them and manage them along with what resources are available to help is crucial to a successful deployment.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What’s New in Vista Security - April 25th 2007&lt;/STRONG&gt; &lt;BR&gt;With all the new eye candy in Vista, the security features often get overlooked.&amp;nbsp; The first session will look at the new features, what they are, where they would be used and most importantly why you should consider implementing them.&amp;nbsp; At the end of this session you should have a good understanding of some kernel level changes and features such as User Access Control, upgrades to the Windows Vista Firewall and Security Center, BitLocker and IE7 and be ready to start implementing a secure Vista deployment.&lt;BR&gt;&lt;A href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032336945&amp;amp;Culture=en-CA"&gt;http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032336945&amp;amp;Culture=en-CA&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Manage Vista Security With Group Policy - May 9th 2007&lt;/STRONG&gt;&lt;BR&gt;Managing Vista via Group Policy has been improved.&amp;nbsp; With over 2400 GPO settings you have more control than ever before and tools like the GPO Accelerator can help speed the implementation of GPOs over your Vista computers and ease management of BitLocker on mobile PCs.&amp;nbsp; This session will start by giving you a refresh of GPO and OU structures and get you up to speed on the new GPO settings, the GPO Accelerator and other resources and how they can be used to lockdown and secure your environment.&lt;BR&gt;&lt;A href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032336947&amp;amp;Culture=en-CA"&gt;http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032336947&amp;amp;Culture=en-CA&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Manage Advanced Security Features&amp;nbsp;- May 23rd 2007&lt;/STRONG&gt;&lt;BR&gt;On top of the new GPO settings there are some new, more advanced, security features in Vista.&amp;nbsp; BitLocker is one of the popular features and we will take a deep dive into BitLocker covering TPM, key backup, management via group policy and configuration will be covered in this session.&amp;nbsp; We will also take a look at improvements to the Encrypted File System (EFS) and Rights Management Services (RMS).&lt;BR&gt;&lt;A href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032336949&amp;amp;Culture=en-CA"&gt;http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032336949&amp;amp;Culture=en-CA&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;We hope you can attend...cheers!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2154185" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/s4cd/archive/tags/Annoucements/default.aspx">Annoucements</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Security+Testing/default.aspx">Security Testing</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Announcements/default.aspx">Announcements</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Webcasts/default.aspx">Webcasts</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Windows+Vista/default.aspx">Windows Vista</category></item><item><title>[Guest Blogger] Kevin Lam Thoughts on Code Scanning Tools</title><link>http://blogs.msdn.com/s4cd/archive/2006/10/01/780122.aspx</link><pubDate>Mon, 02 Oct 2006 03:22:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:780122</guid><dc:creator>dansellers</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/s4cd/comments/780122.aspx</comments><wfw:commentRss>http://blogs.msdn.com/s4cd/commentrss.aspx?PostID=780122</wfw:commentRss><description>&lt;table cellspacing="0" cellpadding="0" border="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="center"&gt;&lt;img src="http://blogs.msdn.com/photos/cdndevs/images/556626/original.aspx" border="1"&gt;&lt;/td&gt; &lt;td width="8"&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;&lt;strong&gt;&lt;a href="http://blogs.msdn.com/kevinlam/"&gt;&lt;font size="2"&gt;Kevin Lam&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; (Redmond, Washington)&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;strong&gt;[Guest Blogger] Thoughts on Code Scanning Tools &lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Information managers, developers and testers commonly make the mistake of seeing code scanning tools as replacement for security QA processes. As a result they get a false sense of security about their software development lifecycle. Rather than using code scanning tools as a QA team replacement, think of code scanning tools an enforcement mechanism to help ensure that developers are following best practices and more importantly application security development policies. &lt;/p&gt; &lt;p&gt;Secondly tools need to be tightly integrated into a SDLC and not done as a one-off exercise. I visit a lot of customers each year to train them on developing applications securely and often ask them about their development processes and where tools fit into those processes. A common, almost consistent, response I hear is “developers run tools if they know they exist and if they remember.” Ouch. One way in which I’ve helped customers in the past is to integrated tools as a direct gate within their SDLC. Failure to complete this step affects the developer’s ability to proceed forward. As I always say, there’s a difference between what you say you do, and what you actually do. &lt;/p&gt; &lt;p&gt;Another common request from customers I get is for me suggest to them which is the ‘best’ tool. My response: potato. There is no best tool per se, but rather there is a best tool that meets their code scanning requirements. In order for a tool to be identified, I help my customers define those requirements first – otherwise they’ve just purchased or downloaded a tool that they have no idea whether or not is adding value or not. &lt;/p&gt; &lt;p&gt;Have fun scanning! &lt;/p&gt; &lt;ul&gt; &lt;li&gt;Prefast: &lt;a href="http://www.microsoft.com/whdc/devtools/ddk/default.mspx"&gt;http://www.microsoft.com/whdc/devtools/ddk/default.mspx&lt;/a&gt;  &lt;li&gt;FxCop: &lt;a href="http://www.gotdotnet.com/team/fxcop/"&gt;http://www.gotdotnet.com/team/fxcop/&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br&gt; &lt;p&gt;Kevin Lam&lt;br&gt;Senior Security Technologist &lt;br&gt;Microsoft ACE Security Services&lt;/p&gt; &lt;p&gt; &lt;table cellspacing="0" cellpadding="0" border="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;img alt="Kevin Lam" src="http://blogs.msdn.com/photos/s4cd/images/780109/secondarythumb.aspx" border="1"&gt;&lt;/td&gt; &lt;td width="8"&gt;&lt;/td&gt; &lt;td valign="top"&gt; &lt;p&gt;&lt;font size="2"&gt;Kevin Lam is a Senior Security Strategist at Microsoft with over 7 years experience in information security. At Microsoft he is responsible for conducting security assessments (security code review, penetration testing and architectural review) for high valued targets such as XBOX Live, Windows, .NET Framework, MSN Money and critical business services. Kevin is also responsible for driving security strategy and policy changes across Microsoft company-wide and works closely with senior management. He recently published a book for Microsoft Press titled “Assessing Network Security” (ISBN: 0-7356-2033-4) that has received excellent reviews industry-wide, and has also been published in literature such as TechNet magazine. He is a frequent speaker and has participated on several expert security panel discussions. &lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=780122" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/s4cd/archive/tags/Guest+Bloggers/default.aspx">Guest Bloggers</category><category domain="http://blogs.msdn.com/s4cd/archive/tags/Security+Testing/default.aspx">Security Testing</category></item><item><title>An Application or Device is Only as Secure as it was Tested Against</title><link>http://blogs.msdn.com/s4cd/archive/2006/09/20/763937.aspx</link><pubDate>Wed, 20 Sep 2006 23:16:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:763937</guid><dc:creator>dansellers</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/s4cd/comments/763937.aspx</comments><wfw:commentRss>http://blogs.msdn.com/s4cd/commentrss.aspx?PostID=763937</wfw:commentRss><description>&lt;p&gt;It still amazing in this day and age how many Security Professionals, Developers and Architect still believe in the Silver Bullet and automatically accept an Application is Secure becomes someone says it is.&amp;nbsp; The quick and easy way out does not work when it comes to Security.&lt;/p&gt; &lt;p&gt;I never believe anything is 100% Secure.&amp;nbsp; There is nothing in this world that is perfect.&amp;nbsp; Applications can only be deemed safe if proper Security testing was conducted and then again it can only be deemed safe for what it was tested against.&amp;nbsp; You can never consider yourself deem safe for the unknown.&lt;/p&gt; &lt;p&gt;I thought the Myth Busters from the Discovery channel did an excellent of pointing out how anything including bio-metrics security mechanisms are also fallible.&amp;nbsp; &lt;/p&gt; &lt;p&gt;This is an excellent video!! &lt;a href="http://www.youtube.com/watch?v=oXyFmieZjiE"&gt;http://www.youtube.com/watch?v=oXyFmieZjiE&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=763937" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/s4cd/archive/tags/Security+Testing/default.aspx">Security Testing</category></item></channel></rss>