Threat Evasion for aws:multifactorAuthPresent condition using Cloudshell
An IAM policy that required MFA for sensitive Lambda actions could be bypassed by generating session credentials from the AWS Cloud Shell console, which already carries an MFA-authenticated session. An attacker holding a privileged user's access keys could therefore perform sensitive actions without knowing the MFA code.
Hello, astonishing hackers and security researchers out there. I hope you all are doing well.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
AWS IAM policies can carry conditions, and one of the conditions available for restricting sensitive API calls is aws:multifactorAuthPresent. When a policy requires this condition to be true, the call is only authorised if the principal authenticated with MFA. The intent is straightforward: if a privileged user's long-lived access keys leak, the attacker holding those keys cannot perform the sensitive actions, because programmatic use of the keys does not satisfy the MFA condition. The researcher's framing is that sensitive actions such as deleting, creating and launching services should only be possible from the console, where MFA has been presented.
The write-up examines whether that restriction can be evaded, and reports that it can, using AWS CloudShell to generate session tokens that then satisfy the condition.
Setup
The demonstration uses an IAM policy attached to a user, with two Lambda read calls gated on MFA: ListFunctions and GetAccountSettings. The researcher creates this policy and then tests the same call from two paths, the AWS console and programmatic access.

The image is captioned "Lambda IAM policy".
Finding it
The starting observation is that a privileged user can perform sensitive actions, including deleting, creating and launching services, without entering MFA even when MFA is enforced on the account. If that user's security credentials are compromised, anyone holding them can perform destructive actions. The researcher calls this issue "Sensitive actions without MFA".
The question then becomes what the MFA condition actually buys. The proposed defence is to require MFA for sensitive calls so that they can only be made from the console, where the user has authenticated interactively. The researcher's initial instinct about bypassing aws:multifactorAuthPresent: true was that it should not be possible. Reading Christophe's blog, "Retrieving AWS security credentials from the AWS console", suggested a different route.
Exploitation
Step 1: Confirm the policy blocks programmatic access
With the policy enforced, listing Lambda functions from the AWS console succeeds.

The image is captioned "Listing lambda functions from aws console".
The same call over programmatic access is denied.

The image is captioned "Listing lambda functions from programmatic access".
So far the condition behaves as intended: console yes, access keys no.
Step 2: Generate session tokens from CloudShell
Inspired by the blog post, the researcher generated session tokens from the CloudShell environment and then assumed the resulting session token, to see whether the MFA condition would still hold.

The image is captioned "Generating session tokens from cloudshell".
Step 3: Use the assumed session to call the gated API
With the session token generated in the previous step, the researcher listed the Lambda functions again.

The image is captioned "Listing lambda function from session token assumed".
The call that was denied with the original access keys now succeeds. The researcher states that this approach bypassed aws:multifactorAuthPresent: true.
A note in the report adds that the session token can be generated irrespective of the privileges assigned to the user for generating credentials.
Root cause
The report does not describe the internal mechanism that makes the condition evaluate as satisfied for credentials produced inside CloudShell. It only records the observed behaviour. The report does not state which principal or service performs the credential passing; it only describes the observed behaviour.
Logging
Logging was checked next, because it determines whether the bypass leaves a trail. The researcher started CloudShell and reviewed the CloudTrail event history, where an event named PutCredentials appeared.

The image is captioned "CloudTrail logs".
On further research the researcher concluded that this event only passes the console credentials to the CloudShell environment.

The image is captioned "PutCredentials in cloudshell".
The report concludes that this action is not being logged. The researcher describes the resulting credentials as "ghost session keys" that no one would ever get to know about.
Impact
Where a policy relies on aws:multifactorAuthPresent to keep sensitive actions console-only, an actor who can reach CloudShell can obtain session credentials that satisfy the condition and perform those actions programmatically. In the demonstrated case that meant listing Lambda functions, one of the two calls the policy gated. The researcher's broader concern is the scenario where a privileged user's access keys are exposed: the MFA condition is meant to stop the holder of those keys from carrying out destructive actions, and this path undermines that expectation. The report does not quantify the impact beyond the demonstrated calls and does not assign a severity.
Fix
The report gives one mitigation: restrict CloudShell access to users who actually require it, and apply the principle of least privilege. No vendor-side change is described. The researcher notes that the issue was reported to AWS before publishing.
Variants to test
What happened, in plain words
Imagine you have a safe at home that requires a fingerprint to open. You also have a spare key that you keep in a drawer. One day you realise that anyone who finds the spare key can open the safe without ever touching the fingerprint scanner, because the safe only checks for the fingerprint when you use the front panel, not when you use the key. That is roughly the kind of gap described here, but for cloud accounts.
In Amazon Web Services (AWS), you can set rules that say "this action is only allowed if the person has proved who they are with a second factor, like a code from their phone". That second factor is called multi-factor authentication (MFA). The idea is that even if someone steals your password or your long-lived access keys, they still cannot do sensitive things because they do not have your phone. The researcher found that a feature called AWS CloudShell can be used to create temporary credentials that the rules treat as if MFA had been used, even though no MFA prompt appeared. Those temporary credentials then let the attacker do the sensitive actions anyway.
The report walks through a demonstration: first showing that the MFA rule blocks the action when you use access keys directly, then showing that you can get around it by generating a session token inside CloudShell and using that instead. It also looks at whether this leaves a trace in the logs, and it suggests a way to reduce the risk.
Background: the pieces involved
Before going further, here are the main AWS concepts you need. If you already know them, skip ahead.
- AWS (Amazon Web Services): a collection of cloud services where you can run servers, store files, and manage users. You interact with it through a web console (a website) or through programmatic access (software making requests).
- IAM (Identity and Access Management): the part of AWS that controls who can do what. You create users, groups, and roles, and attach policies to them.
- IAM policy: a document written in JSON that lists permissions. For example, it might say "this user can list Lambda functions". Policies can also have conditions, which are extra requirements that must be met for the permission to apply.
- Lambda: a service that runs code without you managing servers. For this report, the important part is that you can list your Lambda functions and get account settings through the AWS API.
- API (Application Programming Interface): a way for software to talk to a service. When you click a button in the AWS console, the console is making API calls behind the scenes. When you use a command-line tool, you are also making API calls. Each API call has a name, like
ListFunctions. - AWS console: the website you log into with your username, password, and MFA code. It is interactive.
- Programmatic access: using access keys (an ID and a secret) to make API calls from software, without logging into the website. This is how scripts and command-line tools work.
- Access keys: long-lived credentials that let software act as a user. They are like a username and password for machines. If they leak, anyone can use them until they are revoked.
- MFA (Multi-Factor Authentication): a second proof of identity, such as a code from an app or a hardware key. It makes stolen passwords less useful.
aws:multifactorAuthPresent: a condition you can put in an IAM policy. It is true when the request was made by a principal that authenticated with MFA. If a policy requires it, the action is only allowed when MFA was used.- Principal: the identity making the request, such as an IAM user or a role.
- Session token: a temporary credential that represents a session. When you assume a role or get temporary credentials, you receive an access key ID, a secret access key, and a session token. The session token proves that the credentials are temporary and tied to a session.
- Assume a role / assume a session token: the act of using temporary credentials to act as a role or session. In this report, the researcher generates session tokens and then uses them (assumes them) to make API calls.
- CloudShell: a browser-based shell (command line) available in the AWS console. It comes with the AWS CLI pre-installed and is already authenticated as the user who launched it. You can run commands without setting up keys.
- CloudTrail: AWS's logging service. It records API calls made in your account, including who made them and when. You can view event history in the console.
- Least privilege: the principle of giving users only the permissions they need to do their job, nothing more.
The setup: an MFA-gated policy
The researcher starts by creating an IAM policy that requires MFA for two Lambda read actions: ListFunctions and GetAccountSettings. The policy is attached to a user. The goal is to demonstrate that with this policy, those actions can only be performed from the console, where the user has logged in with MFA, and not with programmatic access using access keys.

The image is captioned "Lambda IAM policy". The report says the policy makes ListFunctions and GetAccountSettings require MFA.
Why do this? Because if an attacker steals the user's access keys, the MFA condition should stop them from using those keys to perform sensitive actions. The researcher wants to test whether that protection holds.
Step 1: Confirm the policy works as intended
First, the researcher uses the AWS console to list Lambda functions. Since the user logged in with MFA, the condition is satisfied and the call succeeds.

The image is captioned "Listing lambda functions from aws console".
Next, the researcher tries the same call using programmatic access, meaning with access keys and the AWS CLI or SDK. This time the call fails with an Access Denied error.

The image is captioned "Listing lambda functions from programmatic access". The report says this attempt returned Access Denied.
So far, the policy behaves correctly: console yes, access keys no. This is the expected security control.
Step 2: The idea for a bypass
The researcher's initial thought was that bypassing aws:multifactorAuthPresent: true should be impossible. But after reading a blog post by Christophe, titled "Retrieving AWS security credentials from the AWS console", the researcher got an idea. The blog is titled "Retrieving AWS security credentials from the AWS console". The researcher wondered: could we generate session tokens from CloudShell and then use them to bypass the MFA condition?
Why CloudShell? Because CloudShell is part of the console and is already authenticated with the console session, which includes MFA. If CloudShell can produce credentials that inherit that MFA context, those credentials might satisfy the condition even when used programmatically.
Step 3: Generate session tokens from CloudShell
The researcher opened CloudShell and generated session tokens. The exact commands are not shown in the report, but the image shows the process.

The image is captioned "Generating session tokens from cloudshell".
Why do this? Because the researcher wants to obtain credentials that are different from the long-lived access keys. If the MFA condition is evaluated based on the authentication context of the session, these new credentials might be considered MFA-authenticated.
Step 4: Use the session token to call the gated API
With the session token in hand, the researcher configured the AWS CLI (or SDK) to use those temporary credentials and then attempted to list Lambda functions again.

The image is captioned "Listing lambda function from session token assumed". The report says this approach bypassed the MFA condition. The researcher states that this approach bypassed aws:multifactorAuthPresent: true.
Why did this work? The report does not explain the internal mechanism; it only records the observed behaviour.
The researcher adds a note: the session token can be generated irrespective of the privileges assigned to the user for generating credentials. The report says the session token can be generated irrespective of the privileges assigned for generating credentials.
Logging: is there a trace?
Logging is critical in cloud environments because it helps detect and investigate incidents. The researcher wanted to know if generating a session token from CloudShell would be logged. They started CloudShell and then checked CloudTrail event history. They found an event named PutCredentials.

The image is captioned "CloudTrail logs".
However, after further research, the researcher concluded that this event only passes the console credentials to the CloudShell environment. It does not log the generation of the session token itself.

The image is captioned "PutCredentials in cloudshell". The report concludes that this action is not being logged. The researcher calls the resulting credentials "ghost session keys" that no one would ever get to know about.
Why does this matter? Because if the bypass leaves no log entry, defenders have no way to detect that someone generated these credentials. That makes the issue more serious.
Impact
The impact is that an attacker who can access CloudShell can obtain session credentials that satisfy the MFA condition and then perform sensitive actions programmatically, even if those actions are supposed to be console-only. In the demonstration, the action was listing Lambda functions. The researcher's broader concern is that if a privileged user's access keys are exposed, the MFA condition is meant to prevent the attacker from doing destructive things. This bypass undermines that expectation. The report does not quantify the impact beyond the demonstrated calls and does not assign a severity.
Mitigation
The report suggests one mitigation: restrict CloudShell access to users who actually need it, and apply the principle of least privilege. In other words, do not give everyone the ability to open CloudShell, because it can be used to generate credentials that bypass MFA conditions. No vendor-side fix is described. The researcher notes that the issue was reported to AWS before publishing.
Variants to test
Glossary
- AWS (Amazon Web Services): a cloud computing platform offering many services.
- IAM (Identity and Access Management): AWS's system for managing users and permissions.
- IAM policy: a JSON document that defines permissions and conditions.
- Lambda: a serverless compute service in AWS.
- API (Application Programming Interface): a set of rules that allows software to communicate with a service.
- AWS console: the web-based interface for managing AWS.
- Programmatic access: using access keys to make API calls from software, without the console.
- Access keys: long-lived credentials (access key ID and secret access key) used for programmatic access.
- MFA (Multi-Factor Authentication): a second form of authentication, such as a code from a phone.
aws:multifactorAuthPresent: an IAM condition key that is true when the request is made with MFA.- Principal: the identity making a request, such as an IAM user or role.
- Session token: a temporary credential that represents a session, used alongside temporary access keys.
- Assume a role / assume a session token: to use temporary credentials to act as a role or session.
- CloudShell: a browser-based shell in the AWS console, pre-authenticated as the console user.
- CloudTrail: AWS's logging service that records API calls.
- Least privilege: the principle of granting only the permissions necessary to perform a task.
- Access Denied: an error returned when a request is not authorized.
- Ghost session keys: a term used by the researcher to describe session credentials that are not logged and thus leave no trace.