Sub topic 3
Understanding the root user
This chapter assumes you know what an AWS account is and have signed up for one. You should also be comfortable running commands in a terminal with the AWS CLI installed. Here you learn what the root user is, what makes it different from other identities, and how to check its state.
What the root user is
When you create an AWS account, AWS creates one identity for you automatically: the root user. You sign in as the root user with the email address and password you used at sign-up. The root user owns the account and has full access to every service and resource in it.
Every other identity in the account is an IAM identity, such as an IAM user or an IAM role. IAM stands for Identity and Access Management. An IAM identity has only the permissions that policies grant it. The root user is different, because no policy limits it.
| Property | Root user | IAM identity |
|---|---|---|
| Created by | AWS, at sign-up | You or an administrator |
| Sign-in name | Account email address | IAM user name, or federated sign-in |
| Permissions | Everything, and they cannot be restricted by IAM policies | Only what attached policies allow |
| Can be deleted | No | Yes |
| Count per account | Exactly one | As many as you need |
Why its power is a risk
Because IAM policies cannot restrict the root user, anyone who signs in as root can do almost anything. That includes deleting every resource, changing the account's contact details, and closing the account. A stolen root password is therefore the worst outcome for an account.
This is why the rest of this tutorial protects root with a strong email address, multi-factor authentication (MFA), and no access keys. It also explains why you should do your daily work as a different identity.
Root credentials
The root user can have three kinds of credentials:
- A password, which you set at sign-up.
- An MFA device, which you add after sign-up and which this tutorial covers in a later chapter.
- Access keys, which let the CLI and SDKs call AWS as root. You should not create these.
A new account has a password and no MFA and no access keys. Your first job is to change that state, starting with MFA.
Checking the root user's state
You can read the root user's security state from the CLI. The account summary reports two values that matter here. AccountMFAEnabled is 1 if the root user has MFA, and AccountAccessKeysPresent is 1 if the root user has access keys.
aws iam get-account-summary \
--query 'SummaryMap.{RootMFA:AccountMFAEnabled,RootAccessKeys:AccountAccessKeysPresent}'On a brand-new account, you would expect output like this:
{
"RootMFA": 0,
"RootAccessKeys": 0
}The goal is RootMFA of 1 and RootAccessKeys of 0.
Next, confirm who your CLI credentials belong to. This matters because you should not run CLI commands as root.
aws sts get-caller-identityThe Arn field in the output shows the identity. A root identity looks like arn:aws:iam::111122223333:root. An IAM user looks like arn:aws:iam::111122223333:user/alice, and an assumed role looks like arn:aws:sts::111122223333:assumed-role/Admin/session. If you see :root, stop and switch to another identity.
Common errors
- Treating root as a convenient admin. It works, but it removes every safety limit. Create an administrative IAM identity instead.
- Creating root access keys "just to test". Keys stay valid until deleted and are easy to leak in code or logs.
- Confusing the root user with an IAM user named "root". An IAM user can have any name, but it is still bound by policies. Only the account-email identity is the real root user.
- Assuming the root user can be locked down with policies. Identity policies in IAM do not apply to it, so protect it with MFA and by limiting who knows its credentials.
Exercise
You run aws sts get-caller-identity and the Arn is arn:aws:iam::111122223333:root. What does this tell you, and what should you do?
Show answer
Your CLI credentials belong to the root user, which means they are root access keys. Root has unrestricted access and should not have access keys. Delete the root access keys, set up an administrative IAM identity, and use that identity for the CLI instead.
Exercise
Your account summary query returns RootMFA: 0 and RootAccessKeys: 0. Which value is already correct, and which still needs action?
Show answer
RootAccessKeys: 0 is correct, because the root user should have no access keys. RootMFA: 0 needs action, so enable MFA on the root user.