Skip to main content

AWS IAM tester - simple command-line tool to check permissions handed out to IAM users and roles.

Project description

Testing AWS IAM policies

Introduction

AWS IAM policies are notouriously complex, it is too easy to add some unintended permissions and it is surprisingly difficult to identify these in heavily used AWS accounts.

Even more surprisingly I couldn't find a ready-to-use utility that I could leverage.

Hence I created one myself.

Testing approach

The testing leverages AWS' IAM simulator (api), that basically includes the same IAM evaluation logic that is applied when working in the console or using the cli. The beneits of this approach are:

  • It takes all different levels of policies into account. Think about permission boundaries, service control policies and so on.
  • It is an official service from AWS, so you can expect this to kept up to date over time.
  • The actual actions are evaluated, but NOT executed. Hence no need for cleaning up resources after testing.

Configuration

In order to run, a configuration of the tests to run is required.

A sample configuration (with only one test) is shown below.

---
user_landing_account: 0123456789 # ID of AWS Account that is allowed to assume roles in the test account
global_exemptions: # The roles and/or users below will be ignored in all tests. Regular expressions are supported
- "^arn:aws:iam::(\\d{12}):user/(.*)(ADMIN|admin)(.*)$"
- "^arn:aws:iam::(\\d{12}):role/(.*)(ADMIN|admin)(.*)$"
- "^arn:aws:iam::(\\d{12}):role/AWSCloudFormationStackSetExecutionRole$"
# List of tests to execute. In general the configurations follow the rules of the AWS IAM Policy Simulator.
# For more information: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_testing-policies.html
tests: 
- actions: # list of actions to validate
  - "*:*"
  - iam:*
  - iam:Create*
  - iam:Pass*
  - sts:AssumeRole
  - sts:AssumeRoleWithSAML
  expected_result: fail # 'fail' or 'succeed'
  resources: # list of resources to validate against
  - "*"
  exemptions: [] # Additional exemptions (on top of the global excemptions) that will be ignored for this test

How to use

Assuming you have define a config.yml in your local directory, then to run and write the outputs to the local ./results directory:

aws-iam-tester --write-to-file

Using a specific config file:

aws-iam-tester --config-file my-config.yml

Include roles that cannot be assumed by human beings:

aws-iam-tester --include-system-roles

Note: including system roles does NOT include the aws service roles.

Or print debug output:

aws-iam-tester --debug

To run a limited number of evaluations (which helps speeding things up, and avoiding API throttling issues):

aws-iam-tester --number-of-runs 10

For more information, run aws-iam-tester --help for more instructions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws-iam-tester-0.0.4.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_iam_tester-0.0.4-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file aws-iam-tester-0.0.4.tar.gz.

File metadata

  • Download URL: aws-iam-tester-0.0.4.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.5 Linux/5.3.0-40-generic

File hashes

Hashes for aws-iam-tester-0.0.4.tar.gz
Algorithm Hash digest
SHA256 65c7f759a522809334ffe1dce66cfdd9e4786c77f0d5002989753264d96f7691
MD5 a23eb97176bf719976da5ef6d393e0d6
BLAKE2b-256 42955bde5c0c566da80a7009e27d4c182737eee181255804d2b1da8164dd599c

See more details on using hashes here.

File details

Details for the file aws_iam_tester-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: aws_iam_tester-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.5 Linux/5.3.0-40-generic

File hashes

Hashes for aws_iam_tester-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 01e03ea683c598f010e636e6eb9b1e7ad93bb6a7a4d67423c956234f6f707372
MD5 ce6dc3e9dbfb7a784be8b802009aa0df
BLAKE2b-256 216569251b336f49a536c004d61214bdf5ecdadae3a00d16cbc1e12059d6a0a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page