mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(redshift): reject foreign-account or foreign-region ARNs in tagging (#6026)
* fix(redshift): reject foreign-account or foreign-region ARNs in tagging resolveTagHandle checked only that the ARN's service was redshift, then looked the resource up by id. CreateTags, DeleteTags, DescribeTags and the tag listing therefore acted on the caller's local resource of the same name when given another account's or another region's ARN, for every resource type in the switch: cluster, snapshot, parametergroup, subnetgroup, snapshotcopygrant and snapshotschedule. The ARN's account and region are now compared with the caller's (RegionResolver.getAccountId / getRegion, the same values the service uses to mint these ARNs) before the lookup. Error choice: ResourceNotFoundFault (404). It is the not-found fault the Redshift model lists for all three tag operations (CreateTags, DeleteTags, DescribeTags), and the snapshotcopygrant branch already uses it for a missing resource. The per-type faults (ClusterNotFound etc.) are not modelled on these operations. What real AWS returns for a foreign-account or foreign-region ARN was not confirmed against the live service. * fix(redshift): reject foreign-partition ARNs in tagging resolveTagHandle compared an ARN's account and region with the caller's but not its partition, so arn:aws-cn:redshift:<local-region>:<local-account>:... still resolved to the local resource. Reject it with ResourceNotFoundFault like the other foreign-scope ARNs. * refactor(redshift): use AwsArnUtils.isForeignAccount for the tag ARN account check Pairs it with isForeignPartition the way LambdaLayerService does, per review.
This commit is contained in:
1 parent
7fb649715c
commit
eb968b0b69
2 files changed
+66
No files matched your search
@@ -1708,6 +1708,16 @@ public class RedshiftService {
|
||||
if (!"redshift".equals(arn.service())) {
|
||||
throw new AwsException("InvalidParameterValue", "Invalid resource name: " + resourceName, 400);
|
||||
}
|
||||
// Resources here are stored per caller account and their ARNs minted in the caller's
|
||||
// partition and region, so an ARN naming another partition, account or region cannot be
|
||||
// a local resource. ResourceNotFoundFault (404) is the not-found fault
|
||||
// CreateTags/DeleteTags/DescribeTags all model; resolving by id alone would tag the
|
||||
// local resource of the same name.
|
||||
if (AwsArnUtils.isForeignPartition(arn, regionResolver.getPartition())
|
||||
|| AwsArnUtils.isForeignAccount(arn, regionResolver.getAccountId())
|
||||
|| !regionResolver.getRegion().equals(arn.region())) {
|
||||
throw new AwsException("ResourceNotFoundFault", "Resource " + resourceName + " not found", 404);
|
||||
}
|
||||
String resource = arn.resource();
|
||||
int sep = resource.indexOf(':');
|
||||
if (sep < 0) {
|
||||
|
||||
Reference in new issue
Block a user