fix(iam): read a role trust policy with the caller's principal keys (#5770)

A role's trust policy was the one context a request is evaluated against that
did not say who was calling. AssumeRolePolicyEvaluator assembled its own map
and put aws:PrincipalArn into it alone, so a trust policy keyed on aws:userid,
aws:PrincipalType or aws:username could not match, where every other context a
request is evaluated against carries all four through
CallerArns.putPrincipalKeys. The user guide puts aws:PrincipalType and
aws:userid in "the request context for all requests, including anonymous
requests" and aws:username in it for every IAM user, and an sts:AssumeRole
request is no exception: the guide's own example of a resource-based policy
tells principals apart in a Condition on aws:userid. Raised by hectorvent on
the review of #5568 and left to its own PR.

The evaluator now takes the caller's CallerArns in place of its two ARN
strings and writes the keys through that single writer, so no second context
has to be kept in step. STS passes the caller it already resolves, and a
credential that resolves to no identity is the account root stand-in it
already names in its denial, now with the account's own keys: the guide gives
the root user the account id as its aws:userid, the type Account and no
aws:username, which is what S3 and the enforcement filter already build for
it. That construction had three copies and is now one factory on the record.

Step Functions passes the execution role as the session it is, carrying
AssumedRole as its aws:PrincipalType: it assumes that role on the state
machine's behalf, so a target role's trust policy may condition on the type.
It mints no session name there, and a session's aws:userid is
role-id:session-name, so that key and aws:username stay absent.

AssumeRolePolicyEvaluatorTest builds its callers through the record, with
three cases on the keys: a condition on aws:username matching the caller and
not matching the same caller carrying no keys, aws:PrincipalType and
aws:userid telling a user apart from a role session, and a value the caller
carries winning over the request's own copy.
AssumeRoleTrustConditionsIntegrationTest signs four more AssumeRole calls end
to end, over a condition on the calling user's name, on the principal type, on
the root stand-in's account id, and on a session's role-id:session-name.
Reverting the evaluator to aws:PrincipalArn alone fails all seven; writing the
keys with putIfAbsent instead fails the precedence case alone.
LambdaTaskAuthorizerTest covers the Step Functions caller from both sides, a
trust condition on the principal type matching it and one on the session's own
id not matching.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-10-16 07:55:16 -05:00
1 parent b2d98d6d08
commit 608a38bff3
10 files changed
+284 -91

No files matched your search

+8 -4
View File
@@ -1543,10 +1543,14 @@ that way applies when the key is missing.
The keys that say who is calling are written onto every context a request is evaluated against:
the one the enforcement filter builds, one per resource the request names, one per transaction
item, and the one S3 builds when it evaluates a bucket policy itself under `s3.enforce-auth`. A
role trust policy is the exception: `sts:AssumeRole` evaluates its conditions with
`aws:PrincipalArn` alone, so a trust policy keyed on `aws:userid`, `aws:PrincipalType` or
`aws:username` does not match yet.
item, the one S3 builds when it evaluates a bucket policy itself under `s3.enforce-auth`, and the
trust policy `sts:AssumeRole` reads, which sees the caller through the same writer. A trust policy
keyed on `aws:userid`, `aws:PrincipalType` or `aws:username` therefore matches the calling user or
session, and a value the caller carries wins over one the request supplied. A credential that
resolves to no IAM identity is the account root stand-in, which carries the account id as its
`aws:userid` and `Account` as its `aws:PrincipalType`. One caller carries no `aws:userid`: the role
Step Functions assumes for a task, which is a session and says so with `AssumedRole`, but is minted
without a session name, and a session's `aws:userid` is `role-id:session-name`.
Transactions check each item as `PutItem`, `UpdateItem`, `DeleteItem`, `GetItem`, or
`ConditionCheckItem` before executing the request. Each item uses its own table, leading key
@@ -745,7 +745,7 @@ public class IamEnforcementFilter implements ContainerRequestFilter {
/** Floci's account-root principal, which is both the caller and the request's aws:PrincipalArn. */
private CallerArns accountRootArns(String accountId) {
String rootArn = AwsArnUtils.Arn.global(requestPartition(), "iam", accountId, "root").toString();
return new CallerArns(rootArn, rootArn, CallerArns.TYPE_ACCOUNT, accountId, null);
return CallerArns.accountRoot(rootArn, accountId);
}
/**
@@ -26,6 +26,12 @@ import java.util.regex.Pattern;
* condition value is a policy variable, and applies AWS precedence: an explicit {@code Deny} wins,
* otherwise a matching {@code Allow} grants.
*
* <p>The condition context is the request's own, with the caller's principal keys written onto it
* by {@link IamService.CallerArns#putPrincipalKeys}. The user guide puts {@code aws:PrincipalType}
* and {@code aws:userid} in "the request context for all requests" and {@code aws:username} in it
* for every IAM user, and an {@code sts:AssumeRole} request is no exception, so a trust policy
* condition reads the same principal as an identity or resource policy would.
*
* <p>Only AWS principals are modeled (account-root, bare account id, exact principal ARN, and
* {@code "*"}); {@code Service} and {@code Federated} principals never match a SigV4 caller and are
* ignored. A caller using assumed-role temporary credentials matches a trust policy that names its
@@ -67,30 +73,34 @@ public class AssumeRolePolicyEvaluator {
private enum PrincipalMatch { NONE, ACCOUNT, CALLER }
/**
* Returns true if {@code trustPolicyDocument} allows the caller (identified by
* {@code callerArn}, in {@code callerAccount}) to perform {@code sts:AssumeRole}, through any
* principal: see {@link #decide} for the arguments.
* Returns true if {@code trustPolicyDocument} allows {@code caller} (in {@code callerAccount})
* to perform {@code sts:AssumeRole}, through any principal: see {@link #decide} for the
* arguments.
*/
public boolean allows(String trustPolicyDocument, String callerArn, String principalArn,
public boolean allows(String trustPolicyDocument, IamService.CallerArns caller,
String callerAccount, Map<String, List<String>> requestContext) {
TrustDecision decision = decide(trustPolicyDocument, callerArn, principalArn, callerAccount, requestContext);
TrustDecision decision = decide(trustPolicyDocument, caller, callerAccount, requestContext);
return decision == TrustDecision.ALLOW || decision == TrustDecision.ALLOW_ACCOUNT;
}
/**
* Decides whether {@code trustPolicyDocument} lets the caller (identified by {@code callerArn},
* in {@code callerAccount}) perform {@code sts:AssumeRole}, and through which principal.
* Decides whether {@code trustPolicyDocument} lets {@code caller} (in {@code callerAccount})
* perform {@code sts:AssumeRole}, and through which principal.
*
* <p>{@code principalArn} is the caller's IAM identity: the user's ARN, or for a role session
* the role's own ARN, path included, which the session ARN does not carry. A {@code Principal}
* naming a role is matched against it, and it is the request's {@code aws:PrincipalArn}.
* {@code requestContext} holds the other condition keys the request carries, such as
* <p>{@code caller} carries both ARNs: the identity it acts as, which for a role session is
* its {@code assumed-role} session ARN, and its principal ARN, which for that session is the
* role's own ARN, path included. A {@code Principal} naming a role is matched against the
* second. It also carries the keys that say who is calling, which it writes onto the context
* through {@link IamService.CallerArns#putPrincipalKeys}, the same writer every other context
* a request is evaluated against uses: a trust policy sees the caller it would see anywhere
* else. {@code requestContext} holds the keys the request itself carries, such as
* {@code sts:ExternalId}; each statement's {@code Condition} is evaluated against both.
*
* <p>A null/blank/unparseable document or one with no matching statement is
* {@link TrustDecision#NEUTRAL}.
* {@link TrustDecision#NEUTRAL}, and a caller with no principal ARN writes no keys at all,
* which leaves every statement keyed on who is calling not applying.
*/
public TrustDecision decide(String trustPolicyDocument, String callerArn, String principalArn,
public TrustDecision decide(String trustPolicyDocument, IamService.CallerArns caller,
String callerAccount, Map<String, List<String>> requestContext) {
if (trustPolicyDocument == null || trustPolicyDocument.isBlank()) {
return TrustDecision.NEUTRAL;
@@ -107,9 +117,11 @@ public class AssumeRolePolicyEvaluator {
return TrustDecision.NEUTRAL;
}
String version = root.path("Version").asText(null);
String callerArn = caller == null ? null : caller.callerArn();
String principalArn = caller == null ? null : caller.principalArn();
Map<String, List<String>> context = new HashMap<>(requestContext);
if (principalArn != null) {
context.put("aws:PrincipalArn", List.of(principalArn));
caller.putPrincipalKeys(context);
}
Iterable<JsonNode> statementList = statements.isArray() ? statements : List.of(statements);
TrustDecision decision = TrustDecision.NEUTRAL;
@@ -5148,6 +5148,16 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
this(callerArn, principalArn, null, null, null);
}
/**
* Floci's account-root principal, for a credential that names no IAM identity. The
* guide's principal key values give the root user the account id as its
* {@code aws:userid}, {@code Account} as its {@code aws:PrincipalType} and no
* {@code aws:username}.
*/
public static CallerArns accountRoot(String rootArn, String accountId) {
return new CallerArns(rootArn, rootArn, TYPE_ACCOUNT, accountId, null);
}
/** A caller with no permissions boundary attached. */
public CallerArns(String callerArn, String principalArn, String principalType, String userId,
String userName) {
@@ -182,16 +182,20 @@ public class StsQueryHandler {
* in the header or presigned in the query, which for an IAM user or a session is the account
* that owns the key rather than the default one. A role session is matched as the role that
* issued it, whose ARN keeps the path the session ARN drops. The trust policy's conditions see
* the request's keys: the global keys, {@code aws:PrincipalArn}, {@code sts:RoleSessionName},
* and {@code sts:ExternalId} when the caller sends one.
* the request's keys: the global keys, {@code sts:RoleSessionName}, {@code sts:ExternalId}
* when the caller sends one, and the keys that say who is calling, which the resolved caller
* writes itself so that a trust policy reads the same principal as any other policy. A
* credential that resolves to no identity is the account root stand-in, carrying the account
* id as its {@code aws:userid} and {@code Account} as its {@code aws:PrincipalType}, as that
* principal does wherever else Floci builds it.
*/
private Response enforceTrustPolicy(String roleArn, IamRole role, String roleAccountId,
MultivaluedMap<String, String> params) {
String callerAccount = regionResolver.getAccountId();
Optional<IamService.CallerArns> callerArns = iamService.resolveCallerArns(callerAccessKeyId());
String callerArn = callerArns.map(IamService.CallerArns::callerArn)
.orElse(regionResolver.buildGlobalArn("iam", callerAccount, "root"));
String principalArn = callerArns.map(IamService.CallerArns::principalArn).orElse(callerArn);
IamService.CallerArns caller = iamService.resolveCallerArns(callerAccessKeyId())
.orElseGet(() -> IamService.CallerArns.accountRoot(
regionResolver.buildGlobalArn("iam", callerAccount, "root"), callerAccount));
String callerArn = caller.callerArn();
if (role == null || !IamService.roleArnMatches(roleArn, role)) {
return AwsQueryResponse.error("AccessDenied",
@@ -209,8 +213,8 @@ public class StsQueryHandler {
if (externalId != null) {
requestContext.put("sts:ExternalId", List.of(externalId));
}
if (trustPolicyEvaluator.allows(role.getAssumeRolePolicyDocument(), callerArn, principalArn,
callerAccount, requestContext)) {
if (trustPolicyEvaluator.allows(role.getAssumeRolePolicyDocument(), caller, callerAccount,
requestContext)) {
return null;
}
return AwsQueryResponse.error("AccessDenied",
@@ -1428,7 +1428,7 @@ public class S3Service implements Resettable, ResourceProvider {
}
String account = accessKeyId.matches("\\d{12}") ? accessKeyId : ownerId();
String rootArn = regionResolver.buildGlobalArn("iam", account, "root");
return Optional.of(new CallerArns(rootArn, rootArn, CallerArns.TYPE_ACCOUNT, account, null));
return Optional.of(CallerArns.accountRoot(rootArn, account));
}
/**
@@ -10,6 +10,7 @@ import io.github.hectorvent.floci.services.iam.IamPolicyEvaluator.ResourceAccoun
import io.github.hectorvent.floci.services.iam.IamPolicyEvaluator.ResourcePolicyDecision;
import io.github.hectorvent.floci.services.iam.IamPolicyEvaluator.SimulationDecision;
import io.github.hectorvent.floci.services.iam.IamService;
import io.github.hectorvent.floci.services.iam.IamService.CallerArns;
import io.github.hectorvent.floci.services.iam.RequestPrincipal;
import io.github.hectorvent.floci.services.iam.ResourcePolicyProvider.ResourcePolicy;
import io.github.hectorvent.floci.services.iam.ScpProvider;
@@ -135,8 +136,14 @@ public class LambdaTaskAuthorizer {
Map.of("aws:PrincipalArn", List.of(callerRoleArn), "sts:ExternalId", List.of(stateMachineArn)),
targetRoleArn, AwsArnUtils.parse(stateMachineArn).region(), callerId.accountId(), roleAccount);
TrustDecision trust = trustEvaluator.decide(target.get().getAssumeRolePolicyDocument(),
sessionArn(callerRoleArn), callerRoleArn, callerId.accountId(), context);
// Step Functions assumes the execution role on the state machine's behalf, so the caller
// is a session of it and carries AssumedRole as its aws:PrincipalType. That path mints no
// session name, and a session's aws:userid is role-id:session-name, so it and aws:username
// stay absent, which is what makes a condition on either of them not match.
CallerArns trustCaller = new CallerArns(sessionArn(callerRoleArn), callerRoleArn,
CallerArns.TYPE_ASSUMED_ROLE, null, null);
TrustDecision trust = trustEvaluator.decide(target.get().getAssumeRolePolicyDocument(), trustCaller,
callerId.accountId(), context);
ResourceAccountRelationship relationship = relationship(callerId.accountId(), roleAccount);
// A grant to the execution role's account delegates to that account, so within it the
// role's own policies have to allow the call too, as they do across accounts anyway.
@@ -19,6 +19,12 @@ class AssumeRolePolicyEvaluatorTest {
private static final String CALLER_ARN = "arn:aws:iam::111111111111:user/alice";
private static final String CALLER_ACCOUNT = "111111111111";
private static final IamService.CallerArns CALLER = caller(CALLER_ARN, CALLER_ARN);
/** A caller carrying its two ARNs and no principal keys, which is what most of these need. */
private static IamService.CallerArns caller(String callerArn, String principalArn) {
return new IamService.CallerArns(callerArn, principalArn);
}
private static String trust(String principal) {
return """
@@ -63,47 +69,47 @@ class AssumeRolePolicyEvaluatorTest {
void allowsAccountRootPrincipal() {
assertTrue(evaluator.allows(
trust("{\"AWS\":\"arn:aws:iam::111111111111:root\"}"),
CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
void allowsBareAccountPrincipal() {
assertTrue(evaluator.allows(trust("{\"AWS\":\"111111111111\"}"),
CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
void allowsExactPrincipalArn() {
assertTrue(evaluator.allows(
trust("{\"AWS\":\"arn:aws:iam::111111111111:user/alice\"}"),
CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
void allowsWildcardPrincipal() {
assertTrue(evaluator.allows(trust("\"*\""), CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertTrue(evaluator.allows(trust("{\"AWS\":\"*\"}"), CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertTrue(evaluator.allows(trust("\"*\""), CALLER, CALLER_ACCOUNT, Map.of()));
assertTrue(evaluator.allows(trust("{\"AWS\":\"*\"}"), CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
void allowsWhenPrincipalListContainsCaller() {
assertTrue(evaluator.allows(
trust("{\"AWS\":[\"arn:aws:iam::999999999999:root\",\"arn:aws:iam::111111111111:root\"]}"),
CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
void deniesWhenAccountDoesNotMatch() {
assertFalse(evaluator.allows(
trust("{\"AWS\":\"arn:aws:iam::999999999999:root\"}"),
CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
void deniesWhenPrincipalArnDiffers() {
assertFalse(evaluator.allows(
trust("{\"AWS\":\"arn:aws:iam::111111111111:user/bob\"}"),
CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -113,7 +119,7 @@ class AssumeRolePolicyEvaluatorTest {
{"Effect":"Allow","Principal":{"AWS":"*"},"Action":"sts:AssumeRole"},
{"Effect":"Deny","Principal":{"AWS":"arn:aws:iam::111111111111:root"},"Action":"sts:AssumeRole"}]}
""";
assertFalse(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows(doc, CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -122,7 +128,7 @@ class AssumeRolePolicyEvaluatorTest {
{"Version":"2012-10-17","Statement":[
{"Effect":"Allow","Principal":{"AWS":"*"},"Action":"sts:TagSession"}]}
""";
assertFalse(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows(doc, CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -131,7 +137,7 @@ class AssumeRolePolicyEvaluatorTest {
{"Version":"2012-10-17","Statement":[
{"Effect":"Allow","Principal":{"AWS":"111111111111"},"Action":"sts:*"}]}
""";
assertTrue(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertTrue(evaluator.allows(doc, CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -142,7 +148,7 @@ class AssumeRolePolicyEvaluatorTest {
{"Effect":"Allow","Principal":{"AWS":"*"},"Action":"sts:AssumeRole"},
{"Effect":"Deny","Principal":{"AWS":"*"},"NotAction":"sts:TagSession"}]}
""";
assertFalse(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows(doc, CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -153,7 +159,7 @@ class AssumeRolePolicyEvaluatorTest {
{"Effect":"Allow","Principal":{"AWS":"*"},"Action":"sts:AssumeRole"},
{"Effect":"Deny","Principal":{"AWS":"*"},"NotAction":"sts:AssumeRole"}]}
""";
assertTrue(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertTrue(evaluator.allows(doc, CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -163,7 +169,7 @@ class AssumeRolePolicyEvaluatorTest {
{"Version":"2012-10-17","Statement":[
{"Effect":"Allow","Principal":{"AWS":"111111111111"},"NotAction":"sts:GetSessionToken"}]}
""";
assertTrue(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertTrue(evaluator.allows(doc, CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -174,7 +180,7 @@ class AssumeRolePolicyEvaluatorTest {
String assumedRoleArn = "arn:aws:sts::111111111111:assumed-role/AppRole/session-abc";
assertTrue(evaluator.allows(
trust("{\"AWS\":\"arn:aws:iam::111111111111:role/AppRole\"}"),
assumedRoleArn, "arn:aws:iam::111111111111:role/AppRole", CALLER_ACCOUNT, Map.of()));
caller(assumedRoleArn, "arn:aws:iam::111111111111:role/AppRole"), CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -184,9 +190,9 @@ class AssumeRolePolicyEvaluatorTest {
String assumedRoleArn = "arn:aws:sts::111111111111:assumed-role/AppRole/session-abc";
String roleArn = "arn:aws:iam::111111111111:role/team/AppRole";
assertTrue(evaluator.allows(trust("{\"AWS\":\"arn:aws:iam::111111111111:role/team/AppRole\"}"),
assumedRoleArn, roleArn, CALLER_ACCOUNT, Map.of()));
caller(assumedRoleArn, roleArn), CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows(trust("{\"AWS\":\"arn:aws:iam::111111111111:role/AppRole\"}"),
assumedRoleArn, roleArn, CALLER_ACCOUNT, Map.of()));
caller(assumedRoleArn, roleArn), CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -195,7 +201,7 @@ class AssumeRolePolicyEvaluatorTest {
String assumedRoleArn = "arn:aws:sts::111111111111:assumed-role/AppRole/session-abc";
assertFalse(evaluator.allows(
trust("{\"AWS\":\"arn:aws:iam::111111111111:role/OtherRole\"}"),
assumedRoleArn, "arn:aws:iam::111111111111:role/AppRole", CALLER_ACCOUNT, Map.of()));
caller(assumedRoleArn, "arn:aws:iam::111111111111:role/AppRole"), CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -204,7 +210,7 @@ class AssumeRolePolicyEvaluatorTest {
String assumedRoleArn = "arn:aws:sts::111111111111:assumed-role/AppRole/session-abc";
assertTrue(evaluator.allows(
trust("{\"AWS\":\"arn:aws:sts::111111111111:assumed-role/AppRole/session-abc\"}"),
assumedRoleArn, "arn:aws:iam::111111111111:role/AppRole", CALLER_ACCOUNT, Map.of()));
caller(assumedRoleArn, "arn:aws:iam::111111111111:role/AppRole"), CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -212,7 +218,7 @@ class AssumeRolePolicyEvaluatorTest {
String assumedRoleArn = "arn:aws-us-gov:sts::111111111111:assumed-role/AppRole/session-abc";
assertTrue(evaluator.allows(
trust("{\"AWS\":\"arn:aws-us-gov:iam::111111111111:role/AppRole\"}"),
assumedRoleArn, "arn:aws-us-gov:iam::111111111111:role/AppRole", CALLER_ACCOUNT, Map.of()));
caller(assumedRoleArn, "arn:aws-us-gov:iam::111111111111:role/AppRole"), CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -220,7 +226,7 @@ class AssumeRolePolicyEvaluatorTest {
String assumedRoleArn = "arn:aws-cn:sts::111111111111:assumed-role/AppRole/session-abc";
assertTrue(evaluator.allows(
trust("{\"AWS\":\"arn:aws-cn:iam::111111111111:role/AppRole\"}"),
assumedRoleArn, "arn:aws-cn:iam::111111111111:role/AppRole", CALLER_ACCOUNT, Map.of()));
caller(assumedRoleArn, "arn:aws-cn:iam::111111111111:role/AppRole"), CALLER_ACCOUNT, Map.of()));
}
/**
@@ -232,7 +238,7 @@ class AssumeRolePolicyEvaluatorTest {
String assumedRoleArn = "arn:aws-us-gov:sts::111111111111:assumed-role/AppRole/session-abc";
assertFalse(evaluator.allows(
trust("{\"AWS\":\"arn:aws:iam::111111111111:role/AppRole\"}"),
assumedRoleArn, "arn:aws-us-gov:iam::111111111111:role/AppRole", CALLER_ACCOUNT, Map.of()));
caller(assumedRoleArn, "arn:aws-us-gov:iam::111111111111:role/AppRole"), CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -240,13 +246,13 @@ class AssumeRolePolicyEvaluatorTest {
String userArn = "arn:aws-us-gov:iam::111111111111:user/alice";
assertTrue(evaluator.allows(
trust("{\"AWS\":\"arn:aws-us-gov:iam::111111111111:root\"}"),
userArn, userArn, CALLER_ACCOUNT, Map.of()));
caller(userArn, userArn), CALLER_ACCOUNT, Map.of()));
}
@Test
void deniesServiceOnlyPrincipal() {
assertFalse(evaluator.allows(
trust("{\"Service\":\"lambda.amazonaws.com\"}"), CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
trust("{\"Service\":\"lambda.amazonaws.com\"}"), CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -314,10 +320,10 @@ class AssumeRolePolicyEvaluatorTest {
{"Effect":"Allow","Principal":{"AWS":"111111111111"},"Action":"sts:AssumeRole",
"Condition":{"StringEquals":{"sts:ExternalId":"Unique-ID-1"}}}]}
""";
assertFalse(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT,
assertFalse(evaluator.allows(doc, CALLER, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows(doc, CALLER, CALLER_ACCOUNT,
Map.of("sts:ExternalId", List.of("unique-id-1"))));
assertTrue(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT,
assertTrue(evaluator.allows(doc, CALLER, CALLER_ACCOUNT,
Map.of("sts:ExternalId", List.of("Unique-ID-1"))));
}
@@ -330,10 +336,10 @@ class AssumeRolePolicyEvaluatorTest {
{"Effect":"Deny","Principal":{"AWS":"111111111111"},"Action":"sts:AssumeRole",
"Condition":{"StringNotEquals":{"sts:ExternalId":"Unique-ID-1"}}}]}
""";
assertFalse(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT,
assertFalse(evaluator.allows(doc, CALLER, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows(doc, CALLER, CALLER_ACCOUNT,
Map.of("sts:ExternalId", List.of("other-id"))));
assertTrue(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT,
assertTrue(evaluator.allows(doc, CALLER, CALLER_ACCOUNT,
Map.of("sts:ExternalId", List.of("Unique-ID-1"))));
}
@@ -345,9 +351,9 @@ class AssumeRolePolicyEvaluatorTest {
{"Effect":"Deny","Principal":{"AWS":"111111111111"},"Action":"sts:AssumeRole",
"Condition":{"StringLike":{"sts:RoleSessionName":"blocked-*"}}}]}
""";
assertTrue(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT,
assertTrue(evaluator.allows(doc, CALLER, CALLER_ACCOUNT,
Map.of("sts:RoleSessionName", List.of("alice"))));
assertFalse(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT,
assertFalse(evaluator.allows(doc, CALLER, CALLER_ACCOUNT,
Map.of("sts:RoleSessionName", List.of("blocked-alice"))));
}
@@ -359,9 +365,9 @@ class AssumeRolePolicyEvaluatorTest {
"Condition":{"ArnLike":{"aws:PrincipalArn":"arn:aws:iam::111111111111:role/team/*"}}}]}
""";
String sessionArn = "arn:aws:sts::111111111111:assumed-role/AppRole/session-abc";
assertTrue(evaluator.allows(doc, sessionArn, "arn:aws:iam::111111111111:role/team/AppRole",
assertTrue(evaluator.allows(doc, caller(sessionArn, "arn:aws:iam::111111111111:role/team/AppRole"),
CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows(doc, sessionArn, "arn:aws:iam::111111111111:role/AppRole",
assertFalse(evaluator.allows(doc, caller(sessionArn, "arn:aws:iam::111111111111:role/AppRole"),
CALLER_ACCOUNT, Map.of()));
}
@@ -373,7 +379,7 @@ class AssumeRolePolicyEvaluatorTest {
{"Effect":"Deny","Principal":{"AWS":"111111111111"},"Action":"sts:AssumeRole",
"Condition":{"StringEquals":"sts:ExternalId"}}]}
""";
assertFalse(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows(doc, CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -401,9 +407,9 @@ class AssumeRolePolicyEvaluatorTest {
{"Effect":"Allow","Principal":{"AWS":"111111111111"},"Action":"sts:AssumeRole",
"Condition":{"StringLike":{"sts:RoleSessionName":"${aws:PrincipalAccount}-*"}}}]}
""";
assertTrue(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT,
assertTrue(evaluator.allows(doc, CALLER, CALLER_ACCOUNT,
sessionNamed(CALLER_ACCOUNT + "-build")));
assertFalse(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT,
assertFalse(evaluator.allows(doc, CALLER, CALLER_ACCOUNT,
sessionNamed("222222222222-build")));
}
@@ -415,12 +421,67 @@ class AssumeRolePolicyEvaluatorTest {
{"Effect":"Allow","Principal":{"AWS":"111111111111"},"Action":"sts:AssumeRole",
"Condition":{"StringLike":{"sts:RoleSessionName":"${aws:PrincipalAccount}-*"}}}]}
""";
assertFalse(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT,
assertFalse(evaluator.allows(doc, CALLER, CALLER_ACCOUNT,
sessionNamed(CALLER_ACCOUNT + "-build")));
assertTrue(evaluator.allows(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT,
assertTrue(evaluator.allows(doc, CALLER, CALLER_ACCOUNT,
sessionNamed("${aws:PrincipalAccount}-build")));
}
@Test
void aTrustConditionReadsTheCallersPrincipalKeys() {
String doc = """
{"Version":"2012-10-17","Statement":[
{"Effect":"Allow","Principal":{"AWS":"111111111111"},"Action":"sts:AssumeRole",
"Condition":{"StringEquals":{"aws:username":"alice"}}}]}
""";
IamService.CallerArns alice = new IamService.CallerArns(CALLER_ARN, CALLER_ARN,
IamService.CallerArns.TYPE_USER, "AIDAALICE", "alice");
assertTrue(evaluator.allows(doc, alice, CALLER_ACCOUNT, Map.of()));
// The same caller without the keys: aws:username is absent, so the statement does not apply.
assertFalse(evaluator.allows(doc, CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
void aTrustConditionTellsAUserApartFromARoleSession() {
String sessionArn = "arn:aws:sts::111111111111:assumed-role/AppRole/session-abc";
String roleArn = "arn:aws:iam::111111111111:role/AppRole";
IamService.CallerArns session = new IamService.CallerArns(sessionArn, roleArn,
IamService.CallerArns.TYPE_ASSUMED_ROLE, "AROAAPPROLE:session-abc", null);
IamService.CallerArns alice = new IamService.CallerArns(CALLER_ARN, CALLER_ARN,
IamService.CallerArns.TYPE_USER, "AIDAALICE", "alice");
String byType = """
{"Version":"2012-10-17","Statement":[
{"Effect":"Allow","Principal":{"AWS":"111111111111"},"Action":"sts:AssumeRole",
"Condition":{"StringEquals":{"aws:PrincipalType":"AssumedRole"}}}]}
""";
String bySessionId = """
{"Version":"2012-10-17","Statement":[
{"Effect":"Allow","Principal":{"AWS":"111111111111"},"Action":"sts:AssumeRole",
"Condition":{"StringLike":{"aws:userid":"AROAAPPROLE:*"}}}]}
""";
assertTrue(evaluator.allows(byType, session, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows(byType, alice, CALLER_ACCOUNT, Map.of()));
assertTrue(evaluator.allows(bySessionId, session, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows(bySessionId, alice, CALLER_ACCOUNT, Map.of()));
}
@Test
void aPrincipalKeyTheCallerCarriesWinsOverTheRequestsOwnCopy() {
// The caller is who the request is from, so its keys are written over the context the
// request assembled, exactly as the enforcement filter writes them last.
String doc = """
{"Version":"2012-10-17","Statement":[
{"Effect":"Allow","Principal":{"AWS":"111111111111"},"Action":"sts:AssumeRole",
"Condition":{"StringEquals":{"aws:username":"alice"}}}]}
""";
IamService.CallerArns alice = new IamService.CallerArns(CALLER_ARN, CALLER_ARN,
IamService.CallerArns.TYPE_USER, "AIDAALICE", "alice");
assertTrue(evaluator.allows(doc, alice, CALLER_ACCOUNT, Map.of("aws:username", List.of("mallory"))));
}
private static Map<String, List<String>> sessionNamed(String sessionName) {
return Map.of("aws:PrincipalAccount", List.of(CALLER_ACCOUNT),
"sts:RoleSessionName", List.of(sessionName));
@@ -429,19 +490,19 @@ class AssumeRolePolicyEvaluatorTest {
@Test
void aGrantNamingTheCallerIsToldApartFromAGrantToItsAccount() {
assertEquals(TrustDecision.ALLOW, evaluator.decide(trust("{\"AWS\":\"" + CALLER_ARN + "\"}"),
CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
CALLER, CALLER_ACCOUNT, Map.of()));
assertEquals(TrustDecision.ALLOW, evaluator.decide(trust("\"*\""),
CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
CALLER, CALLER_ACCOUNT, Map.of()));
assertEquals(TrustDecision.ALLOW_ACCOUNT, evaluator.decide(trust("{\"AWS\":\"arn:aws:iam::111111111111:root\"}"),
CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
CALLER, CALLER_ACCOUNT, Map.of()));
assertEquals(TrustDecision.ALLOW_ACCOUNT, evaluator.decide(trust("{\"AWS\":\"111111111111\"}"),
CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
void aStatementNamingBothTheAccountAndTheCallerGrantsToTheCaller() {
String doc = trust("{\"AWS\":[\"111111111111\",\"" + CALLER_ARN + "\"]}");
assertEquals(TrustDecision.ALLOW, evaluator.decide(doc, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertEquals(TrustDecision.ALLOW, evaluator.decide(doc, CALLER, CALLER_ACCOUNT, Map.of()));
String twoStatements = """
{"Version":"2012-10-17","Statement":[
@@ -449,7 +510,7 @@ class AssumeRolePolicyEvaluatorTest {
{"Effect":"Allow","Principal":{"AWS":"111111111111"},"Action":"sts:AssumeRole"}]}
""".formatted(CALLER_ARN);
assertEquals(TrustDecision.ALLOW,
evaluator.decide(twoStatements, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
evaluator.decide(twoStatements, CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
@@ -459,17 +520,17 @@ class AssumeRolePolicyEvaluatorTest {
{"Effect":"Allow","Principal":{"AWS":"%1$s"},"Action":"sts:AssumeRole"},
{"Effect":"Deny","Principal":{"AWS":"111111111111"},"Action":"sts:AssumeRole"}]}
""".formatted(CALLER_ARN);
assertEquals(TrustDecision.EXPLICIT_DENY, evaluator.decide(deny, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertEquals(TrustDecision.EXPLICIT_DENY, evaluator.decide(deny, CALLER, CALLER_ACCOUNT, Map.of()));
assertEquals(TrustDecision.NEUTRAL, evaluator.decide(trust("{\"AWS\":\"222222222222\"}"),
CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertEquals(TrustDecision.NEUTRAL, evaluator.decide(null, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
CALLER, CALLER_ACCOUNT, Map.of()));
assertEquals(TrustDecision.NEUTRAL, evaluator.decide(null, CALLER, CALLER_ACCOUNT, Map.of()));
}
@Test
void deniesBlankOrMalformedDocument() {
assertFalse(evaluator.allows(null, CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows("", CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows("{}", CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows("not json", CALLER_ARN, CALLER_ARN, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows(null, CALLER, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows("", CALLER, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows("{}", CALLER, CALLER_ACCOUNT, Map.of()));
assertFalse(evaluator.allows("not json", CALLER, CALLER_ACCOUNT, Map.of()));
}
}
@@ -42,6 +42,8 @@ class AssumeRoleTrustConditionsIntegrationTest {
private static final String DEFAULT_ACCOUNT = "000000000000";
private static final DateTimeFormatter AMZ_DATE_FMT =
DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'").withZone(ZoneOffset.UTC);
private static final String ALLOW_ASSUME_ROLE = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\","
+ "\"Action\":\"sts:AssumeRole\",\"Resource\":\"*\"}]}";
@Test
void externalIdConditionNeedsTheMatchingExternalId() {
@@ -91,13 +93,7 @@ class AssumeRoleTrustConditionsIntegrationTest {
@Test
void userKeyCallerIsTheUsersAccountNotTheDefaultAccount() {
String user = "trust-user-" + UUID.randomUUID().toString().substring(0, 8);
String accessKeyId = EnforcementFixtures.createUser(cleanup, baseUri.getPort(),
auth(OTHER_ACCOUNT, "iam"), user).accessKeyId();
given().formParam("Action", "PutUserPolicy").formParam("UserName", user).formParam("PolicyName", "p")
.formParam("PolicyDocument", "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\","
+ "\"Action\":\"sts:AssumeRole\",\"Resource\":\"*\"}]}")
.header("Authorization", auth(OTHER_ACCOUNT, "iam")).when().post("/").then().statusCode(200);
String accessKeyId = createCallerUser("trust-user-" + UUID.randomUUID().toString().substring(0, 8));
String trustsDefault = createRole(trustAccountRoot(DEFAULT_ACCOUNT));
String trustsOwnAccount = createRole(trustAccountRoot(OTHER_ACCOUNT));
@@ -105,6 +101,64 @@ class AssumeRoleTrustConditionsIntegrationTest {
assumeRole(accessKeyId, trustsOwnAccount, "s", null).then().statusCode(200);
}
@Test
void aTrustConditionOnTheUserNameMatchesTheCallingUser() {
String user = "trust-name-" + UUID.randomUUID().toString().substring(0, 8);
String accessKeyId = createCallerUser(user);
String ownerRoot = "arn:aws:iam::" + OTHER_ACCOUNT + ":root";
String namesTheCaller = createRole(trustWithCondition(ownerRoot,
"{\"StringEquals\":{\"aws:username\":\"" + user + "\"}}"));
String namesSomeoneElse = createRole(trustWithCondition(ownerRoot,
"{\"StringEquals\":{\"aws:username\":\"someone-else\"}}"));
assumeRole(accessKeyId, namesTheCaller, "s", null).then().statusCode(200);
assertTrustDenied(assumeRole(accessKeyId, namesSomeoneElse, "s", null), namesSomeoneElse);
}
@Test
void aTrustConditionTellsAUserApartFromARoleSession() {
String accessKeyId = createCallerUser("trust-type-" + UUID.randomUUID().toString().substring(0, 8));
String callerRole = "trust-type-role-" + UUID.randomUUID().toString().substring(0, 8);
createCallerRole(callerRole, "/");
Session session = assumeCallerRole(callerRole, "/");
String onlyUsers = createRole(trustWithCondition("*",
"{\"StringEquals\":{\"aws:PrincipalType\":\"User\"}}"));
String onlySessions = createRole(trustWithCondition("*",
"{\"StringEquals\":{\"aws:PrincipalType\":\"AssumedRole\"}}"));
assumeRole(accessKeyId, onlyUsers, "s", null).then().statusCode(200);
assertTrustDenied(assumeRoleWithSession(session, onlyUsers), onlyUsers);
assumeRoleWithSession(session, onlySessions).then().statusCode(200);
assertTrustDenied(assumeRole(accessKeyId, onlySessions, "s", null), onlySessions);
}
@Test
void theAccountRootStandInIsTheAccountItSignsFor() {
String accessKeyId = createCallerUser("trust-root-" + UUID.randomUUID().toString().substring(0, 8));
String onlyTheRoot = createRole(trustWithCondition("*",
"{\"StringEquals\":{\"aws:PrincipalType\":\"Account\",\"aws:userid\":\"" + TRUSTED_ACCOUNT + "\"}}"));
assumeRole(TRUSTED_ACCOUNT, onlyTheRoot, "s", null).then().statusCode(200);
assertTrustDenied(assumeRole(accessKeyId, onlyTheRoot, "s", null), onlyTheRoot);
}
@Test
void aTrustConditionReadsTheCallersUserId() {
String accessKeyId = createCallerUser("trust-id-" + UUID.randomUUID().toString().substring(0, 8));
String callerRole = "trust-id-role-" + UUID.randomUUID().toString().substring(0, 8);
createCallerRole(callerRole, "/");
Session session = assumeCallerRole(callerRole, "/");
// A user's aws:userid is its own unique id; a session's is role-id:session-name, and the
// session below was issued under the name s.
String userIds = createRole(trustWithCondition("*", "{\"StringLike\":{\"aws:userid\":\"AIDA*\"}}"));
String sessionIds = createRole(trustWithCondition("*", "{\"StringLike\":{\"aws:userid\":\"AROA*:s\"}}"));
assumeRole(accessKeyId, userIds, "s", null).then().statusCode(200);
assertTrustDenied(assumeRoleWithSession(session, userIds), userIds);
assumeRoleWithSession(session, sessionIds).then().statusCode(200);
assertTrustDenied(assumeRole(accessKeyId, sessionIds, "s", null), sessionIds);
}
@Test
void roleSessionIsMatchedAsItsRoleWithItsPath() {
String callerRole = "trust-path-" + UUID.randomUUID().toString().substring(0, 8);
@@ -168,6 +222,16 @@ class AssumeRoleTrustConditionsIntegrationTest {
private record Session(String accessKeyId, String sessionToken) {
}
/** A user in {@link #OTHER_ACCOUNT} carrying the sts:AssumeRole its own policies have to allow. */
private String createCallerUser(String user) {
String accessKeyId = EnforcementFixtures.createUser(cleanup, baseUri.getPort(),
auth(OTHER_ACCOUNT, "iam"), user).accessKeyId();
given().formParam("Action", "PutUserPolicy").formParam("UserName", user).formParam("PolicyName", "p")
.formParam("PolicyDocument", ALLOW_ASSUME_ROLE)
.header("Authorization", auth(OTHER_ACCOUNT, "iam")).when().post("/").then().statusCode(200);
return accessKeyId;
}
/** A role in the trusted account that its own account may assume, allowed to call AssumeRole. */
private void createCallerRole(String name, String path) {
cleanup.register(() -> EnforcementFixtures.removeRole(baseUri.getPort(),
@@ -176,8 +240,7 @@ class AssumeRoleTrustConditionsIntegrationTest {
.formParam("AssumeRolePolicyDocument", trustAccountRoot(TRUSTED_ACCOUNT))
.header("Authorization", auth(TRUSTED_ACCOUNT, "iam")).when().post("/").then().statusCode(200);
given().formParam("Action", "PutRolePolicy").formParam("RoleName", name).formParam("PolicyName", "p")
.formParam("PolicyDocument", "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\","
+ "\"Action\":\"sts:AssumeRole\",\"Resource\":\"*\"}]}")
.formParam("PolicyDocument", ALLOW_ASSUME_ROLE)
.header("Authorization", auth(TRUSTED_ACCOUNT, "iam")).when().post("/").then().statusCode(200);
}
@@ -226,6 +289,13 @@ class AssumeRoleTrustConditionsIntegrationTest {
"Principal":{"AWS":"%s"},"Action":"sts:AssumeRole"}]}""".formatted(principalArn);
}
private static String trustWithCondition(String principal, String condition) {
return """
{"Version":"2012-10-17","Statement":[{"Effect":"Allow",
"Principal":{"AWS":"%s"},"Action":"sts:AssumeRole",
"Condition":%s}]}""".formatted(principal, condition);
}
private static String trustAccountRoot(String account) {
return """
{"Version":"2012-10-17","Statement":[{"Effect":"Allow",
@@ -333,6 +333,31 @@ class LambdaTaskAuthorizerTest {
authorizer.assumeRefusal(ROLE, TASK_ROLE, STATE_MACHINE.replace(":orders", ":other")));
}
@Test
void theTrustPolicyCanRequireAnAssumedRoleCaller() {
roleWithPolicies(ASSUME_ANY_ROLE);
taskRole(TASK_ROLE, """
{"Version":"2012-10-17","Statement":[{
"Effect":"Allow","Principal":{"AWS":"%s"},"Action":"sts:AssumeRole",
"Condition":{"StringEquals":{"aws:PrincipalType":"AssumedRole"}}}]}""".formatted(ROLE));
assertEquals(Optional.empty(), authorizer.assumeRefusal(ROLE, TASK_ROLE, STATE_MACHINE));
}
@Test
void theTrustPolicyCannotMatchTheSessionsOwnIdOnThisPath() {
roleWithPolicies(ASSUME_ANY_ROLE);
taskRole(TASK_ROLE, """
{"Version":"2012-10-17","Statement":[{
"Effect":"Allow","Principal":{"AWS":"%s"},"Action":"sts:AssumeRole",
"Condition":{"StringLike":{"aws:userid":"*"}}}]}""".formatted(ROLE));
// Step Functions mints the session without a name, and a session's aws:userid is
// role-id:session-name, so the key is absent and a condition on it matches nothing.
assertEquals(assumeDenied(TASK_ROLE, "because no role trust policy allows the sts:AssumeRole action"),
authorizer.assumeRefusal(ROLE, TASK_ROLE, STATE_MACHINE));
}
@Test
void aRoleThatDoesNotExistCannotBeAssumedAndNoPolicyIsNamed() {
roleWithPolicies(ASSUME_ANY_ROLE);