DIY AWS Security Review
A regular security review of your AWS account can reveal security issues with little effort. There are some very easy things you can automatically check with the help of the AWS Command Line Interface that have a big impact.
Limit network traffic from 0.0.0.0/0
Allowing traffic from the public internet is not bad by default. You usually want your website to be reachable from the public internet (0.0.0.0/0). But you should limit the entry points into your system to keep the attack surface small.
With this tiny Bash script you can get a list and usage report of all your Security Groups that allow traffic from 0.0.0.0/0.
|
An example output:
# Id of Security Group, How often used?, Name of Security Group |
For a common, auto scaled web environment you only need to allow traffic from 0.0.0.0/0 on port 80/443 on the load balancers (ELB). Your backend behind the ELBs allows traffic based on the source security group that is attached to the ELB.
Most often, you also need SSH access to your environment from 0.0.0.0/0 on port 22. But only to the bastion host. All other machines allow incoming traffic on port 22 only from the source security group of the bastion host.
Avoid unused Security Groups
If you accumulate Security Groups over time it gets harder and harder to find out what is really used.
With this tiny Bash script you can get a list and usage report of all your Security Groups.
|
An example output:
# Id of Security Group, How often used?, Name of Security Group |
The best way to avoid unused AWS resources altogether is to implement Infrastructure as Code.
Activate MFA for all your IAM users
Relying only on a password to get access to your AWS account is not recommended. Instead you should enable Multi-factor authentication (MFA).
With this tiny Bash script you can get a list of all your IAM users. A zero after the username indicates that MFA is not enabled.
#!/bin/bash |
An example output:
michael,1 |
In your Your single AWS account is a serious risk I describe an even better way to deal with IAM users.
Activate MFA for your root user
Every AWS account has a root user. You should not use the root user in your daily work. Instead you should create an IAM user. Nevertheless your root user should also be protected with Multi-factor authentication (MFA).
With this tiny Bash script you can check if your root user has MFA enabled. A zero indicates that MFA is not enabled.
#!/bin/bash |
An example output:
1 |
Further reading
- Article Avoid Sharing Key Pairs for EC2
- Article Event Driven Security Automation on AWS
- Article Introducing the Object Store: S3
- Article Serverless image resizing at any scale
- Tag cli
- Tag security