Web vulnerability scanning in Cybersecurity - Time & Space Complexity
When scanning a website for security weaknesses, it is important to understand how the scanning time changes as the website grows.
We want to know how the number of pages and inputs affects the scanning effort.
Analyze the time complexity of the following simplified vulnerability scanning process.
for page in website.pages:
for input_field in page.input_fields:
test_input(input_field)
check_response()
scan_page_for_issues(page)
This code scans each page and tests every input field for vulnerabilities.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Testing each input field on every page.
- How many times: For each page, all input fields are tested once.
As the number of pages or input fields grows, the scanning time grows too.
| Input Size (pages x inputs) | Approx. Operations |
|---|---|
| 10 pages x 5 inputs | 50 tests |
| 100 pages x 5 inputs | 500 tests |
| 1000 pages x 5 inputs | 5000 tests |
Pattern observation: The total tests increase proportionally with the number of pages and inputs.
Time Complexity: O(p * i)
This means the scanning time grows in direct proportion to the number of pages (p) and input fields (i).
[X] Wrong: "Scanning time only depends on the number of pages, not inputs."
[OK] Correct: Each input field needs separate testing, so more inputs mean more work.
Understanding how scanning time grows helps you explain efficiency and resource needs clearly in real-world security tasks.
"What if the scanner also tested every link on each page? How would that affect the time complexity?"