Slide 1

Slide 1 text

IAM Bad Privilege Escalation using Misconfigured Policies in AWS IAM Riyaz Walikar | Co-Founder - Kloudle | [email protected] May the 4th 2021 – 8:00 AM PDT (8:30 PM IST)

Slide 2

Slide 2 text

Riyaz Walikar Co-founder & Chief Breaker of Things @ Kloudle Inc. Twitter: @riyazwalikar, Blog: https://ibreak.software • Over a decade of experience in breaking web & mobile apps, networks, wireless, cloud and most recently container and Kubernetes • Have led Product Security and Consulting teams at Citrix and PwC SDC in a past life and was the OffSec Lead at Appsecco before moving on to co-founding Kloudle • Have multiple certifications as a result of my learning curve over the years, including CKA, CKAD, OSCP, CREST etc. (also, because they look cool on LinkedIn ☺) • Speaker at multiple cons, co-author, trainer, security evangelist with a short attention span and attracted to all things shiny

Slide 3

Slide 3 text

https://starwarsblog.starwars.com/wp-content/uploads/2021/04/disneyplus-star-wars-day-fan-art-takeover-7387930_TALL.jpg

Slide 4

Slide 4 text

What is the webinar about? • What is an AWS IAM policy? • Common examples of a misconfigured or overly permissive policy • Demo of a misconfiguration within a policy that leads to privilege escalation. • Q&A

Slide 5

Slide 5 text

What is an AWS IAM Policy • A policy is an object in AWS that, when associated with an identity or resource, defines their permissions. • AWS evaluates these policies when an IAM principal (user or role) makes a request. • Permissions in the policies determine whether the request is allowed or denied.

Slide 6

Slide 6 text

An Example AWS IAM Policy

Slide 7

Slide 7 text

Some examples of policy misconfigurations / permissive configurations

Slide 8

Slide 8 text

Common misconfigurations with Policies • Usage of wildcard * not bound to Action or Resource

Slide 9

Slide 9 text

Common misconfigurations with Policies • Usage of an “Action” that could lead to impersonation of another user

Slide 10

Slide 10 text

Common misconfigurations with Policies • Multiple policy versions with overly permissive configuration for an older version

Slide 11

Slide 11 text

Demo Multiple policy versions with overly permissive configuration for an older version

Slide 12

Slide 12 text

Demo Assumptions and Goal • Because we are demonstrating privilege escalation, we work with the assumption that we have gained access to General Tarkin’s AWS credentials • These credentials appear to be non-privileged. • Our aim is to exploit a mis-configuration with the user’s policy definition and gain access to the employee database for the Death Star

Slide 13

Slide 13 text

Identify who you are and if you have access

Slide 14

Slide 14 text

List what user defined policies are attached to the user

Slide 15

Slide 15 text

Get the policy’s current version number

Slide 16

Slide 16 text

Get v6 policy json definition

Slide 17

Slide 17 text

Get a list of available versions for the policy

Slide 18

Slide 18 text

Get v1 definition of the policy

Slide 19

Slide 19 text

Get v2 definition of the policy (and so on)

Slide 20

Slide 20 text

Get v5 definition of the policy (and notice the privileges)

Slide 21

Slide 21 text

Set v5 of the policy as the default policy

Slide 22

Slide 22 text

Access Darth Vader’s Employee database

Slide 23

Slide 23 text

Post privilege escalation? • With the kind of access you will get, explore what else is available within the AWS account • Attackers tend to focus on data theft/destruction and make an attempt to use resources for their own benefit (like crypto-mining) etc. • Some attackers create a shadow admin account and use this as a backdoor • To hide their traces within AWS, attacker may also remove AWS logs (CloudTrail, flowlogs etc.).

Slide 24

Slide 24 text

Commands from the Demo aws rds describe-db-instances --profile aws sts get-caller-identity --profile aws iam list-attached-user-policies --user-name --profile aws iam get-policy --policy-arn "" --profile aws iam get-policy-version --policy-arn "" --version-id v6 --profile aws iam list-policy-versions --policy-arn "" --profile aws iam get-policy-version --policy-arn "" --version-id v1 --profile aws iam get-policy-version --policy-arn "" --version-id v2 --profile aws iam get-policy-version --policy-arn "" --version-id v4 --profile aws iam get-policy-version --policy-arn "" --version-id v5 --profile aws iam set-default-policy-version --policy-arn "" --version-id --profile aws rds describe-db-instances --profile

Slide 25

Slide 25 text

Image credits • https://pngimg.com/uploads/stormtrooper/stormtrooper_PNG11.png • https://thenounproject.com/term/darth-vader/65913/ • https://starwars.fandom.com/wiki/Wilhuff_Tarkin

Slide 26

Slide 26 text

Q&A Site: https://kloudle.com Blog: https://kloudle.com/blog Twitter: - @kloudleinc - @riyazwalikar Reach us at: [email protected]