VA scan
A vulnerability scanner knocks on every door and lists what it already knows to look for. Watch a scan, a fix and a scan again, then the bug no list has and the advisory that lands next week.
What you'll take away
- Read a CVSS score and its vector, and fix the worst finding first
- Know how a scanner finds holes: versions matched to advisories, plus a few real tries
- Explain why a logic bug, like reading an order by changing its id, needs a person to find
- Scan again to prove the fixes, and on a schedule for advisories still to come
The 1-minute version
Tap a point and the picture below plays that step.
Scan, fix from the highest score down, scan again until it's clean. Then have a person test it, and skip to next week. All of it is a toy; for real, scan only your own systems, or ones you have written permission to test
A VA scan finds nothing. Is the system safe?
The picture: a toy company is a fenced yard holding its host, database and web app; the fence is the network and its gates are ports. The scanner on the street outside probes one thing at a time, and each finding lands as a crate with its CVSS score, red for critical down to blue for low, teal once fixed. A grey ? is what a scanner can't see. It's all a toy: for real, scan only your own systems, or ones you have written permission to test.
Compare them all: VA scan
Five problems already in some list, one logic bug, and an advisory that lands later. See what each way finds.
Use it when Nothing should be run like this
Skip it when Anything on the internet
A model of what each way can see, not of time or cost. Some real scanners test web apps more deeply than this, but none knows whose order is whose. Press any tile to see it large above, with when it fits.
What this scan found
| Finding | CVSS | Fix |
|---|---|---|
| the database's default password still works | 9.1 critical | change it and disable the default account |
| an OS package version with an advisory | 7.8 high | update the package and reboot |
| the database port open to the internet | 7.5 high | close it at the firewall; only the app servers may connect |
| change the order id in the URL, see someone else's order (a person found it) | 6.5 medium | check on every request that the order belongs to the logged-in user |
| a reflected XSS on the search page | 6.1 medium | escape what's reflected, add a CSP |
| no HSTS header | 3.1 low | send Strict-Transport-Security |
Known problems only
A scanner matches versions against advisories and tries what it was built to try: open ports, default passwords, missing headers, common payloads. A flaw in your own logic, like an order anyone can read by changing its id, is in no list. That's what a penetration test, a person trying to break it, is for.
Only on what's yours
Scan your own systems, or ones you have written permission to test, with a clear scope. Testing someone else's without it is against the law in many countries, Thailand included.
In real code
# A vulnerability scan in miniature, only against toy services this script starts on 127.0.0.1: connect to each port,
# read the banner, look the name and version up in a table of known problems, and rank what it finds by its CVSS 3.1
# base score (computed here, checked against well-known scores). Then the fix (an upgrade) and a scan again.
# What it can't see is the point of the last service: a flaw nobody has listed yet looks clean to any scanner.
# Run: python3 scan.py
import math
import socket
import threading
W = {"AV": {"N": 0.85, "A": 0.62, "L": 0.55, "P": 0.2}, "AC": {"L": 0.77, "H": 0.44}, "UI": {"N": 0.85, "R": 0.62},
"CIA": {"H": 0.56, "L": 0.22, "N": 0.0}}
def roundup(x: float) -> float:
i = round(x * 100000)
return i / 100000.0 if i % 10000 == 0 else (math.floor(i / 10000) + 1) / 10.0
def cvss31(vector: str) -> float:
m = dict(part.split(":") for part in vector.split("/")[1:])
changed = m["S"] == "C"
pr = {"N": 0.85, "L": 0.68 if changed else 0.62, "H": 0.5 if changed else 0.27}[m["PR"]]
iss = 1 - (1 - W["CIA"][m["C"]]) * (1 - W["CIA"][m["I"]]) * (1 - W["CIA"][m["A"]])
impact = 7.52 * (iss - 0.029) - 3.25 * (iss - 0.02) ** 15 if changed else 6.42 * iss
exploit = 8.22 * W["AV"][m["AV"]] * W["AC"][m["AC"]] * pr * W["UI"][m["UI"]]
if impact <= 0:
return 0.0
return roundup(min((1.08 if changed else 1) * (impact + exploit), 10))
def severity(score: float) -> str:
return "critical" if score >= 9 else "high" if score >= 7 else "medium" if score >= 4 else "low" if score > 0 else "none"
# The scores everyone knows: Log4Shell 10.0, a typical critical RCE 9.8, Heartbleed 7.5, a reflected XSS 6.1
for vec, want in [("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H", 10.0), ("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", 9.8),
("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N", 7.5), ("CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", 6.1)]:
assert cvss31(vec) == want, (vec, cvss31(vec))
# Known problems, by (name, version): made up for these toy services.
KNOWN = {
("toy-ftpd", "1.0"): ("TOY-2026-001 anonymous write", "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"),
("toy-dbd", "3.2"): ("TOY-2026-007 default password", "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"),
("toy-httpd", "2.4"): ("TOY-2026-012 reflected XSS on /search", "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"),
}
def serve(banner: str) -> int:
srv = socket.socket()
srv.bind(("127.0.0.1", 0))
srv.listen()
def loop() -> None:
while True:
conn, _ = srv.accept()
with conn:
conn.sendall(banner.encode() + b"\r\n")
threading.Thread(target=loop, daemon=True).start()
return srv.getsockname()[1]
def scan(ports: list[int]) -> list[tuple[float, str, str]]:
found = []
for port in ports:
with socket.create_connection(("127.0.0.1", port), timeout=2) as s:
name, version = s.recv(100).decode().strip().split("/")
if (name, version) in KNOWN:
what, vec = KNOWN[(name, version)]
found.append((cvss31(vec), f"{name} {version} :{port}", what))
return sorted(found, reverse=True)
before = [serve(b) for b in ["toy-ftpd/1.0", "toy-dbd/3.2", "toy-httpd/2.4", "toy-shop/1.0"]] # toy-shop: a logic bug, listed nowhere
first = scan(before)
assert [round(s, 1) for s, _, _ in first] == [9.8, 9.1, 6.1]
after = [serve(b) for b in ["toy-ftpd/1.1", "toy-dbd/3.3", "toy-httpd/2.5", "toy-shop/1.0"]] # upgraded
second = scan(after)
assert second == []
print("scan 1: " + ", ".join(f"{severity(s)} {s} {what.split()[0]}" for s, _, what in first)
+ " · after upgrading: 0 findings · toy-shop's logic bug: never found, it's in no list")
python3 scan.pyIt printed: scan 1: critical 9.8 TOY-2026-001, critical 9.1 TOY-2026-007, medium 6.1 TOY-2026-012 · after upgrading: 0 findings · toy-shop's logic bug: never found, it's in no listToy services this script starts on 127.0.0.1 only: connect, read each banner, match name and version against a table of known problems, and rank by CVSS 3.1 base score (the formula checked against well-known scores: 10.0, 9.8, 7.5, 6.1). Upgrade, scan again: 0 findings. The toy shop's logic bug is never found. Really run.
Common questions
The scan found nothing. Am I safe?
It means no problem the scanner knows of, on that day. It can't see bugs in your app's own logic, and tomorrow an advisory may land for a version you run. All green is good; it isn't the end.
How does a scanner know there's a hole?
Mostly it reads versions from banners or package lists and matches them against advisories (CVEs). Some things it really tries, like which ports are open or whether a default password works. So it finds only what someone has written a check for.
What is CVSS, and how do I read it?
A score from 0.0 to 10.0 worked out from a vector: AV:N/PR:N means reachable over the network with no login. 9.0 and up is critical, 7.0 to 8.9 high, 4.0 to 6.9 medium, below that low. It rates the hole; how much it matters to your system is still your call.
It found several things. Which do I fix first?
By score, worst first. Here the database's default password (9.1) comes first, then the old package (7.8) and the database port open to the internet (7.5), then down to the XSS (6.1) and the header (3.1).
I fixed everything. Why scan again?
To prove the fixes landed: a patch may have missed a machine, or a service may not have restarted. A second scan that comes back green is your proof.
How is a VA scan different from a penetration test?
A VA scan is a machine sweeping wide for known problems: cheap, and you can run it often. A penetration test is a person trying to break in: deeper, and it finds logic bugs, but it costs more and happens now and then. Systems with money or personal data want both.
How often should I scan?
On a schedule, say weekly or monthly, and after big deploys, because new advisories come out all the time. In Compare, the one-off scan misses the problem that lands later; the scheduled one catches it.
Can I scan someone else's system?
Not without written permission and an agreed scope. In many countries, Thailand included, getting into someone else's system without permission is against the law. Scan only what's yours or what you're allowed to test.
Next lesson
API securityLevel: Intermediate
No scanner caught the order anyone could read by changing its id; next, the check that stops it: who may do what, or a 403.