With IAM enforcement on, AssumeRole matched a trust policy on its Action and
Principal only. The Condition block was never read and the ExternalId request
parameter was ignored, so a role guarded by sts:ExternalId, the documented
confused-deputy guard, could be assumed without it, and a conditional Deny
applied whether or not its condition held.
Trust-policy conditions now go through IamPolicyEvaluator's condition engine,
through a new package-private conditionMatches, so they get the same operators
as identity and resource policies. The request context holds sts:RoleSessionName,
sts:ExternalId when the caller sends one, the global keys the enforcement filter
already provides, and aws:PrincipalArn.
A role session is now matched as the role that issued it, through that role's
own ARN, path included. AssumeRole records it on the session when it issues
one, and a new IamService.resolvePrincipalArn reads it back as is, so an old
session keeps naming its role even after a same-named role replaces it. The
evaluator used to rebuild the role ARN from
the assumed-role session ARN, which names the role without its path, so a
session of role/team/App was compared as role/App: a Principal naming the role
refused it, and a condition on aws:PrincipalArn saw the wrong value. IAM stores
a Principal naming a role as the role's unique ID, and aws:PrincipalArn is the
ARN of the role that was assumed, so both are the full role ARN.
A negated operator on an absent key now holds, as the IAM User Guide says for
every condition operator but the IfExists forms and Null: "If the policy
condition requires that the key is not matched, such as StringNotLike or
ArnNotLike, and the right key is not present, the condition is true."
evaluateConditionBlock failed every operator on an absent key, so once trust
conditions were evaluated a Deny with StringNotEquals on sts:ExternalId stopped
refusing a call that omits ExternalId. The change is in the shared engine, so
identity, resource and SCP conditions get the same rule; the set operators keep
their own rule for an absent key.
The AppSync service-trust path from #4555 had its own small condition evaluator
for aws:SourceArn and aws:SourceAccount. It now uses the same engine with those
two keys as its context, which also makes negated operators such as
StringNotEquals work there instead of refusing the document. A Condition that
is not an object of non-empty operator objects still invalidates the whole
trust document, now on every path.
The trust check also resolved the caller's account from the Authorization
header alone, where only a 12-digit key names an account. An IAM user's or a
role session's key, and any presigned request, therefore counted as the default
account and could assume a role that trusts only that account. The check now
uses the account the request was resolved to, and reads a presigned caller's
key from X-Amz-Credential.