Repository navigation
fix(sts): mint global STS and IAM ARNs per partition and add a strict partition mode - #4743
Conversation
|
pgermosen
left a comment
There was a problem hiding this comment.
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.
… 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.
13a410a to
0c54bb7
Compare
|
Thanks @pgermosen, you were right on both counts, and the web identity one was a regression this PR introduced. Fixed in 0c54bb7:
|
…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.
| private String credentialReportKey() { | ||
| return CREDENTIAL_REPORT_KEY + "/" + regionResolver.getPartition(); |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
@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.
… 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>
… 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>
Summary
Part of #4272 (P9).
Global STS and IAM ARNs per partition.
GetCallerIdentity's root fallback, theAssumeRolefamily's session ARNs (assumed-role/...), the OIDC provider ARN andGetFederationToken(federated-user/...) built their ARNs with an empty region, which falls back to the commercial partition, so they carriedarn:aws:whatever partition the request signed. They now go throughRegionResolver.buildGlobalArn. IAM'sGetAccountSummaryreportsGlobalEndpointTokenVersiononly where the partition publishes a global STS host (sts.amazonaws.com), which isawsalone.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 (theGetCallerIdentityroot fallback,federated-user) follow the request.Strict partition mode, opt-in.
floci.partitions.strict(FLOCI_PARTITIONS_STRICT, defaultfalse) refuses a request signed for a service AWS publishes in another partition but not in the request's one (CloudFront in GovCloud, IAM inaws-eusc) with the unknown-service guard's 404UnknownOperationException. 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.jsonomits 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 theendpoints.jsonkeys they cover (73 keys, such asecrforapi.ecrandbedrockforbedrock-runtime);tools/aws/regen_partitions.pynow vendors that map from botocore'sservice-2.jsonmetadata assigningNames, andAwsPartition.offersSigningNamejoins it. Off by default, nothing changes.Config is wired through
EmulatorConfig, bothapplication.ymlfiles,docs/configuration/environment-variables.md,docs/configuration/advanced/application-yml.mdanddocs/configuration/partitions.md.Independent of #4742 (P8): the two share
IamService,IamServiceTestandpartitions.mdbut touch different hunks, so whichever merges second may need a small rebase.Type of change
fix:)feat:)feat!:orfix!:)AWS Compatibility
Incorrect behaviour: outside the commercial partition,
GetCallerIdentity(root fallback),AssumeRole,AssumeRoleWithWebIdentity,AssumeRoleWithSAMLandGetFederationTokenreturnedarn:aws:ARNs, as didCreateUser,CreateGroup,CreateRole,CreatePolicy,CreateInstanceProfile,CreateOpenIDConnectProviderand the credential report's root row, andGetAccountSummaryreported aGlobalEndpointTokenVersionfor partitions with no global STS endpoint. The strict mode is new and opt-in.Checklist
./mvnw testpasses 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, includingStsQueryHandlerTest,AccountContextFilterTest,PartitionStrictModeIntegrationTest,IamIntegrationTest, the EKS IRSA and IAM enforcement suites).TlsIntegrationTestcould not start locally because Docker already held port 4566; it does not touch this change and runs in CI.make aws-data-checkandmake aws-data-test(69) pass; the full suite runs in CI's four shardsIamPartitionArnIntegrationTest,PartitionStrictModeIntegrationTest,PartitionRegionGatesIntegrationTest,StsSessionIdentityIntegrationTest,AccountContextFilterTest,StsQueryHandlerTest,IamServiceTest,AwsPartitionsTest,test_regen_partitions.py)