[CLF-C02 Practice Questions Q19] The Principle of Least Privilege (IAM Policies and SCPs)

CLF-C02 Practice Questions Q19 The Principle of Least Privilege (IAM Policies and SCPs) Certification

“If I record operations with CloudTrail, isn’t it safe to share the root user?”
“If I allow it in an Organizations SCP, won’t that team member be able to perform the operations?”

AWS Certified Cloud Practitioner (exam code CLF-C02, CLF below) often asks you to tell apart the mechanism that grants permissions (an IAM policy), the mechanism that sets an upper limit (an SCP), and the mechanisms that record activity (CloudTrail and AWS Config), and then choose the way of granting permissions that follows the principle of least privilege. Recording activity is not a substitute for narrowing permissions.

This article is Question 19 of a series that explains CLF practice questions one at a time. The author wrote the questions to match the scope of the exam; they are not actual exam questions. Choose your answer first, then read the explanation.


Question

At a company, a new member of the operations team only starts and stops Amazon EC2 instances. Under the AWS shared responsibility model, managing access permissions to AWS resources is the customer’s responsibility. Which of the following is the most appropriate way to grant permissions to this team member, following the principle of least privilege?

  • A. Share the credentials of the AWS account root user with the team member, and record the operations with AWS CloudTrail
  • B. Grant administrator permissions (AdministratorAccess) to the team member, and record configuration changes with AWS Config
  • C. Use an AWS Identity and Access Management (IAM) policy that allows only the operations to start and stop EC2 instances, and attach it to the team member
  • D. Use an AWS Organizations service control policy (SCP) to allow the team member to start and stop EC2 instances

Once you have chosen your answer, open the section below.

Show the answer (click to open)

Answer: C

Allowing only the needed operations in an IAM policy and granting it is the way that follows the principle of least privilege. The root user and administrator permissions are too broad, an SCP only sets an upper limit and does not grant permissions, and recording with CloudTrail or Config is not a substitute for narrowing permissions.


The answer is C

The correct answer is C.

  • Allow only the needed operations in an IAM policy, and grant it to the team member
  • This is the way of granting permissions that follows the principle of least privilege

The other three are either too broad or cannot grant permissions at all. Let’s look at the options one at a time.


Explanation of each option

A: Do not share the root user (incorrect)

On the upper left, the root user (everything in the account) points to the new team member on the right with an arrow labeled "Share credentials" (the team member also acts as the root user). Under "What the new team member can do," all eight actions are allowed: Start EC2 instances, Stop EC2 instances, Terminate EC2 instances (delete), Delete S3 data, Create IAM users, View billing info, Delete RDS databases, and Change security groups. Only the two in green, start and stop, are needed. On the right, "Sharing the root user credentials" is marked "Not least privilege": the root user is a special user that can do everything in the account, and you should not share it or use it for daily work. Even if CloudTrail logs it, you only find out later, and the permissions stay too big

The root user is a special user that can do everything in an AWS account. As the diagram shows, if you share its credentials, the team member can perform every operation. Only the two in the green frame, start and stop, are needed.

The principle is to not share the root user’s credentials and not use them for daily work. Even if you record operations with CloudTrail, you only find out afterward, and the permissions are still too broad.

B: Administrator permissions are too broad (incorrect)

On the upper left, AdministratorAccess (admin permissions) points to the new team member on the right with an arrow labeled "Grant." Under "What the new team member can do," all eight actions are allowed: Start EC2 instances, Stop EC2 instances, Terminate EC2 instances (delete), Delete S3 data, Create IAM users, View billing info, Delete RDS databases, and Change security groups. Only the two in green, start and stop, are needed. On the right, "Granting AdministratorAccess" is marked "Not least privilege": administrator permissions allow every action, and only start and stop are needed. Config records and evaluates configuration changes. It does not prevent them

AdministratorAccess is administrator permissions that allow every action. For a team member who only starts and stops instances, it is too broad and violates the principle of least privilege.

AWS Config is a service that records and evaluates changes to the configuration of resources. A record only tells you afterward; it cannot prevent unnecessary operations.

C: Allow only the needed operations in IAM (correct)

On the upper left, IAM hands a policy "Policy: Allow" with ec2:StartInstances and ec2:StopInstances to the new team member on the right, with an arrow labeled "Grant." Of what the new team member can do, Start EC2 instances and Stop EC2 instances are allowed (green). Terminate EC2 instances (delete), Delete S3 data, Create IAM users, View billing info, Delete RDS databases, and Change security groups are denied (gray). Only what is allowed is possible, and everything else is denied. On the right, "Allow only the needed actions in an IAM policy" is marked "Least privilege": if nothing is allowed, everything is denied, and only the actions the policy allows are possible. An Identity Center permission set is also an IAM policy inside

You use an IAM policy that allows only the operations to start and stop EC2 instances, and attach it to the team member. In IAM, if nothing is allowed, every operation is denied. Only the operations the policy allows are possible.

In the diagram, only start and stop are allowed, and the other operations are denied. This is least privilege.

Note that for human users, signing in through IAM Identity Center is the recommended approach. The permission sets you assign there are also IAM policies inside.

D: An SCP sets a limit and does not grant (incorrect)

On the left, a red frame titled "If only the SCP allows it." The SCP limit in a dashed frame is start and stop EC2, but because nothing is allowed in an IAM policy, the team member can do nothing. SCPs apply to organizations, OUs, and accounts. On the right, an overlap diagram titled "Usable permissions = only the overlap of the two." The orange SCP sets the limit (guardrail) and does not grant permissions. The blue IAM policy grants permissions. The overlap of the two is the usable permissions

An SCP in AWS Organizations does not grant permissions. It sets the upper limit of the permissions that can be used in an organization, an OU, or an account, and is also called a guardrail.

As the right of the diagram shows, what you can actually use is only the overlap of the SCP’s limit and what the IAM policy allows. Even if the SCP allows start and stop, the team member can do nothing unless an IAM policy allows it (the left of the diagram).


Granting, setting a limit, and recording

Here is a summary of the three mechanisms related to permissions, by role.

RoleMechanismDescription
GrantIAM policy (including an Identity Center permission set)Allow only the needed operations (= least privilege)
Set a limitSCP (AWS Organizations)The upper limit for an organization, OU, or account. An SCP alone cannot do anything
RecordCloudTrail, AWS ConfigYou only find out afterward. Not a substitute for narrowing permissions

Key points

  • Least privilege = allow only the needed operations in an IAM policy and grant it
  • An SCP is an upper limit (guardrail). It does not grant permissions
  • Records in CloudTrail and Config are not a substitute for narrowing permissions
  • Do not share the root user, and do not use it for daily work

The course articles explain the principle of least privilege and IAM policies, and the relationship between SCPs and IAM, in detail.

  • Lecture 10, Part 5: IAM and least privilege
  • Lecture 9, Part 6: Organizations and SCPs

You can read all 14 lectures of AWS Cloud Practitioner Exam Prep in order from its series page.


The CLF-C02 Practice Questions series (100 questions)

All 100 questions with a reading guide: CLF-C02 Practice Questions

In this group (Questions 19–30: The shared responsibility model and security):

This series is the English edition of 【CLF-C02 試験対策問題】, originally written in Japanese.

コメント

Copied title and URL