What is AppLocker?AppLocker is a mechanism in Windows for controlling access to applications. It does this based on a set of rules defined by the administrator of the domain or computer. These rules are defined on aspects of the application (usually based on its digital signature) and who is trying to use it. On the client side, AppLocker was introduced with Windows 7. On the server side, it was introduced in Windows Server 2008 R2. Different versions of Windows allow you to do different things with AppLocker. As a rule of thumb, on the client side, you need at least the Pro version of Windows (Pro, Enterprise, Ultimate). A full chart is available here.
.exe files are not the only executables you can control with AppLocker. You can also control scripts (PowerShell and Visual Basic scripts), packaged apps and their installers, DLLs, and Windows Installer files (.msi). Packaged app rules in AppLocker are available in versions of Windows with apps (Windows 8 / Server 2012 and higher). It is typically deployed through Group Policy either on a single computer or across a domain.
This feature is similar to (but not exactly the same as) other Mandatory Access Control (MAC) measures in Linux such as SELinux and AppArmor.
Why Would You Want To Use It?AppLocker is not intended to be the only defense mechanism you employ in your organization. As we talked about with EMET, it is meant to be one layer in a multi-layer defense. AppLocker is good when you want relatively granular control over which applications are allowed to run in your network. You might want to use AppLocker to only allow applications signed by trusted publishers (like your internal developers or organizations you have a relationship with).
How Do I Use It?The examples we will work through today are in our test domain that we built a little while back. If you have an appropriate version of Windows with AppLocker, you can implement it through Local Group Policy. The idea is the same.
To get started, open Group Policy Management (Start > Run > gpmc.msc or hit the Windows key and start typing Group Policy). Right click the organizational unit (OU) that you want to apply AppLocker policies to. In this case, we will use the Workstations OU we defined previously. Click "Create a GPO in this domain, and Link it here":
Give your GPO a name. I will call our example "Workstations AppLocker Policy"
Right click your newly created GPO and click Edit. AppLocker configuration is under Computer Configuration > Windows Settings > Security Settings > Application Control Policies > AppLocker.
We will start with Executable Rules. Expand the AppLocker section by click the little arrow next to it. Then click Executable Rules. In that window, right click anywhere and choose Create Default Rules:
- Everyone can execute anything in Program Files
- Everyone can execute anything in the Windows folder
- Administrators can execute anything
AccessEnum will enumerate all of the permissions on a given directory and its subdirectories. We can then save the output and use a program like LibreOffice Calc or Excel to filter down to the permissions that we care about. Essentially, we are looking for any folder that has write permissions for Users or Authenticated Users.
Here are the paths for easier copy / paste:
To do this, right click on the policy that says all programs in the Windows folder are allowed to run, click Edit, and then click the Exceptions tab:
For each path, click Add and type or copy / paste the paths we identified above (or ones that you identified):
When you are done, click OK. You can use AccessEnum for other directories you are worried about. In my environment, there were no user writable folders in either C:\Program Files or C:\Program Files (x86)
We will work through one more example. We will only allow signed applications to be run. This might not work for your environment, but it will stop a whole class of malware that is unsigned. This does not stop malware completely though, because even when only signed executables can run, the following could happen:
- If a trusted publisher's signing certificate is compromised, someone could sign malicious binaries with it (either an insider or an intruder).
- If someone is able to install a root certificate on a box, they could sign arbitrary software with it.
- If there is some vulnerability in a signed application, it could be exploited to run other executable code (i.e. from memory). AppLocker does not act on executables that are solely in memory.
To create the rule, right click Executable Rules then click Create New Rule. The Executable Rule Wizard will pop up:
We are writing a rule that only allows signs executables to run. This rule will apply to everyone. We will keep the two options shown here because we cannot say Deny unsigned executables to run. Rather, we have to say that only signed executables are allowed to run. Click Next.
Since we want to work with signatures and not paths or hashes, we will click Next here.
We have to provide a signed file. The publisher is not important because we are going to adjust it to allow any publisher. I chose write.exe under C:\Windows. Then, slide the slider up to Any Publisher.
If we wanted to restrict our rule to certain properties of the signature, such as Publisher or Product name we could do it here by supplying a reference file (a file signed in the way we want this rule to apply). We are not going to do that because we are okay with all signed executables running.
When you click Next, you can define exceptions to the rule.
We do not have any, so click Next.
You can give your new rule a name. I called it "Only allow signed executables"
Finally, click Create. You will see your new rule in the right pane.
Now we need to enforce the rules. There are two things we need to do. First, we have to enable the Application Identity Service to load Automatically. To do that, click System Services under Computer Configuration > Policies > Windows Settings > Security Settings.
Double click Application Identity, click Define This Policy Setting, then click Automatic:
Then click Configure Rule Enforcement on the right side:
Click the check box next to Configured under Executable rules. We have not defined any other types of rules, so we will leave those alone. You could choose to put the rules in Audit Only mode which means that only logs will be generated instead of actually blocking executables. This is good if you want to test your rules before deploying them. We live on the edge, so we will leave this at Enforced. Click OK.
Before we apply the Group Policy settings on the machine, let's try to run an evil Hello World program on our domain-connected client:
Oh no! We cannot let this happen! When we apply the group policy (restarting the computer is easiest), this is what happens when we try to run the same program:
Awesome. We saved our network from that evil program.
There is another good rule you can set up. Suppose a user brings in a USB from home, and without their knowledge, an executable on it is malicious. We can use AppLocker to stop programs from running from removable media. Here is how. When you create a rule, make a new Deny rule, and choose Path as the condition.
In the path box, enter %HOT%. %HOT% is the variable for removable drives. There are other variables you can use, all listed here. You can also use %REMOVABLE% to restrict access to executables on removable media like CDs.
Conclusions and Final Thoughts
AppLocker is another tool for your defensive toolbox. Like just about every other network security measure, it takes configuration and maintenance to be effective. The default rules will not cut because they can be easily bypassed as we saw with writable directories in the Windows folder. However, if you take the time to build a comprehensive rule set, AppLocker may help mitigate some of the vulnerabilities in your network.
AppLocker Policies Deployment Guide
Working with AppLocker Rules