Threat hunting techniques in Cybersecurity - Time & Space Complexity
When we analyze threat hunting techniques, we want to understand how the time needed grows as the amount of data or alerts increases.
We ask: How does the effort change when we have more logs or events to check?
Analyze the time complexity of the following threat hunting process.
for alert in alerts_list:
for log_entry in logs_database:
if matches(alert, log_entry):
record_suspicious(log_entry)
analyze_results()
This code checks every alert against every log entry to find suspicious activity.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Nested loops comparing alerts to logs.
- How many times: For each alert, it checks all log entries.
As the number of alerts and logs grow, the total checks increase quickly.
| Input Size (alerts x logs) | Approx. Operations |
|---|---|
| 10 alerts x 100 logs | 1,000 checks |
| 100 alerts x 1,000 logs | 100,000 checks |
| 1,000 alerts x 10,000 logs | 10,000,000 checks |
Pattern observation: The number of operations grows very fast as both alerts and logs increase.
Time Complexity: O(n x m)
This means the time needed grows proportionally to the number of alerts times the number of logs.
[X] Wrong: "Checking alerts one by one is always fast enough."
[OK] Correct: When data grows large, checking every alert against every log can take a very long time.
Understanding how time grows with data size helps you explain how to handle large security data efficiently in real work.
"What if we indexed the logs to quickly find matches? How would the time complexity change?"
Practice
Solution
Step 1: Understand the purpose of threat hunting
Threat hunting is about proactively looking for threats that may not be detected by automated tools.Step 2: Compare options to the goal
Installing antivirus, creating passwords, or blocking internet are preventive or reactive, not active searching.Final Answer:
To actively search for hidden cyber threats before they cause damage -> Option DQuick Check:
Threat hunting = active search [OK]
- Confusing threat hunting with installing security software
- Thinking threat hunting is only about blocking access
- Believing it is about password management
Solution
Step 1: Identify common threat hunting methods
Threat hunting often starts with forming hypotheses about how attackers might behave.Step 2: Evaluate each option
Waiting for alerts is reactive, ignoring logs or disabling firewalls harms security, so only forming hypotheses fits.Final Answer:
Forming hypotheses about attacker behavior -> Option CQuick Check:
Hypothesis formation = key hunting step [OK]
- Thinking threat hunting is passive waiting
- Ignoring important data sources like logs
- Reducing security tools to avoid alerts
if suspicious_activity_detected and data_source == 'network_logs': alert(). What happens if suspicious activity is found in network logs?Solution
Step 1: Understand the condition in the code
The code triggers alert() only if suspicious_activity_detected is true and data_source equals 'network_logs'.Step 2: Analyze the scenario
If suspicious activity is found in network logs, both conditions are true, so alert() runs.Final Answer:
An alert is generated -> Option AQuick Check:
Conditions met = alert triggered [OK]
- Assuming no alert without checking both conditions
- Confusing alert with system shutdown
- Ignoring the data source condition
if event_type = 'login_failure' then investigate(). What is wrong with this code?Solution
Step 1: Identify the operator used in the condition
The code uses '=' which usually means assignment, not comparison.Step 2: Understand correct syntax for comparison
To check equality, '==' should be used, so the condition properly tests event_type.Final Answer:
The assignment operator '=' is used instead of comparison '==' -> Option AQuick Check:
Use '==' for comparison, not '=' [OK]
- Confusing '=' with '==' in conditions
- Assuming function syntax error without checking operators
- Changing condition logic unnecessarily
Solution
Step 1: Understand the benefit of multiple data sources
Using diverse data like network, endpoint, and user logs gives a fuller picture of threats.Step 2: Evaluate approaches for effective threat hunting
Forming hypotheses and analyzing multiple sources is proactive and thorough, unlike ignoring data or relying only on alerts.Final Answer:
Form hypotheses and analyze data from network, endpoint, and user activity logs -> Option BQuick Check:
Multiple data sources + hypotheses = better hunting [OK]
- Using only one data source limits threat visibility
- Ignoring noisy data that can hold clues
- Relying only on automated alerts misses hidden threats
Ready to prove it?
Pass the test and this pattern moves unknown
