Man-in-the-middle attacks in Computer Networks - Time & Space Complexity
When studying man-in-the-middle attacks, it helps to understand how the attack process scales as more data or connections are involved.
We want to know how the effort or steps needed grow when the attacker handles more intercepted messages.
Analyze the time complexity of the following simplified attack process.
for intercepted_message in network_traffic:
decrypt intercepted_message
modify intercepted_message
re-encrypt intercepted_message
forward intercepted_message
log attack details
This code simulates an attacker intercepting messages, altering them, and sending them on.
Look at what repeats as the input grows.
- Primary operation: Processing each intercepted message (decrypt, modify, re-encrypt, forward)
- How many times: Once for every message in the network traffic
As the number of intercepted messages increases, the total work grows in a straight line.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 message processes |
| 100 | 100 message processes |
| 1000 | 1000 message processes |
Pattern observation: Doubling the messages doubles the work needed.
Time Complexity: O(n)
This means the attacker's work grows directly with the number of messages intercepted.
[X] Wrong: "The attacker can process all messages instantly regardless of how many there are."
[OK] Correct: Each message requires separate steps, so more messages mean more total work.
Understanding how attack steps grow with input size shows your ability to analyze security processes and their costs, a useful skill in many tech roles.
"What if the attacker batches messages and processes them together? How would that change the time complexity?"