In other words, even if a member account has an SCP that explicitly denies an action by all principals on all resources, it may still be possible for a principal to perform the action indirectly via a second action that then performs the first action on the principal’s behalf via a service-linked role, provided the principal has sufficient permissions to perform the second action.
The same is true when the SCP doesn’t blanket deny the action but rather restricts its usage to certain conditions. The conditions don’t apply if the action is indirectly performed via a service-linked role.
I’m still scratching the surface of the practical implications but my gut feeling is this:
- In a prod account that exercises least-privilege with granular permissions on all principals, there are probably little-to-no implications because the usage of all services & roles are probably sufficiently restrictive to prevent circumventing SCPs via a service-linked role. I hate to say “probably” when the consequences of a mistake are unlimited financial liability but it’d require a thorough review of all services & actions to be certain.
- In a dev/sandbox account that gives principals broad permissions (e.g., Administrator Access) and relies on SCPs to provide a few high-value guardrails without overly restricting users, then there are probably some practical avenues for circumventing some SCPs.
For example, let’s say an Org gives their users admin access to a sandbox account with an SCP that only allows `ec2:RunInstances` to be performed if the type is t3.micro and the subnet has a “private” tag.
The SCP would correctly prevent a principal from launching an m5.large instance into a public subnet directly via the EC2 service. But the SCP wouldn’t prevent the same principal from (for example) creating an environment in the Cloud9 service which uses a service-linked role to perform `ec2:RunInstances` on the principal’s behalf, with the type and subnet of their choosing, unrestricted by SCPs targeting `ec2:RunInstances`.
In this example, you can’t fully customize the EC2 instance’s settings since you’re limited to what’s allowed via the Cloud9 service. But you can select the instance’s type and subnet, and then log into it afterward with root access like any other EC2 instance, thus thwarting the SCP.
The mitigation in this example is relatively simple: You can update SCPs to deny principals access to Cloud9 or at least restrict `cloud9:CreateEnvironmentEC2` with conditions related to subnet and instance type.
But `ec2:RunInstances` is just one action and Cloud9 is just one service. To fully understand the implications of SCPs not applying to service-linked roles, you’d have to determine whether any service that any principal has access to provides any avenue for using a service-linked role to circumvent any SCP.
Perhaps that’s a reasonable undertaking for a prod account? I dunno. It’s certainly a tall order for a dev/sandbox account.
Either way, I suspect the intent of most SCPs is to apply restrictions to all principals in an account (as opposed to all principals except service-linked roles) so I’m disappointed that it works this way.