Using OpenAM as a Trusted File Authorization Engine

A common theme in the DevOps world, or any containerization style infrastructure, may be the need to verify which executables (or files in general) can be installed, run, updated or deleted within a particular environment, image or container.  There are numerous ways this could be done.  Consider a use case where exe’s, Android APK’s or other 3rd party compiled files need to be installed or used.

How to know the file is not-malicious, is of a trusted origin or hasn’t been tampered?  A simple way is to have a white listing engine that contains a definition of particular files that could be installed or run within an environment.  This is were OpenAM can come in.  The policy engine in AM, is not just tied to HTTP based URL’s and verbs.  Any arbitrary resource set can be defined with associated actions along with the necessary policies.

But how can we describe a file in the context of a resource?  A common method is to take a hash of the file object using a decent and modern algorithm such as SHA256.  Most iOS or Linux distro’s will have a sha256 sum tool that can be used for this.  But first, we need to create a resource type in AM for our files.


So here we create a simple resource type as an “exe”, with a pattern that will consist of the SHA256 sum of the file we want to check.  The actions for each file will consist of what the OS could do against the file…

The actions simply map into basic file tasks such as install, run delete etc.
Next we need to create a set a policies that will map to each file we want to add to our white list.  The policies are wrapped by a policy set.

This will act as a container for each policy we need to create.  But what does a policy look like? Each policy will contain the hash, some actions and also return the name of the file back in the response attributes.


It’s important to set the subjects condition to be a “Not Never Match” as we are not performing a user test, so no user session will ever be passed for evaluation.

But how can we get all of these policies created and imported into AM? Well, this just requires a little bit of automation on a trusted machine you want to use as the white list source. It’s pretty simple to take a hash of a file, and in turn create a JSON payload of the policy definition that can be sent into OpenAM to the ../openam/json/policies?_action=create endpoint in a POST request.  It’s pretty trival to script this process and run against hundreds of file at once.

So, we now have a policy set with hundreds of file definitions.  Now what?  Well, we can now call the policy evaluation endpoint over ../openam/json/policies/?_action=evaluate with any file hash we find and get a result back from AM that tells us what we can do with the file within the OS or image.


The response back from AM is equally as simple:


Here we get a list of actions we can perform against the file – we can install and run it, but not delete or update.

Another basic example of how modern authorisation is moving away from just modelling HTTP pages and verbs and focusing on REST based policy decision point and evaluation for virtually any resource.

©2022 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?