Access control models (MAC, DAC, ABAC) in Cybersecurity - Time & Space 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?
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.
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.
As the number of access rules grows, the time to check access grows too.
| Input Size (number of rules) | Approx. Operations (rule checks) |
|---|---|
| 10 | Up to 10 checks |
| 100 | Up to 100 checks |
| 1000 | Up to 1000 checks |
Pattern observation: The time grows roughly in direct proportion to the number of rules.
Time Complexity: O(n)
This means the time to check access grows linearly with the number of access rules.
[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.
Understanding how access checks scale helps you design systems that stay fast as they grow, a key skill in cybersecurity roles.
"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?"