Permission Boundaries and Session Policies
Permission boundaries and session policies are advanced IAM controls that limit, rather than grant, permissions. Both matter for the SCS-C03 exam because they enforce least privilege and enable safe delegation. Permission Boundaries: A permission boundary is a managed policy attached to an IAM user or role (not a group) that sets the maximum permissions that identity can ever have. Effective permissions are the intersection of the identity-based policies and the boundary. For example, if the boundary allows only Amazon S3 and DynamoDB, attaching AdministratorAccess still yields only S3 and DynamoDB access. A boundary never grants permissions on its own. A key use case is delegated administration. Developers can be allowed to call iam:CreateRole only when the iam:PermissionsBoundary condition key requires a specific boundary to be attached, which prevents privilege escalation. You should also deny actions that would modify or remove the boundary policy itself. Remember that a resource-based policy in the same account that names an IAM user or role session ARN as the principal can grant access beyond the boundary. Session Policies: Session policies are inline or managed policies passed as parameters when programmatically creating a temporary session through AssumeRole, AssumeRoleWithSAML, AssumeRoleWithWebIdentity, or GetFederationToken. The resulting session permissions are the intersection of the identity-based policies of the role or user and the session policy. You can pass up to 10 managed policy ARNs plus one inline policy, subject to a packed size limit. Common use cases include letting one shared role issue scoped-down credentials per user or per task, such as a broker application that restricts each session to a specific S3 prefix. Evaluation Logic: An explicit deny in any policy always wins. Effective access within an account is roughly the intersection of identity-based policies, permission boundaries, session policies, SCPs, and RCPs, with resource-based policies adding nuance. Exam Tip: If a scenario asks how to safely let others create roles, choose permission boundaries. If it asks how to restrict temporary credentials for a single session, choose session policies.
Permission Boundaries and Session Policies: A Complete Guide for the AWS Certified Security - Specialty Exam
Permission boundaries and session policies are two of the most misunderstood features of AWS Identity and Access Management (IAM). They are tested often on the AWS Certified Security - Specialty exam. Neither feature ever grants permissions. Both are guardrails that limit the maximum permissions an identity or a session can have. If you understand this one idea, you can answer most exam questions on the topic.
Why Permission Boundaries and Session Policies Are Important
1. Safe delegation of IAM administration: Organizations want developers to create their own IAM roles for Lambda functions, EC2 instances and pipelines. They do not want those developers to create a role more powerful than themselves. Permission boundaries close this privilege escalation path.
2. Least privilege at scale: Central security teams cannot review every role a developer creates. Boundaries let them set a ceiling once and enforce it everywhere.
3. Scoped-down temporary access: Session policies let an application or user assume a broad role but receive only the subset of permissions needed for a single task. Examples include a multi-tenant SaaS application that limits each session to one tenant's S3 prefix, or a federated user who needs read-only access for one session.
4. Defense in depth: These features work together with Service Control Policies (SCPs), Resource Control Policies (RCPs), resource-based policies and identity-based policies. They add layers of control to the policy evaluation logic.
5. Compliance and auditability: Boundaries give auditors a clear, documented maximum permission set for delegated identities.
What Is a Permission Boundary?
A permission boundary is an advanced IAM feature where you use a managed policy (AWS managed or customer managed) to set the maximum permissions that an identity-based policy can grant to an IAM user or IAM role.
- It can be set only on IAM users and IAM roles. It cannot be set on IAM groups.
- Each user or role can have only one permission boundary.
- The boundary must be a managed policy. Inline policies cannot serve as boundaries.
- The effective permissions are the intersection of the identity-based policies and the permission boundary.
Example: A boundary allows s3:*, cloudwatch:* and ec2:Describe*. The identity policy attached to the role allows s3:GetObject and iam:CreateUser. The effective permission is only s3:GetObject. The boundary does not include iam:CreateUser, so that action is denied. The boundary does not grant cloudwatch:* either, because no identity policy allows it.
What Is a Session Policy?
A session policy is a policy that you pass as a parameter when you create a temporary session for a role or a federated user. It limits the permissions of that session only.
Session policies are passed with these AWS STS API calls:
- AssumeRole
- AssumeRoleWithSAML
- AssumeRoleWithWebIdentity
- GetFederationToken (federated user sessions)
You can pass session policies in two forms:
- An inline session policy using the Policy parameter. One JSON policy document is allowed, with a plaintext size limit of 2,048 characters.
- Up to 10 managed policy ARNs using the PolicyArns parameter.
The total packed size of session policies and session tags is also limited. The PackedPolicySize value in the response shows how close you are to that limit.
The effective permissions of the session are the intersection of the role's identity-based policies (or the IAM user's policies for GetFederationToken) and the session policy. A session policy can never give the session more than the role already allows.
How It Works: Policy Evaluation Logic
To decide whether a request is allowed within a single account, AWS evaluates policies in this order:
1. Explicit Deny in any policy wins. This includes SCPs, RCPs, resource-based policies, identity policies, boundaries and session policies.
2. Organizations SCPs/RCPs must allow the action if the account is in an organization.
3. Resource-based policies may grant access (see the nuances below).
4. Identity-based policies must allow the action.
5. Permission boundaries must allow the action if one is set.
6. Session policies must allow the action if one was passed.
If any required layer lacks an Allow, the result is an implicit deny.
Effective permission formula (same account, identity-based access):
Effective = Identity policy ∩ Permission boundary ∩ Session policy ∩ SCP
Resource-based policy nuances (high-value exam detail):
- Permission boundary with an IAM user: If a resource-based policy in the same account names the IAM user ARN as principal, the boundary does not limit that access. The resource policy Allow is enough.
- Permission boundary with an IAM role: If a resource-based policy names the role ARN, the boundary does limit the access. The same applies to the session principal for roles.
- Session policy: If a resource-based policy names the session ARN (assumed-role session or federated user ARN), the session policy does not limit that access. If the resource-based policy names the role ARN, the session policy does limit the access.
- An explicit Deny in a boundary or session policy always applies, no matter what any resource policy says.
Cross-account access: Both the trusting account (resource policy or role trust policy) and the trusted account (identity policy, boundary, session policy, SCPs) must allow the request.
Delegated Administration Pattern with Permission Boundaries
This is the classic exam scenario. A central admin wants developers to create roles for their applications while preventing privilege escalation.
Step 1: Create a boundary managed policy, for example DevBoundary, that allows only approved services.
Step 2: Give developers an identity policy that allows iam:CreateRole, iam:PutRolePolicy, iam:AttachRolePolicy and related actions only if the condition key iam:PermissionsBoundary equals the ARN of DevBoundary.
Step 3: Deny iam:DeleteRolePermissionsBoundary and iam:PutRolePermissionsBoundary (except with the approved ARN), and deny edits to the boundary policy itself (iam:CreatePolicyVersion, iam:DeletePolicy, iam:SetDefaultPolicyVersion on the boundary ARN).
Step 4: Optionally put the developers themselves under the same boundary, and restrict iam:PassRole to roles with an approved path or naming prefix.
Result: every role a developer creates is capped by DevBoundary. Developers cannot remove or change the cap.
Common Session Policy Use Cases
- Multi-tenant isolation: An application assumes one shared role and passes a session policy that limits S3 access to arn:aws:s3:::bucket/tenant-123/*. This avoids creating one role per tenant.
- Scoped federation: A broker application calls GetFederationToken or AssumeRole with a narrow policy for each end user.
- Temporary least privilege: A CI/CD job assumes a deployment role but restricts the session to a single stack or Region.
- Session tags (ABAC) alternative: Session tags combined with aws:PrincipalTag conditions are another way to scope sessions. Exam questions may compare the two approaches.
Comparison Table (Summarized)
Permission boundary: Applies to IAM users and roles. Persistent setting. Managed policy only. One per identity. Set by an administrator. Controlled with the iam:PermissionsBoundary condition key.
Session policy: Applies to a single temporary STS session. Exists only for the session lifetime. Inline JSON and/or up to 10 managed policy ARNs. Passed by the caller at session creation.
SCP: Applies to member accounts in AWS Organizations, including the root user of member accounts. Does not apply to the management account. Never grants permissions.
All three: Never grant permissions. They only filter or limit.
Exam Tips: Answering Questions on Permission Boundaries and Session Policies
Tip 1 - Think intersection, not union: When a question asks for 'effective permissions', find the actions that appear in every applicable layer. An action allowed in the boundary but not in the identity policy is not allowed.
Tip 2 - Boundaries and session policies never grant: Any answer claiming that adding a boundary or session policy will 'give' a user new access is wrong.
Tip 3 - Spot the delegation keywords: Phrases such as 'allow developers to create IAM roles', 'prevent privilege escalation' or 'ensure created roles cannot exceed' point to permission boundaries with the iam:PermissionsBoundary condition key.
Tip 4 - Spot the session keywords: Phrases such as 'one role shared by many tenants', 'restrict each session', 'per-request scoping' or 'pass a policy when assuming the role' point to session policies.
Tip 5 - Groups are a trap: Boundaries cannot be attached to IAM groups. An option that sets a boundary on a group is incorrect.
Tip 6 - Inline vs. managed: Boundaries must be managed policies. Session policies may be inline (Policy parameter) or managed ARNs (PolicyArns, max 10).
Tip 7 - Protect the boundary: A complete solution also denies removing or modifying the boundary. If an answer lacks this protection, a developer could escalate privileges. Look for the more complete option.
Tip 8 - Remember the resource-policy exceptions: A resource policy naming an IAM user bypasses that user's boundary. A resource policy naming a session ARN bypasses the session policy. Explicit Deny statements still always win.
Tip 9 - Explicit deny wins everywhere: If any layer contains a matching Deny, the request fails. This is often the fastest way to eliminate options.
Tip 10 - SCPs vs. boundaries: Choose SCPs when the requirement covers whole accounts or OUs (including the member account root user). Choose boundaries when the requirement targets specific users or roles within an account.
Tip 11 - Troubleshooting questions: If a user has an AdministratorAccess identity policy but still gets AccessDenied, check for a boundary, a session policy, an SCP or an explicit Deny. Use the IAM Policy Simulator and the CloudTrail error details to find the limiting layer.
Tip 12 - GetFederationToken specifics: Federated user sessions from GetFederationToken get the intersection of the calling IAM user's policies and the session policy. If no session policy is passed, the session has no permissions except access granted by resource-based policies naming the federated user.
Tip 13 - Choose the least operational overhead: For multi-tenant apps, one role plus dynamic session policies (or session tags) is usually better than creating hundreds of roles.
Tip 14 - Read every word: Words such as 'maximum', 'cannot exceed', 'ceiling' and 'scope down' are strong hints that the answer involves a boundary or session policy rather than an identity policy.
Quick Practice Scenario
A company wants its developers to create IAM roles for Lambda functions. Security requires that no created role can access IAM or AWS Organizations. What should the security team do?
Answer: Create a customer managed policy that excludes IAM and Organizations actions to act as a boundary. Grant developers iam:CreateRole and policy-attachment permissions with a condition requiring iam:PermissionsBoundary to equal that policy ARN. Deny actions that delete or change the boundary or edit the boundary policy.
Summary
Permission boundaries cap the maximum permissions of IAM users and roles and enable safe delegated administration. Session policies cap the permissions of individual temporary sessions and enable fine-grained, per-session least privilege. Both act as filters, both use intersection logic, and neither ever grants access. Master the evaluation logic, the delegation pattern, and the resource-policy exceptions, and you will be ready for this area of the AWS Certified Security - Specialty exam.