Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Identity and Threat Modeling  ›  Lesson

Least Privilege and Role-Based Access

Least Privilege 12 minEvery person, service and pipeline job should hold only the permissions its task needs, granted through roles rather than one by one, and for no longer than needed.

Least Privilege and Role-Based Access

Tiffin's pipeline runs every job as one cloud identity with full admin rights, because that was the quickest way to make deploys work. One day a compromised test dependency runs code inside the test job. With admin rights, that code could delete the production database. With the right permissions, it could have done almost nothing.

The rule

Grant only what the task needs, only to whoever does it, only for as long as needed.

Identity and access management (IAM) is the system that decides who (or what) can do which actions on which resources. Least privilege is the rule for filling it in: start from nothing and add only the permissions a task actually requires.

The point is blast radius. You will never prevent every compromise, so make sure a stolen credential opens as few doors as possible.

Role-based access control (RBAC) makes this manageable. You define roles around jobs, give permissions to the roles, and assign people or services to roles:

roles:
  tiffin-build:           # used by the build job
    allow: [registry:push on tiffin/*]
  tiffin-deploy-staging:  # used by the staging deploy job
    allow: [service:update on staging/tiffin]
  developer:
    allow: [read on staging/*, logs:read on prod/tiffin]

Now a new teammate gets the developer role in one step, and removing it removes everything at once.

Least privilege applies to three kinds of identity:

  • People: no standing production admin. Use a time-limited, approved and logged elevation for emergencies.
  • Services: the Tiffin app's database user can read and write its own tables, not drop them.
  • Pipeline jobs: one role per job, scoped to one environment. The job that runs untrusted pull-request code gets no secrets at all.

Permissions drift upward over time. Compare what each role is granted with what the logs show it uses, and remove the difference.

The shortcut

For any identity, write its job in one sentence, then grant only the verbs and resources in that sentence.

Right-sizing Tiffin's build jobStep 1 of 4
  1. The job in one sentence

    "The build job builds the image and pushes it to the Tiffin repository."

Drills

Answer fast — trust the rule.

quick drill

What is the main goal of least privilege?

quick drill

What does role-based access control add?

quick drill

A developer needs production access to fix an outage at 2 a.m. What fits least privilege best?

quick drill

Which permission set fits Tiffin's deploy-staging job?

Remember

  • Grant only what the task needs, only to whoever does it, only for as long as needed.
  • Write the identity's job in one sentence; grant only its verbs and resources.
  • People, services and pipeline jobs all need least privilege; prune unused rights.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainShrink the pipeline's keys

Today every Tiffin pipeline job runs as one cloud identity with full admin rights, and all five developers are also cloud admins. Design a least-privilege setup using roles, and explain what damage each change prevents.