Access Keys Are Hardcoded on the EC2 Box. Just Rotate Them?
An app on EC2 authenticates to AWS with long-lived IAM user keys in a config file. One leaked. Defend the real fix.
Answer key reviewed by Branko Petric
Read first: AWS IAM: Users, Roles, and Policies
Your decision
Your app on EC2 talks to AWS using long-lived IAM user access keys stored in a config file on the instance, and one set just leaked. A teammate says generate new keys and paste them in. Do you agree, and what should you do instead?
The situation
Your application runs on EC2 and calls AWS services using an access key id and secret stored in a config file on the instance. Those keys just turned up somewhere they should not have, so they are considered leaked.
Context
The keys belong to an IAM user created long ago for this app. They have broad permissions and have never been rotated. A teammate wants to deactivate the leaked pair, create a new access key, drop it into the same config file, and move on. The instance currently allows IMDSv1.
Related challenges
- Cross-Account S3 Access Still Fails. Just Open It Up?
A partner account still gets AccessDenied on your encrypted S3 objects after you added a bucket policy. A teammate wants to make the bucket and key public. Defend the right fix.
- Your S3 Website Returns 403. Make the Bucket Public?
Objects in S3 return 403 and a teammate wants to turn off Block Public Access to fix it fast. Defend the right way to grant access.
- The t3 Instance Got Slow. Just Size It Up?
An app on a t3 instance crawls under steady load and a teammate wants a bigger instance. Defend what is actually throttling it.
- Lambda Is Exhausting Your RDS Connections. Raise the Limit?
Under load, Lambda functions fail with too many connections to RDS. A teammate wants to bump max_connections. Defend the real fix.