Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Foundations / Cloud security basics

Cloud security basics cheat sheet

The programs are the ones that the lessons build. They read a snapshot folder (account by default) and send nothing to any cloud.

Map an account (lesson 1)

TaskCommand
Make the snapshot of the lab accountpython3 gen_account.py (seed 2 in another folder: python3 gen_account.py 2 account2)
Count resources by service and region, list what is outside the approved regionspython3 account_map.py [folder]
Read an ARNarn:partition:service:region:account:resource, for example arn:aws:iam::111122223333:user/alice.morgan
Split an ARN in Pythonarn.split(":", 5)

Decide a request (lesson 2)

TaskCommand
Decide every request of the snapshotpython3 policy_eval.py [folder]
Decide one request in Pythondecide(policies, {"action": ..., "resource": ..., "context": {...}})
The orderA matching Deny wins (explicit deny). Else a matching Allow. Else no (implicit deny).
Same accountAn Allow on the identity or on the resource is enough
Different accountsBoth sides must allow
Deny when MFA is missing"BoolIfExists": {"aws:MultiFactorAuthPresent": "false"}

Find policies that give too much (lesson 3)

TaskCommand
Audit users, roles and policiespython3 iam_audit.py [folder] (exit code 1 on critical or high)
Audit one policy filepython3 iam_audit.py --policy FILE
Test a policy against must-allow and must-not-allow listspython3 policy_test.py POLICY.json [TESTS.json]
Patterns to look for"Action": "*", "service:*" on "*", iam:PassRole on *, a trust policy for "AWS": "*" with no condition

Keys (lesson 4)

TaskCommand
Age and last use of every access keypython3 key_report.py [folder] [today]
Find key IDs by handgrep -rnoE "(AKIA|ASIA)[A-Z0-9]{16}" FOLDER
Scan a folder and name the owner of each keypython3 scan_keys.py [folder] [iam-folder] (exit code 1 on a finding)
Tell the key types apartAKIA... long-lived, ASIA... temporary

Storage (lesson 5)

TaskCommand
Decide which buckets are public, and whypython3 buckets.py [FILE] (exit code 1 when one is public by mistake)
Stop public ACLs that existIgnorePublicAcls
Stop a public policy that existsRestrictPublicBuckets
Refuse new public ACLs and policiesBlockPublicAcls, BlockPublicPolicy
Refuse plain HTTPA Deny with "Bool": {"aws:SecureTransport": "false"}

Network (lesson 6)

TaskCommand
List the ports that the internet can reachpython3 reach.py [FILE] (exit code 1 on a port that is not expected)
Ask who can reach one port of one instancepython3 reach.py FILE INSTANCE PORT
Security groupAround a machine, allow rules only, stateful
Network ACLAround a subnet, allow and deny, lowest number first, stateless

Audit log (lesson 7)

TaskCommand
Print the risky calls and the gapspython3 trail.py [folder]
Timeline of one addresspython3 trail.py FOLDER --ip ADDRESS
Timeline of one access keypython3 trail.py FOLDER --key ACCESS_KEY_ID
Fields to read firsteventTime, userIdentity, eventSource, eventName, sourceIPAddress, errorCode, requestParameters
Sign-in without MFAeventName ConsoleLogin, additionalEventData.MFAUsed No

Metadata service (lesson 8)

TaskCommand
Start the mock on your own machinepython3 imds_mock.py optional 8700 > imds.log 2>&1 & then echo $! > imds.pid
Stop itkill $(cat imds.pid)
Get a session tokencurl -s -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 60" http://127.0.0.1:8700/latest/api/token
Use the tokencurl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://127.0.0.1:8700/latest/meta-data/instance-id
Judge a list of URLs without any trafficpython3 safe_fetch.py --list FILE
Print only the status codecurl -s -o /dev/null -w "%{http_code}\n" URL

Keys for encryption (lesson 9)

TaskCommand
Make a lab keypython3 kms_mock.py create NAME
Rotate, disable or enable itpython3 kms_mock.py rotate NAME, disable NAME, enable NAME
Encrypt a file with a data keypython3 envelope.py encrypt FILE ROLE
Decrypt itpython3 envelope.py decrypt FILE.sealed ROLE

Infrastructure as code (lesson 10)

TaskCommand
Make a plan file in the Terraform JSON shapepython3 gen_plan.py [seed] [file]
Scan a plan with rulespython3 iac_scan.py [PLAN] [RULES] (exit code 1 on high)
Use the scan as a gatepython3 iac_scan.py > scan.txt && echo APPLY || echo STOP

Containers (lesson 11)

TaskCommand
Check manifests for settings that break isolationpython3 k8s_check.py [folder] (exit code 1 on high)
Settings to look forprivileged, hostNetwork, hostPID, hostPath, no runAsNonRoot, the tag latest, no limits

Incident response (lesson 12)

TaskCommand
Plan the response to a leaked keypython3 respond.py FOLDER ACCESS_KEY_ID [NOW]
Check sealed evidence(cd FOLDER-response/evidence && sha256sum -c SHA256SUMS)
The orderKey inactive, scope in the log, end role sessions, close new doors, logging on, snapshot then stop, undo changes, new credential last
The callsaws iam update-access-key --user-name USER --access-key-id KEY_ID --status Inactive, aws iam put-role-policy --role-name ROLE --policy-name revoke-sessions --policy-document file://revoke.json, aws ec2 create-snapshot --volume-id VOLUME_ID, aws ec2 stop-instances --instance-ids ID (not run in this course)

Posture (lesson 13)

TaskCommand
Rank the findings of an account and write a reportpython3 posture.py [folder] [report.md] (exit code 1 on critical)
The scorecritical 9, high 6, medium 3, low 1, and 3 more when the internet can use it today

Where each file comes from in a real account

The course reads snapshot files. In an account you make them with the AWS CLI. This course does not run these calls: they need an account. The real answers have AWS's own shape: a short script joins them into the shape of this course (lessons 2, 5, 6 and 7 say where). requests.json, cross.json, ci-usage.json and ci-tests.json are invented for the exercises.

Snapshot fileCalls in a real account
inventory.jsonAWS Config or AWS Resource Explorer (lesson 1, Field notes)
iam.jsonaws iam get-account-authorization-details
key age and last useaws iam generate-credential-report, then aws iam get-credential-report
buckets.jsonaws s3api get-bucket-policy, get-bucket-acl, get-bucket-encryption and get-public-access-block (each with --bucket NAME), and aws s3control get-public-access-block --account-id ID
network.jsonaws ec2 describe-security-groups, describe-network-acls, describe-route-tables, describe-instances
trails.jsonaws cloudtrail describe-trails, aws cloudtrail get-trail-status --name TRAIL
events.jsonaws cloudtrail lookup-events (management events, last 90 days, one region), or the log files in the bucket of the trail

Safety habits