Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow users to change own password in iam-group-with-policies module #435

Merged

Conversation

vutny
Copy link
Contributor

@vutny vutny commented Nov 13, 2023

Description

This PR corrects IAM Self-manage policy according to example from AWS: Allows MFA-authenticated IAM users to manage their own credentials on the My security credentials page :

  1. Previously, it did not allow users to change their password on their own user page. To allow this, now the iam:GetLoginProfile and iam:UpdateLoginProfile actions to be added to the AllowManageOwnPasswords statement.
  2. The DenyAllExceptListedIfNoMFA statement has been corrected to include missing iam:GetMFADevice permission for own MFA management.
  3. Also, in the same statement iam:ChangePassword action should not be allowed without MFA authorization if it was enforced. This does not allow a user to create a password at sign-in, the MFA must be created and user must authenticate using it before attempting to change administrator provided password.

Motivation and Context

Stay up to date with AWS recommendations for access policies, grant permissions necessary for IAM user selfie-management via AWS Web Console.
Make sure if MFA is enforced, it disallows unauthorized password change for IAM user in case of credentials leak.

Breaking Changes

None.

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

@vutny
Copy link
Contributor Author

vutny commented Nov 13, 2023

@bryantbiggs , please have a look. Thanks!

"iam:CreateVirtualMFADevice",
"iam:EnableMFADevice",
"iam:GetUser",
"iam:GetMFADevice",
"iam:ListMFADevices",
"iam:ListVirtualMFADevices",
"iam:ResyncMFADevice",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing the official AWS documentation page with this statement block, should not we also have one more in not_action?

To also allow a user to change their password from their own user page without signing in using MFA, add the iam:UpdateLoginProfile action to the DenyAllExceptListedIfNoMFA statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc has a bit blurry description.
The iam:UpdateLoginProfile action as exception needed to change the password without MFA if MFA enforcement is present, for example on initial login to reset the password.
But at the same time it gives the ability to bypass MFA when using AWS CLI or API to update the password via login profile call, e.g. aws iam update-login-profile. So in case of compromised access keys, the password could be changed without MFA code which is only required to login through Web Console.

@antonbabenko antonbabenko changed the title fix(iam-group-with-policies): Allow users to change own password feat: Allow users to change own password in iam-group-with-policies module Nov 13, 2023
@antonbabenko antonbabenko merged commit eb5b218 into terraform-aws-modules:master Nov 13, 2023
35 checks passed
antonbabenko pushed a commit that referenced this pull request Nov 13, 2023
## [5.31.0](v5.30.2...v5.31.0) (2023-11-13)

### Features

* Allow users to change own password in iam-group-with-policies module ([#435](#435)) ([eb5b218](eb5b218))
@antonbabenko
Copy link
Member

This PR is included in version 5.31.0 🎉

@vutny vutny deleted the fix-change-password-policy branch November 14, 2023 08:45
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants