mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
Under IAM enforcement a request that passes a role to a service needs iam:PassRole on that role, but no Redshift or Redshift Serverless operation was checked for it. A caller allowed to create a cluster or change its roles could attach any role to it, and Floci's COPY, UNLOAD and Spectrum statements then run as that role; statements run through the Data API on a Redshift Serverless workgroup can use its namespace's roles the same way. Now checked, with iam:PassedToService as the Service Authorization Reference gives it: - Redshift CreateCluster and RestoreFromClusterSnapshot pass the roles in IamRoles, and ModifyClusterIamRoles those in AddIamRoles, to redshift.amazonaws.com. The lists are read through the Redshift handler's own member pattern, so IamRoles.IamRoleArn.N, as the SDK sends it, IamRoles.member.N and IamRoles.N all count. RestoreFromClusterSnapshot is checked although Floci's restore attaches no role yet, as AWS checks it. - Redshift Serverless CreateNamespace and UpdateNamespace pass the roles in iamRoles and the one in defaultIamRoleArn, and CreateScheduledAction and UpdateScheduledAction pass roleArn, to redshift-serverless.amazonaws.com. The Redshift management guide: "To associate an IAM role with a cluster, a user must have iam:PassRole permission for that IAM role." A role named only as a cluster's default, DefaultIamRoleArn, is not checked on its own: the default is one of the roles the cluster holds, and Floci does not act on it. A namespace's defaultIamRoleArn is checked, since Floci keeps it whether or not iamRoles holds it. COPY, UNLOAD and Spectrum now take a role only under the ARN IAM holds it under, path included, as STS AssumeRole does. They looked the role up by its name alone, so a cluster given role/sandbox/AdminRole, which a PassRole grant on role/sandbox/* allows, ran its statements as the AdminRole IAM holds under another path. IAM's AddRoleToInstanceProfile now passes the role it adds to ec2.amazonaws.com. Every instance running with the profile gets that role's credentials from the instance metadata service, so adding a role to a profile already attached to a running instance handed it any role. The IAM API reference: "The caller of this operation must be granted the PassRole permission on the IAM role by a permissions policy." RoleName names the role without its path, so the check uses the ARN IAM holds the role under, or, for a role IAM does not hold, the ARN the name gives. docs/services/iam.md lists the new operations, and docs/services/redshift.md the path rule.