Splunk is committed to using inclusive and unbiased language. This blog post might contain terminology that we no longer use. For more information on our updated terminology and our stance on biased language, please visit our blog post. We appreciate your understanding as we work towards making our community more inclusive for everyone.
Every organization that uses AWS has a set of user accounts that grant access to resources and data. The Identity and Access Management (IAM) service is the part of AWS that keeps track of all the users, groups, roles and policies that provide that access. Because it controls permissions for all other services, IAM is probably the single most important service in AWS to focus on from a security perspective. Over time, there are often personnel changes within the organization as users change roles or leave the company. When this happens, the user accounts may not get updated with the correct permissions or get deleted from IAM if the user is no longer an employee.
For this reason, Amazon describes the detection and removal of unused accounts as a fundamental best practice for any organization on AWS. Unused accounts that are not properly managed can end up being an entry point for malicious actors to gain access. Furthermore, IAM accounts are not just for human users. Applications, scripts and other services need IAM accounts to interact with AWS. Stale user accounts, whether they are for humans or applications, are a huge security risk for any organization.
So clearly it is important to regularly check inactive user accounts within your organization. This process is a prime candidate for automation so you can reduce time spent on it, and also to help you keep up the practice on a regular cadence. Our solution will involve two playbooks: one to find user accounts with passwords that have not been used in a long time, and another to disable those accounts.
The combination of these two playbooks will provide a semi-automated process that is repeatable and extensible. The first playbook will run on a scheduled interval, and the second playbook will be available to launch based on the results of the first playbook if there are any user accounts detected which are no longer in use.
In the rest of this blog post, we will take you step-by-step through how the playbooks work, how to deploy them, and some more advanced capabilities you can add to improve the playbooks. Want to see these two playbooks in action? Check out this video before diving into the written steps below!
Our first playbook is a scheduled search for AWS user accounts where the password hasn’t been used for 90 days (by default). By building this into a playbook, we’re removing the need to manually write a query against the IAM API or manually look through the list of all of your user accounts to find those that are dormant. This playbook was created entirely in the visual playbook editor in Splunk Phantom, so there is no custom code. If additional capabilities are needed, the playbook can easily be extended by adding on after the last block.
Here is a screenshot of the playbook:
First, the playbook lists all user accounts in IAM. For large organizations, this could be hundreds or even thousands of people and applications with different levels of access to AWS. The next block in the playbook is the filter that determines which user accounts have a “password last used” date older than our chosen time range. Finally, the playbook gathers additional information about those unused accounts, and stores the results for further action.
In order to get this playbook up and running you’ll need to configure three apps, then activate the playbook.
Here are the steps shown in the video above:
At this point the playbook should be scheduled and active. Navigate back to the Timer page and press the “Poll Now” button to create a test event and see the playbook in action.
Once this playbook is up and running for a few weeks, it might make sense to come back to it and add additional actions. Are there automatable steps that you find yourself doing manually each time you generate a list of unused AWS accounts? For instance, if you always send a Slack message to the same channel when you find an unused account, you could configure the Slack App on Phantom and add a “send message” action to the playbook.
Similarly, you might find that you always look up the department or job role of the user, so you could add an Active Directory or Okta integration to pull that information into the artifact in Phantom automatically to save time. Elsewhere in AWS there may be other resources you want to monitor on a regular basis. We have 10 more apps in addition to IAM which manage other services on AWS, so the structure of this playbook is something you could repurpose in many other use cases.
After running the first playbook, you will have your list of stale user accounts, and the last thing you want to do is disable them all manually. Our second out-of-the-box playbook will automate that task for you. Once you identify an AWS user account as a problem and decide it shouldn’t be there, the playbook will run and disable it. Here’s how:
The playbook starts with a filter that checks the allowlist, which is a custom list containing AWS usernames that should not be disabled. Next, the playbook prompts an analyst with the names of the user accounts to be disabled. If the analyst confirms the action, the final block deletes the appropriate login profiles on the AWS console and disables the associated access keys.
Most of the prerequisites for this playbook were configured in the Playbook I deployment steps video above. The only additional steps are to ensure that the AWS IAM asset in Phantom is using an access key which has the correct privileges, and to initialize the allowlist for IAM usernames, which should be ignored.
Once this playbook has been in use for a trial period, it may make sense to circle back and add more automated steps. For instance, a Splunk Enterprise query could reveal other accounts or resources associated with users that have left the organization or changed teams. To make this playbook more proactive, you could also connect it to a more robust process for enforcing least privilege, such as a Jira ticket that is created to exhaustively enforce least privilege any time an organizational change occurs.
The possible use cases vary widely, but hopefully this simple example makes it easy to get started!
This blog is part of a series called “SOAR in Seconds” where our distinguished Splunk Phantom experts guide you through how to use out-of-the-box playbooks and other features to automate repetitive tasks.
----------------------------------------------------
Thanks!
Philip Royer
The Splunk platform removes the barriers between data and action, empowering observability, IT and security teams to ensure their organizations are secure, resilient and innovative.
Founded in 2003, Splunk is a global company — with over 7,500 employees, Splunkers have received over 1,020 patents to date and availability in 21 regions around the world — and offers an open, extensible data platform that supports shared data across any environment so that all teams in an organization can get end-to-end visibility, with context, for every interaction and business process. Build a strong data foundation with Splunk.