Overview
Curated: · Written: · Reviewed:
RBAC vs. ABAC Implementation
In one line
Use RBAC when access tracks stable job functions over coarse resources. Use ABAC when access depends on tenant, ownership, classification, region, or time, and keep that context out of role names. Most production systems run a hybrid: a role grants the capability, and attributes constrain where and on which objects it applies.
Key definitions
- Role explosion: the role count grows with each context combination (team x environment x data class) instead of with job functions.
- PEP / PDP / PIP: the enforcement point asks the policy decision point, which pulls any missing attributes from the policy information point.
- Fail-closed: a missing, malformed, stale, or erroring input produces deny.
- Static SoD: conflicting roles cannot be assigned, checked against effective (inherited) roles.
- Dynamic SoD: conflicting actions cannot occur in the same session or transaction.
- Authoritative issuer: the single system allowed to write an attribute, with its schema, type, and freshness rule.
Formulas and complexity
Worked example from the replay in MCQ 25 (hypothetical labelling not needed; figures as given):
Denominator is previously allowed traffic. Intended blocks are excluded from the numerator.
Cache staleness bound with stacked caches:
With a 60 s client cache and a 5 s policy cache, the worst case is about 65 s, not the 10 minutes measured with the 600 s policy cache.
How it works
- The gateway builds a canonical request: authenticated principal, action, canonical resource ID, tenant, and resource attributes read from the system of record.
- The PDP resolves any attributes it lacks from the PIP, then evaluates the complete policy set under a stated combining rule.
- The enforcement point applies the decision to that exact object and records the policy version.
- List, search, export, bulk, and worker paths each repeat steps 1 to 3. One missed path is a bypass.
When to use and when not to
| Situation | RBAC | ABAC |
|---|---|---|
| Stable job functions, coarse resources | Fits | Usually overkill |
| Ownership, tenant, classification, time, network | Role per combination, explodes | Fits |
| Hot path with a tight p99 | Claims in the token, in memory | PIP fetches add variable latency |
| Auditor asks who can access object X | Read role membership | Needs simulation tooling |
| Revocation within minutes | Bounded by token lifetime | Bounded by attribute freshness and cache TTLs |
Traps interviewers probe
- Missing attribute treated as a value. A Go map returns an empty string for a missing key, so
resource_team == caller_teamis true when both are missing. Fix: test for presence and deny when absent. - Checking the path tenant instead of the object. A query like
WHERE id = $1returns another tenant's row when the path tenant matches the token. Fix: scope the query by the token's tenant, or check the loaded row's tenant before returning it. - Expecting a deny rule in Kubernetes RBAC. RBAC rules are allow-only, and a Role cannot subtract a grant from a ClusterRoleBinding. Fix: remove or narrow the binding, or enforce the restriction with admission policy.
- Caching decisions without the policy version. A cache keyed on principal, method, and path keeps serving ALLOW after a deploy removes the permission. Fix: put the policy version in the key, invalidate on deploy, and bound staleness by the TTLs.
- All-or-nothing batch that authorizes any item. Checking whether the caller can delete some item lets the whole batch through. Fix: require every ID to pass before any delete runs.
Interview tips
Open with the decision: "I would go hybrid. Roles grant capability, attributes constrain context, missing attributes deny, and the PDP is called on every path, including lists, exports, and jobs."
Expect these follow-ups: missing or stale attribute, revocation delay and the number that meets it, bulk, export and background-job paths, precedence between allow and deny, and who can access this object.
30-second outline:
- Model: hybrid, chosen on whether the rules track function or context.
- Attributes: issuer, schema, freshness, deny on missing.
- Enforcement: every path, applied to the exact object.
- Revocation: cache TTL sum and invalidation on deploy.
- Audit: policy version and attribute versions for each allow.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.