November 16, 2026 路 #61
The script that logs in as root
A nightly cost report script uses access keys created for the AWS account root user. What should you do?
Next puzzle in UTC
One try. The first answer sticks.
How to fix it
IAM policies cannot restrict the root user. Its keys can do anything, including closing the account. Remove them and give the script a narrow role.
The root user sits above IAM. You cannot attach a policy to limit it within its own account. Only an AWS Organizations service control policy affects root in a member account, and even that does not cover everything. Leaked root keys mean full control of every resource, the billing settings, and the account itself.
AWS recommends having no root access keys at all, and MFA on the root sign-in.
Fix
{
"Effect": "Allow",
"Action": ["ce:GetCostAndUsage", "ce:GetCostForecast"],
"Resource": "*"
}
Give that policy to a role the script assumes, through an instance profile, OIDC from CI, or IAM Identity Center for people. Delete the root keys in the security credentials page and check CloudTrail for their recent use.