Defense in depth strategy in Cybersecurity - Time & Space Complexity
We want to understand how the effort to protect a system grows as we add more layers of defense.
How does adding more security steps affect the total work needed to break through?
Analyze the time complexity of this simplified defense process.
for layer in defense_layers:
if not attacker_bypasses(layer):
stop_attack()
break
else:
continue_to_next_layer()
final_result = attack_successful_or_not()
This code checks each security layer one by one until the attacker fails or all layers are tested.
Look at what repeats in this process.
- Primary operation: Checking each security layer to see if the attacker can bypass it.
- How many times: Once for each layer until the attacker fails or all layers are checked.
As the number of defense layers grows, the number of checks grows too.
| Input Size (n) | Approx. Operations |
|---|---|
| 3 layers | Up to 3 checks |
| 10 layers | Up to 10 checks |
| 100 layers | Up to 100 checks |
Pattern observation: The work grows directly with the number of layers; more layers mean more checks.
Time Complexity: O(n)
This means the time to check defenses grows in a straight line with the number of layers.
[X] Wrong: "Adding more layers doesn't increase the checking time because the attacker will fail early."
[OK] Correct: Sometimes the attacker can bypass early layers, so all layers might need checking, making time grow with layers.
Understanding how defense layers add to the total checking effort helps you explain security designs clearly and shows you think about practical costs.
"What if the attacker always fails at the first layer? How would the time complexity change?"