Skip to content

fix(sts): mint global STS and IAM ARNs per partition and add a strict partition mode - #4743

Merged
pgermosen merged 5 commits into
mainfrom
fix/partition-sts-global
Oct 1, 2026
Merged

pgermosen merged 5 commits into
mainfrom
fix/partition-sts-global

Conversation

@hectorvent

@hectorvent hectorvent commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Part of #4272 (P9).

Global STS and IAM ARNs per partition. GetCallerIdentity's root fallback, the AssumeRole family's session ARNs (assumed-role/...), the OIDC provider ARN and GetFederationToken (federated-user/...) built their ARNs with an empty region, which falls back to the commercial partition, so they carried arn:aws: whatever partition the request signed. They now go through RegionResolver.buildGlobalArn. IAM's GetAccountSummary reports GlobalEndpointTokenVersion only where the partition publishes a global STS host (sts.amazonaws.com), which is aws alone.

IAM resources keep the partition they were created in. CreateUser, CreateGroup, CreateRole, CreatePolicy, CreateInstanceProfile and CreateOpenIDConnectProvider mint their ARNs in the request's partition, and UpdateUser and UpdateGroup re-mint in the stored ARN's partition rather than the renaming request's. AWS never has to choose, since an account belongs to one partition, but one Floci process serves them all, so anything derived from a stored resource follows it: an assumed-role session takes its role ARN's partition in all three AssumeRole handlers and in GetCallerIdentity, and the OIDC provider ARN a web identity trust policy is matched against takes the role's partition too. Only ARNs with nothing stored behind them (the GetCallerIdentity root fallback, federated-user) follow the request.

Strict partition mode, opt-in. floci.partitions.strict (FLOCI_PARTITIONS_STRICT, default false) refuses a request signed for a service AWS publishes in another partition but not in the request's one (CloudFront in GovCloud, IAM in aws-eusc) with the unknown-service guard's 404 UnknownOperationException. On AWS such a request never reaches an API because the host does not resolve; Floci cannot fail DNS, so it answers with that shape. endpoints.json omits the newer services that ship only an endpoint ruleset (FIS, MWAA, S3 Tables), so a service the data lists nowhere is served everywhere. Credential scopes carry signing names, and 46 of them differ from the endpoints.json keys they cover (73 keys, such as ecr for api.ecr and bedrock for bedrock-runtime); tools/aws/regen_partitions.py now vendors that map from botocore's service-2.json metadata as signingNames, and AwsPartition.offersSigningName joins it. Off by default, nothing changes.

Config is wired through EmulatorConfig, both application.yml files, docs/configuration/environment-variables.md, docs/configuration/advanced/application-yml.md and docs/configuration/partitions.md.

Independent of #4742 (P8): the two share IamService, IamServiceTest and partitions.md but touch different hunks, so whichever merges second may need a small rebase.

Type of change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change (feat!: or fix!:)
  • Docs / chore

AWS Compatibility

Incorrect behaviour: outside the commercial partition, GetCallerIdentity (root fallback), AssumeRole, AssumeRoleWithWebIdentity, AssumeRoleWithSAML and GetFederationToken returned arn:aws: ARNs, as did CreateUser, CreateGroup, CreateRole, CreatePolicy, CreateInstanceProfile, CreateOpenIDConnectProvider and the credential report's root row, and GetAccountSummary reported a GlobalEndpointTokenVersion for partitions with no global STS endpoint. The strict mode is new and opt-in.

Checklist

  • ./mvnw test passes locally: the focused suites for everything that touches STS, IAM, GetAccountSummary, the account context filter or the partitions config pass (99 classes, 1283 cases after the IAM ARN round, including StsQueryHandlerTest, AccountContextFilterTest, PartitionStrictModeIntegrationTest, IamIntegrationTest, the EKS IRSA and IAM enforcement suites). TlsIntegrationTest could not start locally because Docker already held port 4566; it does not touch this change and runs in CI. make aws-data-check and make aws-data-test (69) pass; the full suite runs in CI's four shards
  • New or updated integration test added (IamPartitionArnIntegrationTest, PartitionStrictModeIntegrationTest, PartitionRegionGatesIntegrationTest, StsSessionIdentityIntegrationTest, AccountContextFilterTest, StsQueryHandlerTest, IamServiceTest, AwsPartitionsTest, test_regen_partitions.py)
  • Commit messages follow Conventional Commits

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High risk] Changes how IAM resources are created and how STS sessions inherit partition information.

The PR appears safe to merge, although existing persisted credential reports become temporarily unavailable after upgrade until regenerated.

Findings

  1. P2 Persisted reports become unavailable ▶
Summary

The PR makes IAM and STS global ARNs partition-aware and adds an opt-in guard for services absent from a request’s partition.

  • IAM resources and assumed-role sessions retain their stored resource’s partition.
  • Strict mode uses vendored signing-name mappings to decide whether a partition offers a service.
  • Partition-specific credential-report keys leave still-fresh reports from earlier persistent deployments unreadable until regeneration.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Signed request] --> B[Resolve partition]
  B --> C{Strict mode and service absent?}
  C -->|Yes| D[UnknownOperationException]
  C -->|No| E[IAM or STS handler]
  E --> F[Global ARN in request or stored role partition]
  E --> G[Credential report keyed by account and partition]
Loading

Reviews (6) · Last reviewed commit: "fix(sts): mint a session from the stored..."

@pgermosen pgermosen added bug Something isn't working sts AWS Security Token Service (STS) iam AWS Identity and Access Management (IAM) floci-core labels Sep 30, 2026

@pgermosen pgermosen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title covers IAM ARNs too, but iamArn in IamService is unchanged, so CreateRole, CreateUser and CreateOpenIDConnectProvider still return arn:aws: in China scope. With the STS side now following the request, the two disagree. Web identity is where it actually breaks. A China trust policy naming the provider ARN that CreateOpenIDConnectProvider returned used to match, and now AssumeRoleWithWebIdentity compares it against arn:aws-cn: and denies it. AssumeRole has a milder version: pass it the ARN CreateRole returned and the session comes back as aws-cn while GetCallerIdentity says aws. The new China session test doesn't catch this because it writes the arn:aws-cn: role ARN by hand.

Minting iamArn through buildGlobalArn like the rest would line them up, and it's what the managed-policy attach check from #4742 needs too. The strict mode and the signing-name map look good, and you were right about bedrock-runtime.

@pgermosen pgermosen added the waiting-author Review posted; waiting on the PR author to respond label Sep 30, 2026
… partition mode

GetCallerIdentity's root fallback, the AssumeRole family's session ARNs, the
OIDC provider ARN and GetFederationToken built their ARNs with an empty
region, which falls back to the commercial partition, so they carried arn:aws:
whatever partition the request signed. They now go through
RegionResolver.buildGlobalArn. GetAccountSummary reports
GlobalEndpointTokenVersion only where the partition publishes a global STS
host, which is aws alone.

floci.partitions.strict (FLOCI_PARTITIONS_STRICT, default false) refuses a
request signed for a service AWS publishes in another partition but not in
the request's one (CloudFront in GovCloud, IAM in aws-eusc) with the
unknown-service guard's 404, mirroring the host that never resolves on AWS.
endpoints.json omits the services that ship only an endpoint ruleset, so a
service the data lists nowhere is served everywhere. Credential scopes carry
signing names, and 46 of them differ from the endpoints.json keys they cover
(73 keys, such as ecr for api.ecr); regen_partitions.py vendors that map as
signingNames and AwsPartition.offersSigningName joins it.

Part of #4272
…n collecting signing names

The botocore wheel ships each service model as service-2.json.gz, while the checkout under local/aws/botocore ships it plain. collect_signing_names looked only for the plain file, so in CI, which resolves botocore to the installed package, it found no models, generated an empty signingNames and failed aws-data-check against the committed map. It now reads either form, as regen_dynamodb_shapes.py already does.
…nswer strict-mode Query requests in XML

GetCallerIdentity rebuilt an assumed-role session's ARN with an empty region, which falls back to the commercial partition, so a session AssumeRole issued as arn:aws-cn:sts:: came back as arn:aws:sts::, and a chained AssumeRole was then refused by a China trust policy as a caller from another partition. The session ARN now takes the partition its role ARN names.

Strict partition mode refused a form-encoded Query request (IAM in aws-eusc) with a JSON body; it now returns the Query XML error the unknown-region guard beside it already returns for such requests.
…them there

CreateUser, CreateGroup, CreateRole, CreatePolicy, CreateInstanceProfile and
CreateOpenIDConnectProvider minted arn:aws: whatever partition the request
signed, while STS now followed the request. Under China that denied
AssumeRoleWithWebIdentity (the trust policy names the arn:aws: provider ARN
CreateOpenIDConnectProvider returned, matched against arn:aws-cn:), and
AssumeRole reported the request's partition while GetCallerIdentity reported
the role's.

An IAM resource is now created in the request's partition and keeps it:
UpdateUser and UpdateGroup re-mint in the stored ARN's partition. Anything
derived from a stored role follows the role: all three AssumeRole handlers,
resolveCallerArn and the web identity OIDC provider ARN take the role ARN's
partition through AwsArnUtils.partitionOrDefault. The credential report's
root row takes the request's partition.
@hectorvent
hectorvent force-pushed the fix/partition-sts-global branch from 13a410a to 0c54bb7 Compare September 30, 2026 22:58
@hectorvent

Copy link
Copy Markdown
Member Author

Thanks @pgermosen, you were right on both counts, and the web identity one was a regression this PR introduced. Fixed in 0c54bb7:

  • iamArn now mints in the request's partition, so CreateUser, CreateGroup, CreateRole, CreatePolicy, CreateInstanceProfile and CreateOpenIDConnectProvider return arn:aws-cn:iam:: under China. IamPartitionArnIntegrationTest checks all six in every partition.
  • A resource keeps the partition it was created in: UpdateUser and UpdateGroup re-mint in the stored ARN's partition, not the renaming request's.
  • Anything derived from a stored role follows the role. The session ARN in all three AssumeRole handlers now uses the role ARN's partition, the same rule resolveCallerArn already applied, so the two agree even when the call is signed for another partition. The OIDC provider ARN a web identity trust policy is matched against takes the role's partition too.
  • The China session test now uses the ARN CreateRole returned. The new web identity, cross-partition and rename tests all fail on the previous head.

partitions.md states the rule. I also rebased onto main to resolve the conflict with your #4716; its trust-condition block is kept as merged, only the root fallback now mints in the request's partition.

…l report per partition

AssumeRole, AssumeRoleWithWebIdentity and AssumeRoleWithSAML find the role by
account and name, but minted the session ARN from the RoleArn the request
named. A China role assumed with an arn:aws: RoleArn therefore came back as an
arn:aws:sts:: session, while AssumeRole registered the session under the
stored role's ARN, so GetCallerIdentity reported aws-cn. All three handlers
now mint the session from the stored role's ARN when the role exists and
register it under the same ARN.

The credential report was cached once per account, so a report generated for
one partition was handed to a caller in another for four hours, with the
wrong partition's root row. It is now kept per partition.
Comment on lines +3119 to +3120
private String credentialReportKey() {
return CREDENTIAL_REPORT_KEY + "/" + regionResolver.getPartition();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Persisted reports become unavailable

If IAM uses persistent, hybrid, or WAL storage, a report generated before an upgrade remains under the old credential-report key. This method now looks only under credential-report/<partition>, so GetCredentialReport returns ReportNotPresent even when the old report is still fresh. The caller must generate another report to read it.

Knowledge Base Used:

@pgermosen pgermosen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hectorvent iamArn going through buildGlobalArn lines the two sides up, and iamArnBeside is a case I had not thought of: a rename arriving on a commercial-scoped request should not drag a China user's ARN across, and now it cannot. IamPartitionArnIntegrationTest closes the hole I pointed at in the old China test too.

The bot's last point is correct but it is the mildest sort of migration gap, so I would leave it: a report under the old bare key becomes unreachable, and the recovery is the one thing your own error message already tells the caller to do. A four-hour transient regenerating on demand is a different thing from state that silently stops working.

@pgermosen pgermosen removed the waiting-author Review posted; waiting on the PR author to respond label Oct 1, 2026
@pgermosen
pgermosen merged commit 0bc85f3 into main Oct 1, 2026
25 checks passed
@pgermosen
pgermosen deleted the fix/partition-sts-global branch October 1, 2026 00:48
omatheusmesmo pushed a commit to omatheusmesmo/floci that referenced this pull request Oct 12, 2026
… partition mode (floci-io#4743)

* fix(sts): mint global STS and IAM ARNs per partition and add a strict partition mode

GetCallerIdentity's root fallback, the AssumeRole family's session ARNs, the
OIDC provider ARN and GetFederationToken built their ARNs with an empty
region, which falls back to the commercial partition, so they carried arn:aws:
whatever partition the request signed. They now go through
RegionResolver.buildGlobalArn. GetAccountSummary reports
GlobalEndpointTokenVersion only where the partition publishes a global STS
host, which is aws alone.

floci.partitions.strict (FLOCI_PARTITIONS_STRICT, default false) refuses a
request signed for a service AWS publishes in another partition but not in
the request's one (CloudFront in GovCloud, IAM in aws-eusc) with the
unknown-service guard's 404, mirroring the host that never resolves on AWS.
endpoints.json omits the services that ship only an endpoint ruleset, so a
service the data lists nowhere is served everywhere. Credential scopes carry
signing names, and 46 of them differ from the endpoints.json keys they cover
(73 keys, such as ecr for api.ecr); regen_partitions.py vendors that map as
signingNames and AwsPartition.offersSigningName joins it.

Part of floci-io#4272

* fix(core): read the gzipped botocore models the pip package ships when collecting signing names

The botocore wheel ships each service model as service-2.json.gz, while the checkout under local/aws/botocore ships it plain. collect_signing_names looked only for the plain file, so in CI, which resolves botocore to the installed package, it found no models, generated an empty signingNames and failed aws-data-check against the committed map. It now reads either form, as regen_dynamodb_shapes.py already does.

* fix(sts): keep an assumed-role session in its role's partition, and answer strict-mode Query requests in XML

GetCallerIdentity rebuilt an assumed-role session's ARN with an empty region, which falls back to the commercial partition, so a session AssumeRole issued as arn:aws-cn:sts:: came back as arn:aws:sts::, and a chained AssumeRole was then refused by a China trust policy as a caller from another partition. The session ARN now takes the partition its role ARN names.

Strict partition mode refused a form-encoded Query request (IAM in aws-eusc) with a JSON body; it now returns the Query XML error the unknown-region guard beside it already returns for such requests.

* fix(iam): mint IAM resource ARNs in the request's partition and keep them there

CreateUser, CreateGroup, CreateRole, CreatePolicy, CreateInstanceProfile and
CreateOpenIDConnectProvider minted arn:aws: whatever partition the request
signed, while STS now followed the request. Under China that denied
AssumeRoleWithWebIdentity (the trust policy names the arn:aws: provider ARN
CreateOpenIDConnectProvider returned, matched against arn:aws-cn:), and
AssumeRole reported the request's partition while GetCallerIdentity reported
the role's.

An IAM resource is now created in the request's partition and keeps it:
UpdateUser and UpdateGroup re-mint in the stored ARN's partition. Anything
derived from a stored role follows the role: all three AssumeRole handlers,
resolveCallerArn and the web identity OIDC provider ARN take the role ARN's
partition through AwsArnUtils.partitionOrDefault. The credential report's
root row takes the request's partition.

* fix(sts): mint a session from the stored role, and keep one credential report per partition

AssumeRole, AssumeRoleWithWebIdentity and AssumeRoleWithSAML find the role by
account and name, but minted the session ARN from the RoleArn the request
named. A China role assumed with an arn:aws: RoleArn therefore came back as an
arn:aws:sts:: session, while AssumeRole registered the session under the
stored role's ARN, so GetCallerIdentity reported aws-cn. All three handlers
now mint the session from the stored role's ARN when the role exists and
register it under the same ARN.

The credential report was cached once per account, so a report generated for
one partition was handed to a caller in another for four hours, with the
wrong partition's root row. It is now kept per partition.
Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
omatheusmesmo pushed a commit to omatheusmesmo/floci that referenced this pull request Oct 12, 2026
… partition mode (floci-io#4743)

* fix(sts): mint global STS and IAM ARNs per partition and add a strict partition mode

GetCallerIdentity's root fallback, the AssumeRole family's session ARNs, the
OIDC provider ARN and GetFederationToken built their ARNs with an empty
region, which falls back to the commercial partition, so they carried arn:aws:
whatever partition the request signed. They now go through
RegionResolver.buildGlobalArn. GetAccountSummary reports
GlobalEndpointTokenVersion only where the partition publishes a global STS
host, which is aws alone.

floci.partitions.strict (FLOCI_PARTITIONS_STRICT, default false) refuses a
request signed for a service AWS publishes in another partition but not in
the request's one (CloudFront in GovCloud, IAM in aws-eusc) with the
unknown-service guard's 404, mirroring the host that never resolves on AWS.
endpoints.json omits the services that ship only an endpoint ruleset, so a
service the data lists nowhere is served everywhere. Credential scopes carry
signing names, and 46 of them differ from the endpoints.json keys they cover
(73 keys, such as ecr for api.ecr); regen_partitions.py vendors that map as
signingNames and AwsPartition.offersSigningName joins it.

Part of floci-io#4272

* fix(core): read the gzipped botocore models the pip package ships when collecting signing names

The botocore wheel ships each service model as service-2.json.gz, while the checkout under local/aws/botocore ships it plain. collect_signing_names looked only for the plain file, so in CI, which resolves botocore to the installed package, it found no models, generated an empty signingNames and failed aws-data-check against the committed map. It now reads either form, as regen_dynamodb_shapes.py already does.

* fix(sts): keep an assumed-role session in its role's partition, and answer strict-mode Query requests in XML

GetCallerIdentity rebuilt an assumed-role session's ARN with an empty region, which falls back to the commercial partition, so a session AssumeRole issued as arn:aws-cn:sts:: came back as arn:aws:sts::, and a chained AssumeRole was then refused by a China trust policy as a caller from another partition. The session ARN now takes the partition its role ARN names.

Strict partition mode refused a form-encoded Query request (IAM in aws-eusc) with a JSON body; it now returns the Query XML error the unknown-region guard beside it already returns for such requests.

* fix(iam): mint IAM resource ARNs in the request's partition and keep them there

CreateUser, CreateGroup, CreateRole, CreatePolicy, CreateInstanceProfile and
CreateOpenIDConnectProvider minted arn:aws: whatever partition the request
signed, while STS now followed the request. Under China that denied
AssumeRoleWithWebIdentity (the trust policy names the arn:aws: provider ARN
CreateOpenIDConnectProvider returned, matched against arn:aws-cn:), and
AssumeRole reported the request's partition while GetCallerIdentity reported
the role's.

An IAM resource is now created in the request's partition and keeps it:
UpdateUser and UpdateGroup re-mint in the stored ARN's partition. Anything
derived from a stored role follows the role: all three AssumeRole handlers,
resolveCallerArn and the web identity OIDC provider ARN take the role ARN's
partition through AwsArnUtils.partitionOrDefault. The credential report's
root row takes the request's partition.

* fix(sts): mint a session from the stored role, and keep one credential report per partition

AssumeRole, AssumeRoleWithWebIdentity and AssumeRoleWithSAML find the role by
account and name, but minted the session ARN from the RoleArn the request
named. A China role assumed with an arn:aws: RoleArn therefore came back as an
arn:aws:sts:: session, while AssumeRole registered the session under the
stored role's ARN, so GetCallerIdentity reported aws-cn. All three handlers
now mint the session from the stored role's ARN when the role exists and
register it under the same ARN.

The credential report was cached once per account, so a report generated for
one partition was handed to a caller in another for four hours, with the
wrong partition's root row. It is now kept per partition.
Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working floci-core iam AWS Identity and Access Management (IAM) sts AWS Security Token Service (STS)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants