Sub topic 3
Understanding the root user
This chapter assumes you know what an AWS account is, you have a rough idea of IAM users, roles, and policies, and you can run commands in a terminal with the AWS CLI installed. By the end, you will be able to recognize the root user, explain why it differs from every other identity, and check whether you are using it by accident.
What the root user is
When you sign up for an AWS account, AWS creates one identity automatically: the root user. It is tied to the email address and password you used at sign-up. Nobody has to grant it permissions. It has complete access to every service and resource in the account, including billing, account settings, and the ability to close the account.
The root user is not an IAM user. IAM users, groups, and roles are objects you create inside the account, and each one gets only the permissions that policies give it. The root user exists before you create anything, and you cannot delete it.
| Property | Root user | IAM user or role |
|---|---|---|
| Created by | AWS, at sign-up | You, inside the account |
| Sign-in identity | Account email address and password | Account ID or alias, user name, and password (or federated sign-in) |
| Permissions | Everything in the account | Only what attached policies allow |
| Limited by IAM policies | No | Yes |
| Can be deleted | No | Yes |
| Count per account | Exactly one | Many |
Why IAM policies cannot restrict it
Identity-based policies and permissions boundaries do not apply to the root user. You cannot attach a "deny" policy to root to make it safer. Evaluation of a request from root skips the identity-policy checks that apply to IAM identities.
There is one control that does reach root. If your account is a member of an AWS Organization, a service control policy (SCP) can restrict the root user of that member account. SCPs do not affect the management account, so the root user of a management account is unrestricted. This is why the account you sign up with directly, which becomes the management account if you later create an organization, deserves the strongest protection.
Because the only protection is the credential itself, the practical rules are:
- Protect the credential with MFA.
- Do not create long-lived access keys for it.
- Do not use it for daily work.
- Keep the email address it depends on secure.
The following chapters cover each rule in detail. This chapter explains why they exist.
How you sign in as root
You sign in as root through the console sign-in page by choosing the root user option and entering the account email address. This is different from IAM sign-in, which asks for an account ID or alias and a user name. If a sign-in form asks for an email address and nothing else, you are signing in as root.
Root also has a different recovery path from IAM users. If you lose the password, AWS sends a reset link to the root email address. Whoever controls that mailbox can reset the root password, and if they also hold your MFA device or can pass the account recovery checks, they can take over the account. For this reason the email address is part of the root credential, not just a contact detail.
Recognizing root in your tools
You should be able to tell when a session or a log entry belongs to root. Three places show it.
The console. The account menu in the top right shows the identity. When you are signed in as root, it shows the account name and the label "Root user" in the sign-in details, rather than a user name or an assumed role.
The CLI. The sts get-caller-identity command returns the ARN (Amazon Resource Name, the unique identifier for an AWS object) of whatever credentials the CLI is using.
aws sts get-caller-identityFor root credentials, the output looks like this (the account ID is a placeholder):
{
"UserId": "111122223333",
"Account": "111122223333",
"Arn": "arn:aws:iam::111122223333:root"
}The ARN ends in :root. For an IAM user it ends in :user/name, and for an assumed role it contains :assumed-role/. If you ever see :root from a CLI that you set up for routine work, stop and fix it, because it means root access keys exist and are configured on that machine.
The account summary. IAM keeps two counters that describe root's state: whether root has MFA, and whether root has access keys.
aws iam get-account-summary \
--query 'SummaryMap.{RootMFA:AccountMFAEnabled,RootAccessKeys:AccountAccessKeysPresent}'The result is two numbers. A healthy account shows RootMFA as 1 and RootAccessKeys as 0. Note the naming: AccountMFAEnabled refers to the root user, not to your IAM users.
In CloudTrail, the service that records API activity, an event made by root has userIdentity.type set to Root. If you search your logs for that value, you get a list of every time root was used. In a well-run account that list is short, and every entry is something you can explain.
What goes wrong in practice
Most root-user incidents come from a small set of habits.
- Root for daily work. Someone signs up, sees that root can do everything, and keeps using it. Every browser session, shared laptop, and phishing page becomes a route to full account control.
- Root access keys. A key pair for root works from anywhere, never expires on its own, and bypasses every IAM boundary you build later. A leaked key often leads to cryptocurrency mining jobs and a large bill.
- A personal or shared mailbox as the root email. If the person leaves or the mailbox is compromised, the account is at risk. If the mailbox is deleted, recovery becomes slow.
- Sharing the root password. Several people knowing one password means you cannot tell who did what, and you cannot remove one person without rotating it for everyone.
- Assuming a deny policy protects you. Trying to restrict root through an IAM policy does nothing, as described above.
When root is still required
The root user is not useless. A small number of tasks cannot be done by any IAM identity, however privileged. Examples include changing the account's root email address, changing the AWS Support plan, closing the account, and restoring IAM permissions when every administrator has been locked out. The later chapter on root-only tasks lists them. The pattern to remember is that you sign in as root rarely, do one specific job, and sign out.
If your account belongs to an AWS Organization, newer centralized root access management lets the management account perform some of these tasks on member accounts through short-lived, task-scoped credentials. You can then remove root credentials from member accounts altogether. The chapter on AWS Organizations returns to this.
A quick check you can run now
Run the two commands from this chapter against your account, using an IAM identity or whichever credentials you currently have.
aws sts get-caller-identity
aws iam get-account-summary \
--query 'SummaryMap.{RootMFA:AccountMFAEnabled,RootAccessKeys:AccountAccessKeysPresent}'Read the results this way:
- If the ARN from
get-caller-identityends in:root, your CLI is using root keys. Plan to remove them. - If
RootAccessKeysis 1, root has at least one access key, even if you are not using it on this machine. Plan to delete it. - If
RootMFAis 0, root has no MFA. Fix this first. The next chapters cover choosing a factor and enabling it.
Key points
- The root user is created at sign-up, belongs to the account email address, and cannot be deleted.
- IAM policies and permissions boundaries do not limit it. Only an SCP in an Organization can, and not for the management account.
- The email address is part of the root credential because password reset goes through it.
- You can detect root by the
:rootARN, the account summary counters, andRootentries in CloudTrail. - Protect root with MFA, keep it free of access keys, and reserve it for the few tasks that require it.
Exercise
You run aws sts get-caller-identity on a build server and the ARN is arn:aws:iam::111122223333:root. What does this tell you, and what should you do?
Show answer
The CLI on that server is using root access keys. Those keys bypass every IAM restriction and never expire on their own, so a compromise of the server would mean full account compromise. Create an IAM identity or role with only the permissions the build needs, switch the server to it, then delete the root access keys in the console and confirm that AccountAccessKeysPresent in aws iam get-account-summary returns 0. Afterward, review CloudTrail for events with userIdentity.type of Root to see what the keys were used for.
Exercise
A teammate proposes attaching an IAM policy that denies ec2:* to the root user so it cannot launch instances by mistake. Will this work? What control could restrict root, and where does it not apply?
Show answer
No. Identity-based policies and permissions boundaries do not apply to the root user, so the policy would have no effect. A service control policy in AWS Organizations can restrict the root user of a member account. It cannot restrict the root user of the management account.