34

Is it possible to require Multi-factor Authentication (MFA) be enabled for specific/all IAM accounts in Amazon Web Services?

There are options for password requirements and it's clear how one can choose to add it to one's account, but it's not clear if there is an option to force users to have MFA.

1

6 Answers 6

12

After a bit of looking around, it appears that the answer is "kind of". In IAM, an administrator can configure a MFA for another IAM user. Although this may be a bit tricky if you are setting up a virtual MFA, it's possible. Then, if the user has not been granted permissions to update/remove their MFA, it is effectively required.

While I have not yet determined the complete list of actions that should be denied (or simply not granted), this post seems to have the information, and I will update this answer once I have tested it.

[Update]

I was able to setup users as power-users (thereby not granting them access to an IAM functions, although I'm sure you could get more granular), and implement their MFA with them. Using this methodology, they will be unable to disable it.

3
12

The answer is yes, there is. By using a condition. For instance, for admin accounts:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "*",
      "Resource": "*", 
      "Condition":
      {
          "Null":{"aws:MultiFactorAuthAge":"false"}
      }
    }
  ]
}

It will enforce MFA for both password authentication and token-based authentication using the API.

7
  • 8
    Doing it this way would require it for both Console & API access; would it be possible to require it for only Console access?
    – jeffbyrnes
    Jul 23, 2014 at 19:19
  • No idea. I know that it is annoying for the API (CLI) as MFA is not well supported. BTW I do not really see the point of setting up a stronger security if it is a way to bypass it by using another access method.
    – smad
    Jul 24, 2014 at 13:46
  • 4
    @smad I think the point would be that token credentials will be auto-generated and stored on the user's hard-drive so the only attack vector is getting it from the user's computer, either via malware, stealing the computer, etc. The password on the other hand might be weak or re-used on other sites, so there's an additional attack vector of brute-forcing it or getting it from a password dump from a hacked site. A password policy can help but it's hard to prevent ppl e.g. using a dictionary word with only the i replaced with a 1 or !
    – danny
    Nov 21, 2015 at 2:20
  • 1
    I'm not sure this is working anymore - at least, unless I didn't apply it correctly! (as a new policy, assigned to the Administrators group). Both new & existing administrators on my account are able to login without having set up MFA.
    – Tim Malone
    Apr 3, 2017 at 1:52
  • 1
    This doesn't deny existing permissions if the MFA is disabled but allows the user to do anything if the MFA is enabled. This cannot be cumulated to other fine-grain permissions. You should strongly warn newbies about that, it could be dangerous. This one is better obytes.com/blog/enforce-mfa-for-aws-iam-users
    – maxime
    Jan 5, 2022 at 11:52
10

The accepted answer is no longer valid AFAICT. AWS has documented how you can do this through their tutorial article here:

https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_users-self-manage-mfa-and-creds.html

I followed that for my new AWS Account and Team and it worked great.

2
  • 1
    weirdly i get " is not authorized to perform: iam:CreateVirtualMFADevice" even though it's listed in the NotActions for the deny block.
    – Sirex
    Sep 14, 2020 at 21:23
  • 1
    @sirex I had the same problem. I wrongly used "user" and not "mfa" in the resource ARN (arn:aws:iam::*:mfa/${aws:username}) Mar 15, 2021 at 17:32
1

Yes, you can require MFA for IAM accounts both for the web console, and for the awscli command line. In fact, it is not possible to reliably require MFA for the web console while not requiring it for the awscli command line, because both hit the same APIs. I say 'reliably' because with complex IAM policy it is possible to allow some awscli operations without MFA while enforcing MFA for the web console. However, the results are somewhat unpredictable, and besides, the IAM keys are equally if not more hazardous unprotected. My recommendation is to require it for both, and then perhaps create unprotected keys for special uses where MFA is absolutely contraindicated. For automated processes roles would be a better choice generally.

To make MFA operations on the command line easier, I've created a set of bash scripts and a carefully crafted MFA enforcement policy example that make it easy to attach/detach vMFAd, and to start and manage MFA sessions. They work on macOS and Linux variants, but likely not on Windows (not tested).

0

Apparently not. It appears that MFA for IAM accounts is optional, although you'd do best to post to the AWS Support Forums for an authoritative answer.

1
  • Thanks for the link, but it answers a different question about when MFA will be required once it is enabled. This question is about whether the enabling can be enforced.
    – Joe
    Feb 28, 2013 at 15:03
0

We documented a few considerations for AWS API multifactor in general (where to add the conditions, what are the implications etc.) in the documentation for some custom tooling (https://github.com/kreuzwerker/awsu) we developed for using Yubikeys as source for the TOTP tokens. This makes working with roles and long-term credentials + session tokens pretty easy.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .