Describe the bug
When static AWS credentials (access keys) exist in ~/.aws/credentials, the aws login command displays a success message saying it "Updated profile default to use [new credentials]", but those new credentials are silently ignored. The static credentials from ~/.aws/credentials continue to be used due to credential precedence rules, with no warning to the user.
This creates a dangerous situation where users believe they have switched to different credentials (via aws login) but are actually still using their old static access keys.
Regression Issue
Expected Behavior
When a user runs aws login successfully:
-
If static credentials exist in ~/.aws/credentials for the same profile, AWS CLI should:
- Display a WARNING that static credentials will take precedence, OR
- Prompt the user to choose whether to remove the conflicting static credentials, OR
- Fail with a clear error message about the credential conflict
-
Users should never see "Updated profile to use X" when X will not actually be used
-
The success message should accurately reflect whether the login credentials will actually be used
Current Behavior
- User has static access keys in ~/.aws/credentials for [default] profile
- User runs
aws login and successfully authenticates
- AWS CLI displays: "Updated profile default to use arn:aws:sts::XXXXXXXXXXXX:assumed-role/RoleName/username credentials."
- User believes the profile now uses the new login credentials
- User runs AWS CLI commands
- Commands silently use the static credentials from ~/.aws/credentials
- The login credentials are completely ignored
- No warning or indication is given that a different credential is being used
Reproduction Steps
-
Configure static access keys in ~/.aws/credentials:
[default]
aws_access_key_id = AKIA...
aws_secret_access_key = xxx...
-
Verify current identity:
$ aws sts get-caller-identity
{
"Account": "111111111111",
"Arn": "arn:aws:iam::111111111111:user/test-user"
}
-
Run aws login and complete browser authentication
Output shows:
"Updated profile default to use arn:aws:sts::222222222222:assumed-role/AdminRole/username credentials."
-
Check identity again:
$ aws sts get-caller-identity
{
"Account": "111111111111",
"Arn": "arn:aws:iam::111111111111:user/test-user"
}
⚠️ Still using static credentials despite success message claiming profile was updated
-
Manually remove static credentials from ~/.aws/credentials
-
Check identity again:
$ aws sts get-caller-identity
{
"Account": "222222222222",
"Arn": "arn:aws:sts::222222222222:assumed-role/AdminRole/username"
}
✓ NOW using aws login credentials
Possible Solution
Option 1: Display a prominent warning when aws login detects conflicting static credentials
Option 2: Prompt user "Static credentials exist for this profile. Remove them? (y/n)"
Option 3: Change success message to indicate credentials may not be used due to precedence
Option 4: Fail aws login command with error explaining the credential conflict
Additional Information/Context
This is a security concern because:
-
Misleading success message: aws login claims "Updated profile to use [credentials]" but those credentials are not used if static keys exist in ~/.aws/credentials
-
Silent credential override: Users operate with different credentials than they authenticated with, with zero indication this is happening
-
Defeats the purpose of aws login: The feature is designed to eliminate static credentials, but silently continues using them when they exist
-
Accidental wrong-account operations: Users may believe they're operating in one AWS account (from login) while actually operating in a different account (from static credentials)
While AWS credential precedence is documented (credentials file > config file), the aws login command should either:
- Handle this conflict explicitly (warn/prompt/fail), OR
- Not display a misleading success message when the credentials won't actually be used
CLI version used
aws-cli/2.32.1
Environment details (OS name and version, etc.)
macOS 15.6.1
Describe the bug
When static AWS credentials (access keys) exist in ~/.aws/credentials, the
aws logincommand displays a success message saying it "Updated profile default to use [new credentials]", but those new credentials are silently ignored. The static credentials from ~/.aws/credentials continue to be used due to credential precedence rules, with no warning to the user.This creates a dangerous situation where users believe they have switched to different credentials (via aws login) but are actually still using their old static access keys.
Regression Issue
Expected Behavior
When a user runs
aws loginsuccessfully:If static credentials exist in ~/.aws/credentials for the same profile, AWS CLI should:
Users should never see "Updated profile to use X" when X will not actually be used
The success message should accurately reflect whether the login credentials will actually be used
Current Behavior
aws loginand successfully authenticatesReproduction Steps
Configure static access keys in ~/.aws/credentials:
[default]
aws_access_key_id = AKIA...
aws_secret_access_key = xxx...
Verify current identity:
$ aws sts get-caller-identity
{
"Account": "111111111111",
"Arn": "arn:aws:iam::111111111111:user/test-user"
}
Run
aws loginand complete browser authenticationOutput shows:
"Updated profile default to use arn:aws:sts::222222222222:assumed-role/AdminRole/username credentials."
Check identity again:
$ aws sts get-caller-identity
{
"Account": "111111111111",
"Arn": "arn:aws:iam::111111111111:user/test-user"
}
Manually remove static credentials from ~/.aws/credentials
Check identity again:
$ aws sts get-caller-identity
{
"Account": "222222222222",
"Arn": "arn:aws:sts::222222222222:assumed-role/AdminRole/username"
}
✓ NOW using aws login credentials
Possible Solution
Option 1: Display a prominent warning when aws login detects conflicting static credentials
Option 2: Prompt user "Static credentials exist for this profile. Remove them? (y/n)"
Option 3: Change success message to indicate credentials may not be used due to precedence
Option 4: Fail aws login command with error explaining the credential conflict
Additional Information/Context
This is a security concern because:
Misleading success message:
aws loginclaims "Updated profile to use [credentials]" but those credentials are not used if static keys exist in ~/.aws/credentialsSilent credential override: Users operate with different credentials than they authenticated with, with zero indication this is happening
Defeats the purpose of aws login: The feature is designed to eliminate static credentials, but silently continues using them when they exist
Accidental wrong-account operations: Users may believe they're operating in one AWS account (from login) while actually operating in a different account (from static credentials)
While AWS credential precedence is documented (credentials file > config file), the
aws logincommand should either:CLI version used
aws-cli/2.32.1
Environment details (OS name and version, etc.)
macOS 15.6.1