As your AWS usage grows, splitting workloads across several accounts becomes the simplest way to isolate them. AWS Organizations manages that set of accounts, and Service Control Policies (SCPs) set the permission ceiling for each account in the structure. Note that an SCP grants access to nothing. It only blocks, and those blocks work as guardrails: limits that no identity in the account can cross, no matter how many IAM permissions it has.
In security governance with Organizations and SCPs, the work starts with the OU structure, because policies are applied through it. Next come guardrails written with Deny and conditions, used to restrict Regions and protect critical services, and RCPs, which close off access to resources from the outside. One precaution applies to all of this: never apply a poorly planned SCP, because it can break your entire operation.
Accounts, OUs and strategy
Organize accounts into organizational units (OUs) that reflect environments and functions, such as production, staging, security, logging and sandbox. Since SCPs apply per OU, a good split lets you use different guardrails in different contexts. Production can have stricter rules, while the sandbox, where the team tries things out, can tolerate more freedom.
Set aside dedicated accounts for security functions, such as a centralized log account and an audit account. That way, a compromised production account does not reach the logs or the audit trail, which live in a different account.
Inheritance and the management account
SCPs are inherited down the hierarchy. An account is limited by the intersection of the policies attached to the root, to the OUs above it and to the account itself, and an action only goes through if no SCP along the path blocks it. The important exception is the management account: SCPs do not apply to it, so do not count on guardrails to contain that account. Treat it as a very high-privilege account, use it as little as possible and keep workloads in member accounts.
Anatomy of a Deny guardrail
The most predictable approach is to start from the policy that allows everything and add Deny SCPs to block what must never happen. A Deny with a condition is safer than building Allow lists, because any service someone forgets to include on the list gets blocked without warning. One of the guardrails with the best return is restricting the allowed Regions. It keeps resources from appearing in Regions you neither use nor monitor, which are exactly the Regions where attackers tend to operate.
{ "Effect": "Deny", "NotAction": [ "iam:*", "sts:*", "cloudfront:*", "route53:*", "support:*", "organizations:*" ], "Resource": "*", "Condition": { "StringNotEquals": { "aws:RequestedRegion": ["sa-east-1", "us-east-1"] } }}The NotAction element leaves out global services such as IAM, STS, CloudFront and Route 53. They operate from a control Region and would stop working if they fell under the Region restriction. Adjust this exception list to the services you actually use, and test before applying it in production.
{ "Effect": "Deny", "Action": [ "cloudtrail:StopLogging", "cloudtrail:DeleteTrail", "guardduty:DeleteDetector", "config:DeleteConfigurationRecorder" ], "Resource": "*"}Remember that the SCP only sets the ceiling. For anyone to do anything in the account, an IAM policy still has to grant the permission, within what the SCP lets through. In other words, the SCP blocks and IAM grants, and neither one replaces the other.
Common guardrails and RCPs
Besides the Region restriction and protection for security services, a few guardrails show up in almost every mature structure. Apply them per OU according to the environment, with production stricter than the sandbox.
- Prevent CloudTrail, GuardDuty and Config from being turned off
- Protect audit roles and resources against changes
- Restrict usage to the allowed Regions
- Block log deletion and changes to the audit bucket
- Prevent an account from leaving the organization or changing the structure
- Use different guardrails in each OU, depending on the environment
SCPs limit what principals in the account can do. Resource Control Policies (RCPs) look at it from the other side and limit who can access the resources in your accounts, such as S3 buckets and queues, even when the request comes from outside. An RCP can require, for example, that only principals in your organization access certain resources, which shuts the door on external identities. So SCPs and RCPs complement each other: the SCP handles identities on the inside, and the RCP protects resources against access from outside.
Risks of a poorly planned SCP
The biggest risk of SCPs is their reach. A badly written policy can block legitimate actions in dozens of accounts at once. Test changes in a test OU first, do not deny actions without understanding what depends on them, and take extra care with the management account, which SCPs do not limit. Document each guardrail and the reason it exists.
Also pay attention to global services and to services that create resources on your behalf. A poorly tuned Region restriction can break certificate issuance, content delivery or DNS resolution, because those services operate from a control Region. That is why a NotAction with the right exceptions, and testing before you apply, belong in the policy design from the start.
Practical checklist
- Group accounts into OUs by environment and function
- Have dedicated accounts for logging and auditing
- Write guardrails with Deny and conditions instead of Allow lists
- Use an SCP to block turning off security services
- Prevent changes to and deletion of audit resources
- Restrict the allowed Regions without forgetting global services in the NotAction
- Evaluate RCPs to close off external access to resources
- Tailor the guardrails to the environment of each OU
- Test SCPs in a test OU before production
- Document each guardrail and why it exists
- Review SCPs whenever a new service comes into use
- Use the management account carefully, since SCPs do not limit it
Best practices
- Use SCPs as broad guardrails and leave fine-grained access control to IAM
- Prefer Deny with conditions over Allow lists, which break easily
- Design OUs around the policies each context will receive
- Keep security functions in separate accounts
- Restrict Regions so there is no activity where nobody is watching
- Test every SCP change before taking it to production
- Record the intent of each guardrail alongside it
Common mistakes
- Broad SCP deny without mapping dependencies
- Legitimate actions stop in many accounts at the same time.
- Region restriction with no exception for global services
- IAM, CloudFront, Route 53 and certificate issuance break, and the cause takes a while to surface.
- Logs and audit in the same production account
- Whoever compromises production also reaches the audit trail.
- Counting on SCPs to contain the management account
- SCPs do not apply to that account, so the guardrail you expected does not exist.
- Treating an SCP as an access grant
- Without an IAM policy granting the permission, the account still has no access, however much the SCP allows.
- Applying an SCP straight to production without testing
- A wrong policy can stop critical operations in several accounts at once.
Authorship and review
Cesar Gargiulo
CEO and founder of GUARDIASEC. Technical and editorial lead for the content published in this library.
Published on . Found a technical error? Write to [email protected] and we will correct it and keep a record of the change.