Files
floci/docs/services/sts.md
T
Priamo Germosen a3118eb42b fix(sts): evaluate GetSessionToken and GetFederationToken sessions as the user that minted them (#5081)
Under IAM enforcement, credentials from the two STS operations that mint a
session from a long-term key were evaluated as the wrong identity:

- A GetSessionToken session was stored with no role ARN, which
  resolveCallerContext answered with null, and the enforcement filter lets a
  known credential it cannot map to policies through. A user allowed only
  sts:GetSessionToken got credentials that passed every check, IAM calls
  included, and since the session had no caller ARN, AssumeRole took it for
  the account root and let it assume any role whose trust policy names the
  account. AppSync's IAM authorization and RDS IAM database authentication
  also read a null context as allowed, so they let these sessions through too.
- A GetFederationToken session was stored with the federated user's ARN where a
  role session keeps its role's, and its permissions were read from the role
  whose name followed the last slash. A user allowed only
  sts:GetFederationToken that federated under an existing role's name got that
  role's permissions; any other name got none, even with a session policy.

The STS API Reference says GetSessionToken credentials "have the same
permissions as the IAM user", and that a GetFederationToken session with no
session policy "has no permissions", and otherwise the intersection of "the IAM
user policies and the session policies". Both handlers now record the identity
whose key signed the request. An active key of a user in the request's account
names that user, by ARN and unique ID. A key no account holds, the legacy test
key or the account id among them, names the account root, which is how Floci
already treats such a key.

A GetSessionToken session is evaluated as that user, policies and boundary
included, or as the root, whose context the filter still bounds by the
account's service control policies. A federated session is evaluated as that
user intersected with its session policy. Without one it has no permissions of
its own, but keeps the Deny statements of its user's policies and boundary: a
resource policy naming the federated user grants to the session past implicit
denies, not past explicit ones (IAM User Guide, "Resource-based policies for AWS
STS federated user principal sessions"). Whatever its policies allow, a
federated session cannot call any IAM operation, nor any STS operation except
GetCallerIdentity (STS API Reference, GetFederationToken), so its context
always carries an explicit Deny for iam:* and sts:*; the filter answers
GetCallerIdentity before reading any policy.

A session whose issuer is gone is no credential at all, refused like an unknown
access key, so neither a resource policy nor S3's fallback to the account root
acts on its behalf. That covers a session minted with any other key IAM holds
(another session's, which AWS does not accept here, or an inactive key or
another account's, which account routing can land in the default account), a
session whose user was deleted and recreated under the same name, and one
stored before the issuer was recorded.

The caller identity follows: a GetSessionToken session's caller and principal
ARN are its user's, and a federated session's are its federated-user ARN, with
account:name as its user ID, as GetCallerIdentity reports for a federated user.

The unit test that pinned the GetSessionToken bypass now checks that a session
stored without an issuer is no credential; unit tests cover each kind of
issuer, the deny-only context of a federated session without a policy, and
that the issuer survives persistence. Integration tests (IAM and S3
enforcement, real SigV4) cover the role-name federation, the intersection, the
no-policy session, the GetSessionToken session and its AssumeRole, a
bucket-policy Deny keyed on the user's aws:PrincipalArn, both kinds of session
staying within the user's permissions boundary, a session of a recreated user
under a bucket policy granting everyone, and a bucket policy naming a federated
user against its user's explicit Deny, and a federated session refused IAM
and AssumeRole although both its user and session policy allow them; the SCP integration test now also checks
a root-minted session. All of them fail on main. Tests that built an STS
session credential as a role-less session with no issuer, a shape Floci no
longer creates, now build one the account root minted, or a presigned-URL
session, as production does.
2026-10-05 17:12:00 -05:00

6.9 KiB

STS

Protocol: Query (XML), POST http://localhost:4566/ with Action= parameter

Supported Actions

Action Description
GetCallerIdentity Returns the account ID, user ID, and ARN
AssumeRole Assume an IAM role, returns temporary credentials
AssumeRoleWithWebIdentity Assume a role using a web identity token (OIDC)
AssumeRoleWithSAML Assume a role using a SAML assertion
GetSessionToken Get temporary credentials for an IAM user
GetFederationToken Get temporary credentials for a federated user
DecodeAuthorizationMessage Decode an encoded authorization failure message

Configuration

Variable Default Description
FLOCI_SERVICES_STS_ENABLED true Enable or disable the service

Session Token and Federation Token Permissions

When FLOCI_SERVICES_IAM_ENFORCEMENT_ENABLED=true, credentials from GetSessionToken and GetFederationToken are evaluated as the identity whose long-term key signed the call, as on AWS:

  • GetSessionToken credentials have the permissions of that IAM user, or of the account root when its key minted them, still bounded by the account's service control policies.
  • GetFederationToken credentials have no permissions without a session policy (Policy). With one, they have the intersection of that policy and the permissions of the IAM user that minted them, never those of a role that shares the federated user's name. A resource policy naming the federated user's ARN can grant access on its own, but not past an explicit Deny in the user's policies or permissions boundary. Whatever their policies allow, they cannot call any IAM operation, nor any STS operation except GetCallerIdentity. Managed session policies (PolicyArns) are not supported yet.

A session minted with another session's temporary credentials, which AWS does not accept here, with an inactive access key or one that belongs to another account, or by an IAM user since deleted and recreated under the same name, is not a valid credential: it is refused like an unknown access key. A key IAM does not know anywhere mints sessions that act as the account root, as the key itself does.

Trust Policy Enforcement

AssumeRole and AssumeRoleWithWebIdentity require the target role to exist in IAM, returning AccessDenied (403) if it does not.

When FLOCI_SERVICES_IAM_ENFORCEMENT_ENABLED=true, AssumeRole also evaluates the target role's trust policy (AssumeRolePolicyDocument) against the caller and returns AccessDenied if it is not permitted. AWS principal forms are matched: "*", an account id, an account-root ARN (arn:aws:iam::<acct>:root), and exact principal ARNs; and an explicit Deny always wins. Both Action and NotAction elements are honored when matching sts:AssumeRole.

The caller is the account that owns the request's credentials, whether they sign the Authorization header or a presigned query string: an IAM user's or a role session's access key belongs to its own account, not to the default one. A role session matches a Principal that names its session ARN or its role's ARN, path included.

Condition blocks are evaluated with the same operators as identity and resource policies. The request context holds sts:RoleSessionName, sts:ExternalId when the caller passes ExternalId, aws:PrincipalArn (for a caller using assumed-role credentials, the role's ARN with its path, as on AWS), aws:PrincipalAccount, aws:ResourceAccount, aws:RequestedRegion and aws:PrincipalIsAWSService. A trust policy that requires sts:ExternalId, the confused-deputy guard, refuses a call that omits it or passes another value, and a conditional Deny applies only when its condition matches.

Known limitations

  • Session tags and source identity are not modelled. aws:RequestTag/*, aws:TagKeys, sts:TransitiveTagKeys and sts:SourceIdentity are not in the request context, so a condition on them does not match, and sts:TagSession and sts:SetSourceIdentity are not checked.
  • The caller's own permission is checked against *. The caller's identity policy must allow sts:AssumeRole, but it is evaluated for resource * rather than the role's ARN, so a policy that names the role in Resource does not grant it.

Web Identity Validation (IRSA)

AssumeRoleWithWebIdentity validates tokens minted by an OIDC issuer Floci hosts - currently an EKS cluster's IRSA provider.

When the token's iss names a known Floci issuer, all of the following are enforced:

  • the RS256 signature, against the issuer's public key
  • iss matches that issuer exactly
  • aud contains sts.amazonaws.com
  • exp / nbf, with 60s of clock-skew tolerance
  • the role's trust policy: Principal.Federated plus the Condition block, comparing <oidcProvider>:sub and <oidcProvider>:aud with exact, case-sensitive equality (StringEquals, StringNotEquals, StringLike, and StringNotLike are supported)

The response carries the token's real claims in SubjectFromWebIdentityToken, Provider, and Audience. A bad token returns InvalidIdentityToken (400), an expired one returns ExpiredTokenException (400), and a role that does not exist or a trust policy that does not permit the subject returns AccessDenied (403).

By default, tokens from an issuer Floci does not host, or tokens that are not parseable JWTs, are treated as opaque and accepted for compatibility with existing workflows, provided the target role exists in IAM. When FLOCI_SERVICES_IAM_ENFORCEMENT_ENABLED=true, those tokens return InvalidIdentityToken because Floci cannot verify a third-party provider's signature. See EKS for the full IRSA walkthrough and the token-minting endpoint.

Examples

export AWS_ENDPOINT_URL=http://localhost:4566

# Get caller identity (always works, useful for smoke testing)
aws sts get-caller-identity --endpoint-url $AWS_ENDPOINT_URL

# Assume a role
aws sts assume-role \
  --role-arn arn:aws:iam::000000000000:role/my-role \
  --role-session-name dev-session \
  --endpoint-url $AWS_ENDPOINT_URL

# Get a session token
aws sts get-session-token --endpoint-url $AWS_ENDPOINT_URL

GetCallerIdentity is commonly used in CI pipelines and integration tests as a quick connectivity check before running more complex tests. For temporary credentials returned by an assumed-role action, its Arn and UserId match the AssumedRoleUser.Arn and AssumedRoleUser.AssumedRoleId returned when the session was created. For GetSessionToken credentials they are those of the IAM user that minted them, and for GetFederationToken credentials the FederatedUser.Arn and FederatedUser.FederatedUserId (<account>:<name>).

When FLOCI_SERVICES_IAM_SEED_DEPLOYER_PRINCIPAL=true, requests signed with the seeded floci access key return arn:aws:iam::000000000000:user/floci-deployer. Other unknown local credentials continue to return the account root ARN for backward compatibility.