Vulnerability Scanning Basics: How to Find Vulnerabilities on Your Server
"Is my server secure?" Feelings cannot answer that. Your server runs an OS, services, and a pile of dependency libraries — any component with a publicly known vulnerability (CVE) can be an entry point. Vulnerability scanning is a "health check" for your server: it proactively asks "what ports are open, what versions are running, and are there known vulnerabilities?" This guide explains, from zero, what vulnerability scanning is, what the three scan types check, how to use common tools, and how to prioritize the results.
1. What Vulnerability Scanning Is: A Health Check for Your Server
Think of your server as a person and vulnerability scanning as an annual physical:
- Port scanning: checks "which doors are open" — which ports are reachable from outside;
- Service scanning: checks "what is behind each door" — which software and version is listening;
- Dependency scanning: checks "are the medicines in your cabinet expired" — whether libraries your code depends on have known vulnerabilities.
Scanners compare these results against a vulnerability database (CVE database) and output a "report card": which components are at risk and how severe. Note that scanning "finds problems" but does not "solve them" — you still need to review and fix based on the report. To understand the full lifecycle from a flaw's discovery to public disclosure, see Vulnerability & CVE Lifecycle.
2. Three Scan Types, Each with Its Own Purpose
Port Scanning: The Most Basic Layer
Purpose: discover which ports the server exposes to the outside. Ports that should not be open by default (database 3306, Redis 6379) being exposed is a "door left unlocked".
nmap -sV -p- your-server-ip
-sV probes versions as well, and -p- scans all 65,535 ports. When you see unexpected open ports, either stop the service or block it with the firewall. Rules are in Linux Firewall Configuration.
Service and Version Scanning: Find Software "Working While Sick"
Purpose: confirm the software and version behind each open port, then compare against the vulnerability database. For example, if Nmap finds Nginx 1.20.1, look up whether that version has known CVEs. Nmap's -sV does exactly this.
Dependency and Image Scanning: Catch "Invisible" Risks
The npm/pip/composer packages your site depends on and the system libraries inside Docker images are hot spots for vulnerabilities. Because dependencies number in the hundreds or thousands, manual review is impractical — automation is the only option. For image scanning in containerized deployments, see Container Security Best Practices.
3. Common Tools: How to Choose and Use Them
| Tool | Role | Best for | Typical usage |
|---|---|---|---|
| Nmap | Network/port/service scanning | Quickly mapping the attack surface | nmap -sV -p- ip |
| OpenVAS | Full vulnerability scanner (with vulnerability DB) | Regular comprehensive checkups | Browser interface; configure a target and scan in one click |
| Trivy | Container image/filesystem/dependency scanning | Scanning images and dependencies in CI | trivy image your-image, trivy fs . |
| Nikto | Web server misconfiguration scanning | Web site checkups | nikto -h https://your-site.com |
Selection factors: whether you need web-application scanning, CI integration, or one-off command-line checks versus scheduled full scans. A more complete tool comparison is in Vulnerability Scanner Comparison.
4. After the Results: Prioritize with CVSS
Scan reports often contain dozens or hundreds of entries. Do not try to fix everything at once; fix the most dangerous first. The industry-standard scoring system is CVSS (Common Vulnerability Scoring System), from 0 to 10:
- 9.0–10.0 (Critical): remotely exploitable with no privileges. Fix within 24 hours, ideally the same day.
- 7.0–8.9 (High): low exploitation barrier, large impact. Fix within a week.
- 4.0–6.9 (Medium): conditionally exploitable. Include in the next maintenance window.
- 0–3.9 (Low): limited impact or hard to exploit. Log it and review periodically.
Add two more dimensions when prioritizing: is it exposed to the internet (a library only on the internal network can wait even with a high score) and is there active exploitation in the wild (jump the queue for flaws already being exploited). Fixes usually fall into three kinds: upgrade the version, apply a patch, or apply mitigations (such as restricting the firewall to internal-only access or disabling the affected module).
5. Intro Workflow and Frequency Advice
- Weekly: run an Nmap port/service scan to confirm the attack surface has not changed.
- Every release: run Trivy in CI to scan images and dependencies; block the merge if problems appear.
- Monthly: run an OpenVAS full scan and produce a monthly report.
- After every scan: sort by CVSS plus exposure, update the fix plan; also read Penetration Testing Basics to understand deeper "attacker's-eye" testing beyond scanning, and when possible hire a professional team for a full penetration test.
- Will scanning affect production? It can. Some scans (especially full-port, deep service probing) generate traffic and connections that may trigger alerts or slow services. Scan a test/staging environment first, and use low-frequency, low-concurrency settings on production.
- If no vulnerabilities are found, am I safe? No. Scanning only finds "known vulnerabilities"; it cannot catch logic flaws, misconfigurations, or zero-days. It is the lowest-barrier health check, not a security certification.
- Aren't scanning tools for hackers? No. Nmap, Trivy, and others are legitimate operations/security tools; "where you point them" determines the nature. Scanning your own assets is standard practice. Note that scanning someone else's assets without authorization is illegal in most jurisdictions.
- Where can I find more security hardening content? The Security Hardening category on this site covers system hardening, WAF, security headers, and more — complementary to scanning.
Configuration & Integration Examples
Example 1: Service and version discovery on an authorised target
#!/usr/bin/env bash
# Only scan hosts you own or have written authorisation for; -sV generates real traffic
set -euo pipefail
target="${TARGET:?set TARGET=authorised host or IP}"
out="/tmp/scan-$(echo "$target" | tr '/' '_')"
nmap -sV -Pn --top-ports 1000 -oA "$out" "$target"
# Keep only open ports and versions so the output reconciles with your asset list
grep -E "^\s*[0-9]+/tcp\s+open" "$out.nmap" | sort -k1 -n
-sV actively probes services, so avoid shared hosting or third-party systems; sanitise results before storing them, because a clean port list is exactly what an attacker wants.
Example 2: Host baseline and image vulnerabilities are two separate scans
# Host configuration audit: read-only, changes nothing
lynis audit system --quick --no-colors | tee "/var/log/lynis-$(date +%F).log" >/dev/null
grep -E "Hardening index|Warning" "/var/log/lynis-$(date +%F).log" | head
# Container image: high and critical only, skip issues with no fix available
trivy image --severity HIGH,CRITICAL --ignore-unfixed \
"${IMAGE:?set IMAGE=registry/image:tag}"
# Filesystem and dependency scan, suitable for CI
trivy fs --scanners vuln,secret --exit-code 1 .
They answer different questions: lynis tells you where configuration drifts from a baseline, trivy tells you whether a dependency has a known CVE. Skipping either leaves a blind spot.
Scan Scope and Cadence Rules
The four scan types carry different cadences, and scheduling them as one bucket loses on both ends: port scans run weekly, the full scan monthly, and dependency scans ride along with releases. Set the cadence first, then judge the production impact of each type.
The table follows the tool table and cadence advice above; the last column is what decides whether a scan needs a maintenance window.
| Scan type | Tool and command | Cadence | Suggested environment | Production impact |
|---|---|---|---|---|
| Ports and services | nmap -sV -p- (65535 ports) |
weekly | production at low rate | full-range probing generates traffic and can trip alerts |
| Dependencies and images | trivy image, trivy fs . |
every release, inside CI | build artifacts | no production traffic |
| Web configuration | nikto -h |
whenever site config changes | staging first | bursts of requests, keep concurrency low |
| Full vulnerability scan | OpenVAS web UI | monthly | staging first, production at low concurrency | deep probing, book a maintenance window |
More frequent is not better. A weekly full-range port scan is enough to confirm the exposed surface has not changed; the cadence that genuinely needs tightening is release time, since only the Trivy run in CI stops a newly added dependency with a CVE before merge.
Ports such as 3306 for databases and 6379 for Redis belong to port scanning for detection and to firewall rules for prevention. Scanning finds them; the firewall keeps them from reopening.
Fix Windows and Exposure Cross-Check
The four CVSS bands map to four fix windows: 9.0-10.0 within the day or 24 hours, 7.0-8.9 within a week, 4.0-6.9 in the next maintenance window, 0-3.9 logged and re-checked periodically. That timeline is the skeleton of the remediation plan.
Score alone misleads. An internal-only component scoring 9.0 can wait, while an internet-facing 7.5 must move on the one-week window; conversely, a CVE with active exploitation jumps the queue even at a middling score.
Remediation takes three forms: version upgrade, patch, mitigation. Mitigation usually means a firewall rule that only admits the internal network, or disabling the affected module — and it must be written back to the list, or the next scan reports the same finding again.
Windows only work when they match cadence. Weekly port scan results get consumed within the week, and the monthly report within the maintenance window; production keeps the low-rate, low-concurrency profile, and deep probing stays in staging.
Limitations
- "Is my server secure?" Feelings cannot answer that.
- Note that scanning "finds problems" but does not "solve them" — you still need to review and fix based on the report.
- The npm/pip/composer packages your site depends on and the system libraries inside Docker images are hot spots for vulnerabilities.
- Do not try to fix everything at once; fix the most dangerous first.
- Scanning only finds "known vulnerabilities"; it cannot catch logic flaws, misconfigurations, or zero-days.
FAQ
What permission does an authenticated scan require?
Root is required for SYN scans. Local dependency checks need the same privilege, while a remote scan only needs port 80/443 to answer. Get written authorisation before touching the host, because port lists are intelligence. Run the scanner from the same network segment to avoid rate limits and false negatives across the edge.
Port scans keep failing: what do you check first?
Confirm the host is up and routable before blaming the firewall. Add -Pn to skip host discovery and start with --top-ports 1000; a full 65535-port sweep is often throttled or dropped by security groups and IDS, which looks like a permanent timeout. Lower concurrency or scan from inside.
Where should the scanner's SSH key live?
Keep it on the scanner only, with chmod 600. Use a dedicated account pinned to a source IP. Never reuse the operations account or park the private key in plain text outside CI secrets; credentialed scans should run with least privilege and rotate the key afterwards so the scanner does not become a new attack surface.
Can vulnerability scanning replace a penetration test?
No. Scanning compares against known CVEs and configuration items, so logic flaws, broken authorisation and chained business abuse stay invisible. 1 Nmap sweep weekly plus 1 OpenVAS run monthly keeps the exposed surface bounded; a penetration test has a human building attack paths and runs yearly or before a major launch.
Related Providers
- Nmap: when the first job is mapping exposed ports and service versions in a single -sV -p- pass.
- OpenVAS: when a scheduled full assessment with a vulnerability feed and monthly reports is required.
- Trivy: when images and dependencies must be scanned inside CI before a release merges.
Community & Resources
Official docs and communities
- Nmap Reference Guide — semantics of port scanning and version detection, so heavy options are not used by accident
- OpenSCAP — automated compliance scanning against SCAP baselines
- NVD — authoritative CVE and CVSS data for judging severity
- Stack Overflow
nmap— scan flags, output parsing and common false positives
Learning resources and tools
- Lynis — host audit and hardening score
- CISOfy/lynis — check definitions behind every warning
- aquasecurity/trivy — scanner for images, filesystems and dependencies
- Nmap project — documentation, script library and licensing
Original source: 16IDC Original ↗