AppLocker Design Guide PDF
AppLocker Design Guide PDF
(c) 2013 Microsoft Corporation. All rights reserved. This document is provided "as-is." Information and views
expressed in this document, including URL and other Internet Web site references, may change without notice.
You bear the risk of using it.
Some examples are for illustration only and are fictitious. No real association is intended or inferred.
This document does not provide you with any legal rights to any intellectual property in any
Microsoft product. You may copy and use this document for your internal, reference purposes.
Microsoft uses the term application control to describe the approach of explicitly allowing the code that will run
on a Windows host. This concept is widely referred to as application whitelisting 1 across the IT industry, so this
latter term will be used throughout this document to avoid any potential confusion.
1
Examples include http://www.dsd.gov.au/publications/csocprotect/top_4_mitigations.htm, http://www.sans.org/critical-security-
controls/guidelines.php, and http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-53r4.pdf
The underlying problem is a lack of consistent methods for establishing trust between a
computing platform and the code it is asked to run. While a number of techniques exist such
as digital signing (to prove authenticity and integrity) and distribution though app stores
(where apps can be vetted), these are not applied uniformly across the computing
ecosystem and are not enforced by the end-users computer.
Application whitelisting is an approach which attempts to address this trust issue. The
organizations IT function (in consultation with the business units) defines what is trusted by
the organization, and an application whitelisting product on the organizations computers
enforces this policy by only allowing trusted content to run. Application whitelisting is
increasingly recognized in the security community as a more effective alternative to the
never-ending arms race between anti-malware vendors and the criminals who use malware
as a tool in performing illegal activities.
In fact, the Australian Defence Signals Directorate list application whitelisting as the highest
ranking control in preventing successful cyber intrusions
http://www.dsd.gov.au/infosec/top35mitigationstrategies.htm. This finding is based on their
vulnerability assessment work along with lessons learned from real incident responses
during 2011 and 2012. They recommend deploying whitelisting initially to all high sensitivity
user systems, such as PCs run by executive staff, then progressively extending whitelisting to
the broader organization of users and server infrastructure.
Effective application whitelisting can both prevent an unapproved executable from running
on a system and prevent an executable from being installed. It can be equally applied to end
user systems and servers.
2
Taken from last 3 years reports of proactive detection tests from
http://www.av-comparatives.org/comparativesreviews/retrospective-test
3
Anti-malware software is still important as part of a comprehensive, defense-in-depth strategy.
While the technology is free to use and fairly simple to understand, it is not trivial to deploy
application whitelisting in an organization of even moderate complexity. Effective application
whitelisting requires the organization to explicitly define what software is trusted
throughout the organization. If the organization cannot accurately express what is trusted in
AppLocker policy, end users may be impacted. There are mechanisms within the AppLocker
technology, such as first running in Audit Only mode that can help organizations in this
regard.
The aim of this guide is to describe the end-to-end process for developing, testing and
deploying AppLocker in an organization of any size and regardless of their security
requirements, in a way that minimizes the impact on the operation of the business.
Windows Installers
Refers to traditional application packages that are installed by the Windows Installer service.
It includes the installer packages themselves (.msi), and application patches (.msp). On
Windows 8 / Server 2012 computers, it also includes application transforms (.mst) that
specify which components of the installer package should be installed.
Windows installers install files and make configuration changes that only users with
administrative rights can perform. Assuming that users are not given administrative rights, a
good level of control already exists in preventing users from making unauthorized changes.
Even after an application is installed, Executable rules must still be in place to allow the
application to actually execute. For these two reasons, many organizations choose not to
control Windows Installers using AppLocker. Alternatively, they may deem to implement a
slightly restrictive policy allowing administrators to install applications as long as they have
been signed by a publisher that the computer trusts.
Scripts
Refers to PowerShell (.ps1), Windows command interpreter (.cmd and .bat), VB script (.vbs)
and Java script (.js) files, but does not apply to client-side scripts executed by a browser.
Note that additional script types (such as Perl) cannot be controlled by AppLocker, although
the scripts themselves can be prevented from running by preventing the corresponding
script interpreter from running. Also note that Office applications can run Visual Basic for
Applications (VBA) code in macros that are not controlled by AppLocker.
Unlike almost all executables, installers, packaged apps and DLL/OCX files, many of the
several hundred scripts that ship with Windows are not digitally signed. A number of
complex path or file hash rules will need to be created to allow them to run. While
secondary to controlling executable files, execution of scripts should be considered for high
value computers, or those exposed to significant risk. If the organization has enabled code
signing for in-house developed applications and packages, the same process can be used
for digital signing of scripts to allow simpler (and fewer) publisher rules to be used to allow
them to run.
Modern malware targets the shared code that legitimate applications load in an effort to
avoid detection. To provide the best possible protection, DLL/OCX files should be evaluated
by AppLocker policy. This however this creates an additional dependency in that AppLocker
rules must be created that allow every such .dll and .ocx file required for the application to
function. If a single .dll or .ocx file that is required by an application is prevented from
loading, the application will either fail to run or will generate errors when certain tasks are
performed. Consequently, checking of .dll and .ocx files is disabled by default and must be
explicitly enabled before it can be used.
While organizations must perform rigorous testing to ensure that they include all shared
libraries used by their applications, the procedures in this guide should allow this feature to
be enabled and used to provide maximum protection against malicious code. However
depending on resource availability, some organizations may choose to initially implement
AppLocker without enabling this feature, and enable it once they are comfortable in
deploying and maintaining it in Production.
Not configured If no rules are present, AppLocker is disabled for that rule type.
If one or more rules are present, AppLocker operates in the
Enforce rules mode for that rule type.
Also, if a higher precedence GPO is set to Not Configured,
the mode selection is deferred to the next highest precedence
GPO.
Enforce rules The actions specified in the AppLocker rules will be enforced,
and actions logged to the Windows event log.
4
The Security Compliance Manager baselines can be used to configure this setting (http://technet.microsoft.com/en-
us/library/cc677002.aspx)
5
Refer to the security guide for the appropriate version of Office contained within the Security Configuration Manager baselines.
Also, ensure that the hotfixes described in section 5.10 are installed to prevent possible circumvention of AppLocker policy.
Audit only mode is used to develop and test the AppLocker rules without impacting
normal operations. Computers will typically operate in this mode until sufficient confidence
is reached that the AppLocker rules support all legitimate use cases.
After validation of the AppLocker rules, computers are changed to Enforce rules mode
where actions that are not explicitly allowed (through rules) are blocked. Allow / block
decisions continue to be logged, allowing on-going monitoring to enable rules to be tuned,
or to spot suspicious behavior.
Rule ID
While not exposed through the user interface, each rule also has a unique identifier which is
a random hexadecimal number that uniquely identifies each rule. These are used during
merge and replace operations and allow AppLocker to match source and destination rules
even if some of the properties are different.
Rule Description
Descriptions are optional but allow additional information to be associated with individual
rules such as specific reasons for its creation, contact details of the rule author or
application owner, or any other details that cannot be expressed in the rule name. Use of
detailed descriptions is highly recommended to assist in traceability back to original rule
requirements.
By default, rules apply to the built-in Everyone group; which matches any user trying to run
the specified object.
Note that AppLocker rules have no effect on files running as SYSTEM, such as the Windows
kernel, critical services and kernel-mode drivers.
Unlike many rule-based access control products, the ordering of AppLocker rules is not
significant. Deny rules are always processed first, and so take precedence if a conflict
occurs with an Allow rule. If a Subject / Object pair does not match any Deny rules,
Allow rules are processed until a match is found, and then the action is allowed. If no
Allow rules are matched, the action is denied. This is referred to as default deny mode
and is the only mode that AppLocker can operate in objects are implicitly denied unless
explicitly allowed.
However some companies that collect inventory data from their computers may choose to
use this approach as a means of blocking undesirable applications that show up in inventory
reports. This is a reactive approach and has obvious drawbacks, but may be applicable to
some organizations. While implementation of this approach can be easily inferred from this
document, the remainder of the guidance in this document assumes that AppLocker is
operating in the intended default deny mode.
Each of these three rule types have their own unique advantages and disadvantages, and are
described in detail below. A table at the end of this section also summarizes these
advantages and disadvantages.
Path Rules
Path rules apply to an individual file or a folder. In the case of an individual file rule, the full
path and name of the file is specified.
In the case of a folder rule, the rule applies to all files with applicable extensions in that
folder and ALL subfolders. While absolute path names can be used, variables may be used
to cater for any customized folder names or drive letters. However where possible, absolute
paths should be used to mitigate the risk of a variable change allowing code to run from an
alternate location. The variables are unique to AppLocker, and are listed in the table below
(along with their Windows system variable equivalents):
The way in which AppLocker treats subfolders of path rules is another serious disadvantage.
If AppLocker only cares that a file is run from a particular location, then a user can copy any
file to a writable subfolder under the parent path defined in the rule to circumvent policy.
The default EXE, script and DLL / OCX rules (which will not be used in this guide) allow
anyone to run anything if it resides in a subfolder of \Windows. As there are numerous
standard user-writable subfolders of \Windows, these rules need to have numerous
exceptions (described below) defined if they are to be effective. The number of writable
subfolders increases further when you consider accounts commonly used by services such
as Local Service and Network Service. Any service running as these accounts that could be
made to write content to one of these locations could be used to circumvent a path rule.
As described above, path rules can be defined down to individual executables (by full path
and name). However AppLocker has no means of determining whether the file name actually
represents the file intended to be allowed. This means that any executable can be renamed
to match the conditions of a path rule and will be allowed to run whether it is the
legitimate executable or something completely different.
The final disadvantage is that path rules do not check the integrity of files before allowing
them to run. This means that a file that is allowed to run via an AppLocker rule will run
equally well if it is the intended version or has been modified for malicious purposes (e.g. by
malware).
Due to these numerous, significant disadvantages, path rules should only be used when
neither of the two alternative rule types are appropriate. When using path rules, care must
be taken to ensure that ACLs on the respective folders (and all subfolders) prevent users
from writing content to them.6
6
AccessEnum (http://technet.microsoft.com/en-us/sysinternals/bb897332) can be used to enumerate user-writable subfolders.
While security-conscious companies may accept the increased burden for the very tight
control given by hash rules, the general recommendation is to avoid hash rules except in
very specific circumstances primarily where the files have not been digitally signed. Files
that have been digitally signed should use Publisher rules (described next) which provide the
same integrity benefits as hash rules but with far less management overhead.
Publisher Rules
When a file is digitally signed, a hash of the file contents and file attributes (such as the
product name and its version) is cryptographically protected (signed) by a publisher.
Assuming that publisher is trusted by the users computer, the computer can validate the
integrity of the file and its attributes. Similar to the mechanism used in evaluating hash rules,
if the contents or attributes of a signed file is changed, it wont match the information in the
signature and will fail validation.
AppLocker uses this validation mechanism in Publisher rules. Rather than matching the hash
of the file to be run, Publisher rules make decisions based on any combination of:
Note that the new .appx packages that run on Windows 8 / Server 2012 must be digitally
signed (or Windows wont run them) and have a package name and package version instead
of product name, file name and file version.
When choosing publisher rules, you need to keep in mind that they are only as secure as the
publisher is trustworthy. If you rely on publisher rules and one of the specified publishers has
their code signing certificate private key compromised, whoever compromised that
certificate could use it to sign their own code8. AppLocker would not be able to distinguish
between this and legitimate files, and could potentially be used to bypass it.
There have also been a number of high profile incidents where trusted certificate issuers
have been compromised and fraudulent certificates generated9. Fraudulent code signing
7
If Organization, Locality, State & Country properties are defined for a signing certificate, only these properties are used by
AppLocker and all other properties (including common name) are ignored. If any of O, L, S or C are not defined, AppLocker will use
the full certificate subject name.
8
Witnessed in the Bit9 incident described at https://blog.bit9.com/2013/02/25/bit9-security-incident-update/
9
Trusted certificate authorities include DigiNotar, Comodo and TurkTrust
The reason why countersignatures (or timestamps) are important is that they extend and
simplify the certificate validation process. If a file is not countersigned, the file will fail
validation once the publisher certificate reaches its expiry date (typically 1 year). Also,
revocation information must be retrieved on a periodic basis to ensure that the publisher
certificate (or any of its intermediate CA certificates) have not been revoked. This would not
be possible for computers that are not regularly connected to the Internet (e.g. servers), and
could cause validation to fail. The requirement to check revocation information is removed
for files that have been countersigned. For more information on Authenticode certificates,
timestamps and the validation process, refer to
http://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-
d599bac8184a/Authenticode_PE.docx.
Object Exceptions
Path and Publisher rules allow you to define one or more Exceptions to the object
definition to get finer-grained control over the files that a rule matches. (File hash rules do
not need exceptions because the hash of each individual file must be included in the rule a
file is excluded by simply not listing its hash).
The conditions used to match files in exceptions can be the same or different from the rule
type. For example, the examples above could exclude specific files based on their hash value
rather than path or publisher information. You can even have exceptions of all three
different types (path, file hash and publisher) within a single rule if that is the most efficient
way to exclude files that you dont want a rule to match.
Exceptions provide an efficient means of matching exactly the objects you wish to target
with a smaller number of rules without having to resort to the use of Deny rules.
Note 1: assumes that the software vendor adopts a consistent naming and numbering
scheme for the files they sign.
Note 2: assumes that the publisher takes adequate steps to protect their signing certificate,
and depends on the trustworthiness of all CAs in the chain that issued it.
Note 3: slightly more complex due to the number of attributes that can be used in object
definitions, but this complexity gives a great deal of flexibility.
To avoid scenarios like this, AppLocker allows the administrator to create a set of permissive
default rules that will allow the user to interact with the operating system without
restriction.
The default rules for Executable rules, Script rules and DLL rules (if enabled) are:
Action Subject Object Exceptions
Allow Everyone %PROGRAMFILES%\* No exceptions
Allow Everyone %WINDIR%\* No exceptions
Allow BUILTIN\Administrators * No exceptions
For the Windows Installer rule type, the default rules are:
Allow Everyone Signed by any publisher No exceptions
Allow Everyone %WINDIR%\Installer\*No exceptions
Allow BUILTIN\Administrators * No exceptions
For the Packaged apps rule type, the default rule is:
Allow Everyone Signed by any publisher No exceptions
While allowing an inexperienced administrator to safely interact with AppLocker, it does not
create a secure environment. The guidance provided in this document recommends that the
default rules not be used. By following the process in this document, an administrator can
safely create a highly tailored set of AppLocker policies without the need for the default
rules.
To reiterate, DO NOT ENABLE THE DEFAULT RULES.
A list of relevant AppLocker event IDs can be found in the following table.
Event ID Level Event message Description
Indicates that the policy was not applied
Application Identity Policy correctly to the computer. The status
8000 Error
conversion failed. Status <%1> message is provided for troubleshooting
purposes.
The AppLocker policy was applied Indicates that the AppLocker policy was
8001 Information
successfully to this computer. successfully applied to the computer.
Specifies that the .exe or .dll file is allowed by
8002 Information <File name> was allowed to run.
an AppLocker rule.
Applied only when the Audit only
<File name> was allowed to run
enforcement mode is enabled. Specifies that
but would have been prevented
8003 Warning the .exe or .dll file would be blocked if the
from running if the AppLocker
Enforce rules enforcement mode were
policy were enforced.
enabled.
Access to <file name> is restricted by the
administrator. Applied only when the Enforce
<File name> was prevented from
8004 Error rules enforcement mode is set either directly
running.
or indirectly through Group Policy
inheritance. The .exe or .dll file cannot run.
Specifies that the script or .msi file is allowed
8005 Information <Script or MSI> was allowed to run.
by an AppLocker rule.
Applied only when the Audit only
<Script or MSI> was allowed to run
enforcement mode is enabled. Specifies that
but would have been prevented
8006 Warning the script or .msi file would be blocked if the
from running if the AppLocker
Enforce rules enforcement mode were
policy were enforced.
enabled.
Access to <file name> is restricted by the
administrator. Applied only when the Enforce
<Script or MSI> was prevented
8007 Error rules enforcement mode is set either directly
from running.
or indirectly through Group Policy
inheritance. The script or .msi file cannot run.
AppLocker policy has been applied to a
Windows edition that does not support it.
8008 Error AppLocker disabled on the SKU.
Refer to section 2.2 for a list of supported
editions.
<Packaged app> was allowed to Added in Windows Server 2012 and Windows
8020 Information
run. 8. Logged when an application is executed.
The process for deploying application whitelisting into an organization follows the Microsoft
Solutions Framework (MSF) methodology. This describes a five phase process progressing
from solution envisioning and requirements gathering through design, testing and into
deployment. As the actual deployment of AppLocker is trivial and the ongoing
maintenance of AppLocker is so critical to its success, the Deploy phase is extended to
Deploy / Operate to address this critical aspect.
The phases are summarized as follows and are described in detail throughout the remainder
of this document:
1. Envision
Determine the objectives for using AppLocker in the organization and the scope
governing its use. Also identify assumptions and risks that will guide the remainder of
the AppLocker project.
2. Plan
Perform a detailed analysis of the computing environment including computer
roles, user roles and applications to be controlled. Determine the AppLocker policy
strategy and the strategy for deploying it by using Group Policy. Determine how
AppLocker will be monitored after the deployment, and the processes for supporting
users and maintaining policy. Finally, determine the AppLocker deployment and
communications plans.
3. Develop
Create AppLocker rules on reference computers for the operating system and all
applications. Test and refine the rules until they are ready for formal testing, and then
export the rule sets to XML.
4. Stabilize
Configure centralized monitoring of AppLocker events, import AppLocker policy into
GPOs, and deploy (in Audit only mode) to target computers. Perform detailed
validation and user acceptance testing until sign off can be achieved.
The phases of the AppLocker design and deployment process are illustrated in the following
diagram.
Determine Determine
Identify solution Identify solution Vision/Scope
Envision application control application control
assumptions risks approved
objectives scope
Computer
roles
Applications
Deploy reference
Develop policy for Validate policy for Export validated
Develop computers in audit Scope complete
base build base build policy to XML Develop, validate &
mode
export policies for
applications
Configure event Create and deploy Validate AppLocker User Acceptance Release readiness
Stabilize
collection AppLocker GPOs policy deployment Testing approved
Communicate
Enforce AppLocker Deployment
Deploy change to
policy complete
enforcement mode
AppLocker requires a direct tradeoff between security and flexibility / cost to operate.
Determine what this balance should be for each computer role. Doing this early will provide
guidance to the design team when considering design alternatives. Consider a qualitative
scale such as Prioritize Security / Balanced / Prioritize Flexibility, or a more granular scale if
appropriate.
When considering the control objectives (for each computer profile or to be applied
globally), consider each of the rule categories that AppLocker can control as you may not
wish to control all categories on all computer roles. Refer to the considerations for each rule
type in section 2.3.1 for more information.
You may have task-specific administrative roles that logon to a computer profile and wish to
limit their access, yet allow more flexibility to the highest tier of administrators to provide
them the flexibility to troubleshoot issues.
Use the information in the following subsections for guidance on collecting the application
inventory.
If none of these or third-party inventory tools are in use, use PowerShell to enumerate this
information. (Many of the PowerShell commands in this guide require that the PowerShell
console has been elevated to Run as administrator. This should be used for all examples in
this guide.) For example, you can use the following command (all on a single line) to
enumerate all installed applications on a reference computer and output it to a file named
InstalledApps.csv (which can be opened directly in Excel):
This will display 32-bit applications on 32-bit versions of Windows and 64-bit applications on
64-bit versions of Windows.
HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
These commands can be run interactively on each machine, or you can use PowerShell
remoting to aggregate this information from multiple computers. In order to do this, the
Windows Remote Management service must be running on each target computer, with a
listener configured and a Windows Firewall exception created. This can be done via Group
Policy, or can be done interactively by running winrm quickconfig on each target computer
that you will query. The following command is an example of how to collect this information
from two remote clients PC01 and PC02:
AppLocker policy should generally align with the software deployment methodology using
a single policy to enable applications in the base build, and then individual policies specific
to each deployment package. AppLocker rules from the base policy and the application-
specific policies will be merged to create an effective policy suitable for the software that is
installed on any given machine.
Similarly there may be a need for multiple application-specific policies. Consider a suite of
products like Microsoft Office. There may be no need (or no license) to run Access on some
computers, while it is required on others. In this case, two AppLocker policies should be
created, with only one allowing Access to run.
Monolithic Policies
With this methodology, the organization attempts to add all rules for all possible
applications into a small number of monolithic AppLocker policies (typically, one per
computer role or one per business unit).
Advantages:
Reduces the number of policies that must be deployed and managed.
Disadvantages:
A change in a rule for one business unit could have unintended consequences for
another business unit that uses the same computer role but has different application
needs. This impacts the flexibility of the policy to adapt to changing requirements.
The number of rules and resulting size of the GPO can get quite large.
The number of rules applied on each computer (a lot of which are for software that is
not installed) could get very large, and may impact application launch times.
You may need to support multiple versions of applications in the same policy, which
could get complex.
The advantages and disadvantages are essentially reversed compared to monolithic policies.
Advantages:
Flexibility to accurately target specific applications (or application versions) without
impacting other applications.
Exceptions are much easier to manage. If two business units use the same application
but have different constraints, it is much easier to maintain two separate policies than
try to meet all requirements in a single rule set.
Easy to create new policies for new applications and retire existing policies as
applications are retired.
Policies are small, highly targeted and therefore easy to comprehend.
The effective policy could be much smaller, as only rules for installed software are
applied.
Disadvantages:
Results in a large number of AppLocker policies to manage.
Creates the need to synchronize software and AppLocker rule deployments. If an
application gets deployed without the corresponding AppLocker rules being applied,
the newly installed application wont run.
Creates the need to target the right policies at the right computers. This targeting
can be done via the OU hierarchy and can be further filtered by security group
and/or WMI filters. (You could potentially use a WMI filter to detect an application
and therefore apply the corresponding AppLocker policy, however you would have to
wait for GPO processing to complete before a newly installed application could be
launched).
Recommended Approach
While the above discussion describes the two opposing approaches in designing AppLocker
policies, the optimal strategy is usually somewhere in between (typically favoring multiple
policies).
The monolithic approach works well when you combine multiple components that are
deployed and updated as a single unit into a single policy. An example of this would be the
base operating system, management tools and utilities. Components that are likely to be
upgraded without a full update to the operating environment are candidates for moving into
separate policies, so that the necessary changes to AppLocker rules to accommodate this
dont impact the base build. Another example of combining components into a single policy
With the GPO processing hierarchy in mind, determine the appropriate locations for linking
the GPOs that were defined in the previous step. Use the following guidelines:
Link to OUs at a sufficiently high level so that inheritance flows the rules down to
computers that need them, but not so high that you need to filter GPOs to prevent
them from applying to computers that shouldnt receive them.
If the OU structure doesnt promote the use of inheritance to flow rules to the
computers that need them without affecting computers that dont, link GPOs to the
OUs containing the desired computers. A single GPO can be linked to as many OUs
as is required.
If an OU contains computers that dont have the same policy requirements, you will
need to use security group and / or WMI filtering. This should be used sparingly as it
adds additional complexity to the comprehension of policy inheritance. It also
requires that computers are added / removed from the appropriate groups (in the
10
High value computers or computers operating in high risk environments may get local AppLocker policy applied during
deployment to provide immediate protection before AppLocker rules from Group Policy are applied. This should be balanced with
the fact that local policy cannot be managed centrally, and may become stale during the lifetime of the computer.
There are a number of additional configuration items that are related to AppLocker that
could potentially be configured in this GPO:
Configure the Application Identity service with a startup type of Automatic. This is
required for AppLocker.
Configure the Windows Remote Management (WS-Management) service with a
startup type of Automatic. This is required to forward events to a remote event
collector.
Configure the URL of the remote event collector as described in section 7.2.2 below.
Configure the custom error URL as described in section 5.7 below.
Refer to section 7.2 for steps to configure computers to forward AppLocker events to a
central event collector.
Modify the filter XPath string to return the events of interest adding or removing
conditions as required. At its simplest, setting it to * will return all events.
3. Run Get-WinEvent against the ForwardedEvents log using the filter defined in point
2 above. Events matching that filter are piped into the Get-AppLockerEvent function.
If a file name has been passed as a parameter to the Get-AppLockerEvent function
(as in the example below), the results will be written as comma-separated values to
the specified file. The CSV file can then be imported into Excel (specifying comma as
the delimiter) for viewing and reporting purposes.
If a parameter is not passed to the Get-AppLockerEvent function, custom objects
corresponding to each event that contain all of the AppLocker-specific details as
properties are output to the pipeline. This allows them to be displayed, or piped to
other cmdlets for further manipulation (filtering, sorting etc.) As all of the relevant
details are in the objects, they could also be used to populate an AppLockerPolicy
object which could be piped to the Set-AppLockerPolicy cmdlet to create additional
rules.
The above list is not exhaustive, but covers the majority of cases. For each case, an
organization should develop a process for addressing the issue that aligns with their existing
endpoint support processes. This is beyond the scope of this document.
In cases where users wish to request an exception to the current AppLocker policy, an
appropriate approval process must also be created (or an existing one leveraged).
Administrators have the ability to customize the error a user receives when their action is
blocked by AppLocker with a URL to a custom support page. This is configured through
Group Policy via the Set a support web page link setting under Policies | Administrative
Templates | Windows Components | Windows Explorer. The web page might host details
of the organizations policies or instructions on how to request an exception. It might also
contain a form for users to submit this information directly into a ticketing system or
approval workflow.
The organization might also consider creation of an emergency override process to disable
AppLocker in the event that serious errors in the policies are impacting the organizations
operations. This is another motivating factor for the dedicated GPO for AppLocker
enforcement mode described in section 5.5.2.3. If AppLocker problems cannot be rectified in
a suitable time frame and operations are being impacted, that GPO can be changed from
Enforce rules to Audit only until the problems can be fully resolved. As this could have a
significant impact on the security posture of the affected computers, it is essential that the
ICT security team be involved in the development of the emergency override process, and in
the decision / reporting chain before the process is initiated.
The organization needs to define a process for maintaining AppLocker policies over time,
including answers to the following questions:
Where will the requirements for change come from? Proactive (via analysis of
centrally-collected AppLocker events or through consultation with business units)
and / or Reactive (support cases from impacted users).
What is the approval process for AppLocker policy changes?
Which group is responsible for developing the AppLocker policy change?
Which group is responsible for testing the AppLocker policy change?
How does AppLocker policy fit into the regular and emergency change management
processes?
How will changes to policy be documented, tracked and communicated?
Which GPOs will host the AppLocker policy changes, who owns them and who will
import the changes?
Given the potentially disruptive nature of application whitelisting as a security control, the
ability to run in Audit only mode is critical to the successful adoption of this technology. All
computer profiles that will be part of the AppLocker rollout will go through a Stabilization
phase (described in section 7). In this phase, they will operate in Audit only mode for as
long as it takes for the appropriate authority to be satisfied that the implementation has
been sufficiently tested, and the support and maintenance processes are in place to address
issues as they arise.
Users should be informed about the nature of the change, the reasons it is being introduced,
and the timing of the change. Users should be directed to intranet sites containing details of
what will and wont be blocked, as well as the support and exception management
processes. Note that this URL should also be delivered by Group Policy and will be presented
to the user every time an action is blocked by AppLocker.
Determine what will be communicated to users, and the frequency of communication in the
lead up to AppLocker being enforced on their computers.
5.10.1 KB2532445
Applies to Windows 7 and Windows Server 2008 R2 (RTM and service pack 1). The fix is
included in Windows 8 / Server 2012.
The hotfix described at http://support.microsoft.com/kb/2532445 removes the potential for
scripting features (such as Office macros) to tamper with process memory and circumvent
AppLocker rules. Specifically, a number of functions11 have flags that allow code to load
irrespective of any AppLocker restrictions. This hotfix causes these flags to be ignored unless
the process is running under the context of Local System or TrustedInstaller.
5.10.2 KB977542
Applies to Windows 7 and Windows Server 2008 R2 (RTM only the fix was included in
service pack 1). The fix is included in Windows 8 / Server 2012.
The hotfix described at http://support.microsoft.com/kb/977542 removes the potential for
non-administrative users to boot the computer into safe mode to circumvent AppLocker
restrictions.
11
For example, the LOAD_IGNORE_CODE_AUTHZ_LEVEL flag for LoadLibraryEx
(http://msdn.microsoft.com/en-us/library/windows/desktop/ms684179.aspx)
Later sections will describe how to build rules for individual applications. The sum of these
individual policies will merge to form the effective policy enabling all required functionality
on a given computer role.
PowerShell is the preferred method for creating application-specific rules, and will be used
for the majority of the rule creation and validation process.
The following graphic illustrates the results of the wizard run against C:\ on a Windows 8
system.
Figure 2
Get-AppLockerFileInformation -Directory C:\ -Recurse FileType Exe | Select-Object Property Path, Publisher, Hash | Sort-
Object Property Publisher | Export-Csv Path .\Exe.csv Encoding Unicode NoTypeInformation
Repeat this by changing the FileType parameter for each of the different file types that
rules will be created for (Exe, Script, WindowsInstaller, and Dll).
The process for enumerating packaged apps is different. Use the example below to
document packaged apps:
The resulting spreadsheets will have 3 columns (2 for packaged apps) matching those in the
wizard:
Path the full path to the executable using the AppLocker-specific variables listed in
the table in section 2.4.4.1.
Publisher in the format
<Publishers distinguished name>\<Product name>\<File name>\<File version>
This field is blank for unsigned files.
Hash hash algorithm and value of the file. This column does not exist for packaged
apps.
Select the top entry, hold SHIFT and select the last entry that has an empty Publisher.
Ensure that all of the entries have been de-selected. This will exclude these files from the rule
creation process, and we will use the spreadsheet in a later stage to manually add rules for
the files we need to allow to run. Since the above PowerShell command sorts files by
Publisher, all unsigned files will be grouped at the top of the spreadsheet for easy
identification.
De-select Files for which you dont want Everyone Rules Created
There are two reasons for doing this:
There are files that you dont need anybody to be able to run effectively disabling
them as long as AppLocker policy is enforced.
There are files that you only want named users or groups to be able to run.
Click a column heading (File name, Product name or Folder path) to sort by that column in
order to find files that you do not want Everyone to run. As you de-select each file,
document the condition in a new column of the spreadsheet. For each file that you deselect,
enter either Disabled or the users or groups that can run it (bearing in mind that each
AppLocker rule applies to a single user or group, so a single group that contains all of the
users is preferable to avoid an excessive number of rules). Repeat this process until you have
de-selected and documented all of the files that meet the above two conditions.
When you have finished de-selecting files from the list, click OK. While you can always go
back and add or remove rules at a later stage, it is far easier to do this now, and allow the
wizard to optimize the rules created.
Repeat the above process for each of the other file types (scripts, installers, and packaged
apps). Note that unlike the other file types, DLL/OCX rules cannot be created using the
Automatically generate rules wizard, although the console can be used to create rules for
explicitly selected DLL/OCX files. To automatically generate rules for large numbers of
DLL/OCX files, use the PowerShell method that is described next.
Get-AppLockerFileInformation -Directory C:\ -Recurse FileType Exe | Select-Object Property Path, Publisher, Hash | Sort-
Object Property Publisher | Export-Csv Path .\Exe.csv Encoding Unicode NoTypeInformation
Repeat this by changing the FileType parameter for each of the different file types that
rules will be created for (Exe, Script, WindowsInstaller, and Dll).
Note that there is a bug in the Get-AppLockerFileInformation cmdlet whereby .ocx files are
not processed when FileType is set to Dll. To create rules for .ocx files, the Local Security
Policy MMC console must be used as described in the previous section.
The process for enumerating packaged apps is different. Use the example below to
document packaged apps:
Next, repeat the same command, but pipe the output to additional AppLocker cmdlets to
create the policy instead of creating the CSV. For example:
Get-AppLockerFileInformation -Directory C:\ -Recurse FileType Exe | New-AppLockerPolicy RuleType Publisher User
Everyone RuleNamePrefix SOE IgnoreMissingFileInformation Optimize | Set-AppLockerPolicy Merge
If there is a large number of unsigned files, it may be more efficient to create a single Path
rule targeting a folder that contains the files (or contains subfolders that contain the files). In
this case, it is critical to review permissions on that folder and all subfolders. If a subfolder
allows users to write, they could copy any arbitrary executable into that subfolder and
circumvent the AppLocker policy. Use a tool such as AccessEnum
(http://technet.microsoft.com/en-us/sysinternals/bb897332) to analyze write permissions on
the subfolder hierarchy.
If a user writable subfolder (or its subfolders) do contain executables (and you are not able
to change permissions on the folder), the only safe way to enable these files is via File hash
rules.
While File hash rules can contain many hashes from multiple folders, it is recommended that
a new File hash rule be created for each subfolder and the subfolder clearly indicated in the
rule name or description field. This will make it easier to know which hashes to update, as
you may have multiple files with the same name across the computers folder structure.
Note that this testing is designed to catch as many errors as possible, but is not intended to
be exhaustive. Once the rules pass this initial validation stage, they will be thoroughly tested
during the Stabilize phase of the AppLocker project.
The output is the list of objects that would be filtered in the method specified, together with
the AppLocker rule that resulted in that decision (in the case of Allowed or Denied).
Example2:
Test whether the AppLocker rules in Local Security Policy would deny a specific user from
running any .exe file in \System32 because there is not an explicit allow rule for any of the
files, and save it to a text file. You could also add the Recurse parameter to Get-ChildItem
to create a list of all files in all subfolders of the folder you specify. This could be used to test
all .exe files on C drive for a particular user. Note that you will receive errors in the
PowerShell console where you dont have access to the files in a subfolder, but the
command will complete for all subfolders that are accessible.
Example 3:
In this example the Filter parameter has been omitted, so we get a list of all of the .exe files
in \System32 and the action that would be taken for the specified user by rules in the local
policy (sorted by policy decision).
The Test-AppLockerPolicy cmdlet has other capabilities that will be useful throughout the
deployment and support of an AppLocker deployment:
Testing can be done against policy that has been exported to XML files rather than
requiring the policy to be live on a machine. This is useful for testing how new files
on a computer will be handled without having to actually load policy onto that
machine.
Testing can be done against policy that resides inside Active Directory GPOs, without
the policy actually being deployed to that machine. As above, this is useful for testing
how new files on a computer will be handled by different GPOs without having to
actually enforce policy on that machine. To do this, just use the Get-AppLockerPolicy
cmdlet with the Domain and Ldap parameters to specify the path to the GPO.
Testing can be done against the effective policy on a computer that is the merger
of all GPO policies that are in scope for that computer as well as its local policy. This
is extremely useful for troubleshooting issues on computers when policy comes from
If the EventType parameter is omitted entirely, all three event types are assumed.
Get-AppLockerFileInformation -EventLog -EventType Audited | New-AppLockerPolicy -RuleType Publisher, Hash, Path -User
Everyone RuleNamePrefix AUDIT -Optimize | Set-AppLockerPolicy Merge
A quick way of clearing all AppLocker logs with a single command is:
12
Microsoft recommends the use of Attack Surface Analyzer (http://www.microsoft.com/en-us/download/details.aspx?id=24487) to
evaluate application installations for introduction of known security weaknesses, such as weak ACLs on executable files.
There are a number of ways to achieve the above and a number of configuration settings
(such as authentication type) that wont be covered in this guide.
Running the command winrm qc from an elevated command prompt will achieve all of the
above requirements enabling the WinRM service, creating an HTTP listener that is bound
to every IP address on the server and accepting Kerberos or Negotiate authentication
protocols, and creating a Windows Firewall exception for the HTTP listener.
Running the command wecutil qc from an elevated command prompt will achieve all of the
above requirements.
Create an empty GPO in the computers domain that will host AppLocker rules for the base
build. The final command will disable the user portion of the GPO as AppLocker rules apply
to the computer portion only:
$gpoName = AL-SOE
$gpoComment = AppLocker policy for base SOE
$gpo = (New-Gpo Name $gpoName Comment $gpoComment)
$gpo.GpoStatus = UserSettingsDisabled
$gpoName = AL-SOE
Where <computer> is the name of the remote computer to update policy. You can also pipe
a list of computers to Invoke-GPUpdate to perform the update on multiple computers.
Double-click the gpresult.htm file that was created on the desktop and click Allow Blocked
Content at the bottom of the Internet Explorer window. Note that this command can also
be used against remote computers if the Remote Event Log Management rule group has
been enabled in the target computers Windows Firewall configuration.
Under the Computer Details section are a number of subsections that contain the required
information:
Group Policy Objects
o Applied GPOs shows each GPO that has been applied to the computer.
Expanding the GPOs will show the OU it was linked to, the security groups
that can apply it and any WMI filters on the GPO.
o Denied GPOs shows each GPO that was not applied to the computer.
Expanding the GPOs will show the OU it was linked to, the security groups
that can apply it and any WMI filters on the GPO. It also shows the reason
why the GPO was not applied.
Settings shows all settings that were applied to the computer from all of the
Applied GPOs (the resultant set of policy), and which GPO applied each setting (the
GPO with the highest precedence where multiple policies attempt to configure the
same setting).
The command should be repeated with different starting folders, different file types, and
with different users to get adequate coverage of the rule set. You could also test with the
filter condition of Allowed to see what specific users CAN run on the computer rather than
what would be blocked.
NB. An issue may occur with Windows 7 computers prior to service pack 1 where application
installers running under the SYSTEM account are blocked by AppLocker. This is a bug, as
AppLocker should not be controlling any processes running as SYSTEM. If affected, a
resolution is to create a path rule of * in the Windows Installer rule collection for user
NT AUTHORITY\SYSTEM.
8.2 Deploy
The monitoring solution described in section 5.6.3 is the appropriate tool to use for
proactive monitoring of the AppLocker solution. Ideally AppLocker events will have been
imported into SQL and SQL Reporting Services is being used to report on the data. If not,
the sample scripts provided in section 5.6.3 (and the appendix) can be used to mine the
event data and produce reports that can be viewed in Excel.
The frequency of monitoring will depend on the value of the resources being protected and
resources assigned to the task, however weekly monitoring of AppLocker events should be
considered the minimum frequency.
The outcome of monitoring will be one of two potential actions:
If suspicious or unauthorized activity is detected, an incident should be created to
investigate the cause.
If a significant number of users are being prevented from performing potentially
legitimate actions, it should be reported to the change control process. Management
can assess the need to accommodate the applications via additions to AppLocker
policy.
Read the entry in the Rule Name property of the returned event (or events):
If the Rule Name property has an entry, the file has been blocked by a Deny rule
and the property will give you the name of the rule that denied access. Use the rule
prefix to identify the GPO that it was delivered by, and investigate why this GPO has
been applied (i.e. by design or in error).
If the Rule Name property has a - symbol, it was blocked because it has not been
explicitly allowed. This is the more likely case.
There are a number of common reasons why an allow rule does not exist in the computers
effective policy. The action to take will depend on the cause:
The GPO has not been applied to the users computer. Use the gpresult tool as
described in section 7.5.1 to find out if the GPO is being filtered by WMI or security
group membership. If not, check whether the GPO links to the appropriate place in
the GPO hierarchy, and that inheritance is not being blocked.
An appropriate allow rule has not been created. Work with the application owner to
understand why the rules were not created and initiate change control to have this
resolved.
There is an error in the allow rule such as the file has been updated and no longer
matches the rule condition. Initiate change control to have this resolved.
function Export-AppLockerRules {
<#
Inputs:
Path to output XML file (can use path variables). If not specified, the user will be prompted for it (specify absolute path).
Rule prefix (without the ":"). If not specified (and the -All switch is not provided), the user will be prompted for it.
If the -Effective switch is provided, rules will be read from effective policy. If not, rules are read from local policy.
If the -All switch is provided, all rules will be exported. If not, only rules matching the prefix will be exported.
Output: Rules saved to specified XML file.
#>
param (
[string]$OutPath = (Read-Host Enter absolute path to XML file),
[string]$RulePrefix,
[switch]$Effective,
[switch]$All
)
If (!$RulePrefix -and !$All) {
$RulePrefix = (Read-Host `nEnter rule prefix (without the `":`") or cancel and rerun with the -All switch)
}
If ($Effective) {
[xml]$xml = Get-AppLockerPolicy -Effective Xml
Write-Host "`nExporting rules from Effective policy"
} else {
[xml]$xml = Get-AppLockerPolicy -Local Xml
Write-Host "`nExporting rules from Local policy"
}
If (!$All) {
Write-Host "Exporting rules with prefix `"$RulePrefix`:`"`n"
$xml.AppLockerPolicy.RuleCollection | ForEach-Object {$_.EnforcementMode = NotConfigured}
$nodesToRemove = $xml.SelectNodes("//FilePublisherRule[not(starts-with(@Name,'${RulePrefix}:'))] |
//FilePathRule[not(starts-with(@Name,'${RulePrefix}:'))] | //FileHashRule[not(starts-with(@Name,'${RulePrefix}:'))]")
$nodesToRemove | ForEach-Object {
[void]($_.ParentNode.RemoveChild($_))
}
} else {
Write-Host "Exporting ALL rules`n"
}
$xml.Save("$OutPath")
}
function Get-Sid {
param ([string]$user)
$ntaccount = New-Object System.Security.Principal.NTAccount($user)
return [string]$ntaccount.Translate([System.Security.Principal.SecurityIdentifier])
}