0
0
Cybersecurityknowledge~5 mins

Access control models (MAC, DAC, ABAC) in Cybersecurity - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Access control models (MAC, DAC, ABAC)
O(n)
Understanding Time Complexity

We want to understand how the time it takes to check access permissions changes as the number of users and resources grows.

How does the system handle more users or rules without slowing down too much?

Scenario Under Consideration

Analyze the time complexity of this simplified access check function.


function checkAccess(user, resource, action) {
  for (let rule of accessRules) {
    if (rule.appliesTo(user, resource, action)) {
      return rule.isAllowed;
    }
  }
  return false;
}
    

This code checks each access rule one by one to see if it applies to the user, resource, and action requested.

Identify Repeating Operations

Look for loops or repeated checks in the code.

  • Primary operation: Looping through all access rules.
  • How many times: Once for each rule until a match is found or all rules are checked.
How Execution Grows With Input

As the number of access rules grows, the time to check access grows too.

Input Size (number of rules)Approx. Operations (rule checks)
10Up to 10 checks
100Up to 100 checks
1000Up to 1000 checks

Pattern observation: The time grows roughly in direct proportion to the number of rules.

Final Time Complexity

Time Complexity: O(n)

This means the time to check access grows linearly with the number of access rules.

Common Mistake

[X] Wrong: "Checking access is always instant no matter how many rules there are."

[OK] Correct: Each rule must be checked until a match is found, so more rules mean more work and longer time.

Interview Connect

Understanding how access checks scale helps you design systems that stay fast as they grow, a key skill in cybersecurity roles.

Self-Check

"What if access rules were organized in a way that lets us find the right rule without checking them all? How would that change the time complexity?"