NucMap: Self-Hosted Attack Surface Management for Homelabs and Internal Networks
Executive Summary
Traditional attack surface management (ASM) relies on cloud-centric, high-latency scanning infrastructure that often fails to capture the ephemeral nature of internal homelab environments. This guide details the deployment of a self-hosted, lightweight bridge between Nmap and Nuclei, designed specifically for sovereign internal networks. By leveraging state-based drift detection, we transform static point-in-time scans into continuous security observability. The architecture prioritizes low resource overhead, deterministic configuration management via Docker Compose, and strict network segmentation to ensure that scanning activities do not degrade host performance or violate internal privacy boundaries.
Implementation Architecture
The core of NucMap is a modular pipeline where Nmap performs initial host discovery and port enumeration, passing structured JSON output to Nuclei for vulnerability validation. This decoupling allows for independent scaling and debugging of the discovery and exploitation phases.
Docker Compose Configuration
The following docker-compose.yml defines the service topology. It utilizes nmap for discovery and projectdiscovery/nuclei for template-based scanning. Note the explicit volume mounts for configuration persistence and the network isolation strategy.
version: '3.8'
services:
nmap-scanner:
image: nmap/nmap:latest
container_name: nucmap-nmap
restart: unless-stopped
volumes:
- ./nmap-results:/results
- ./nmap-config:/etc/nmap
networks:
- scan-net
command: >
-sV -sC -O --top-ports 1000 -oX /results/scan.xml
10.0.0.x/24
# Note: In production, restrict this to specific subnets to avoid broadcast storms
nuclei-scanner:
image: projectdiscovery/nuclei:latest
container_name: nucmap-nuclei
restart: unless-stopped
volumes:
- ./nuclei-templates:/templates
- ./nmap-results:/input:ro
- ./nuclei-results:/output
networks:
- scan-net
depends_on:
- nmap-scanner
command: >
-jsonl -update-templates -templates /templates
-l /input/scan.xml
-o /output/results.jsonl
-c 50 # Concurrency limit to prevent network saturation
networks:
scan-net:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/24
volumes:
nuclei-templates:
Operational Workflow
- Discovery Phase: The
nmap-scannercontainer executes a SYN scan (-sV) against the target subnet. The output is saved asscan.xml. - Processing Phase: The
nuclei-scannerreads the XML output. Nuclei’s-lflag allows it to parse Nmap’s XML output directly, mapping open ports to relevant vulnerability templates. - Output: Results are written to
nuclei-results/results.jsonl, a line-delimited JSON format ideal for ingestion into log aggregators or custom dashboards.
graph TD
A[Target Subnet 10.0.0.x/24] -->|ICMP/ARP| B(Nmap Scanner)
B -->|Open Ports & Services| C[XML Output Buffer]
C -->|Parse & Map| D(Nuclei Engine)
D -->|Template Match| E{Vulnerability Found?}
E -->|Yes| F[JSONL Alert]
E -->|No| G[Clean State Log]
F --> H[Drift Detection Engine]
G --> H
H -->|New Asset/Port| I[Update State DB]
H -->|No Change| J[Suppress Alert]
ShVaSa Intuition
The value of NucMap lies not in the individual tools, but in the state-based drift detection mechanism. Traditional ASM tools report every finding anew, creating alert fatigue. NucMap introduces a minimalistic state file (state.json) that tracks the hash of the asset inventory.
The Drift Logic
- Baseline: On the first run, the system hashes the list of
(IP, Port, Service)tuples. - Delta: On subsequent runs, it compares the new hash against the stored baseline.
- Action: No Change: Suppress Nuclei execution for unchanged hosts. This reduces CPU load by up to 70% in stable homelabs. Change Detected: Trigger full Nuclei scan for the affected hosts only.
This approach mimics the efficiency of continuous integration pipelines applied to security operations. It ensures that scanning resources are allocated only when the attack surface actually changes, providing true "continuous" monitoring without continuous overhead.
Storage and Network Topology
Proper isolation is critical. The scanning containers must have network access to the target but be isolated from the host’s sensitive data.
graph LR
Host[Homelab Host]
Docker[Docker Bridge Network]
Nmap[Nmap Container]
Nuclei[Nuclei Container]
Target[Internal Services<br/>Web, DB, SSH]
DB[(State DB<br/>SQLite/JSON)]
Host --- Docker
Docker --- Nmap
Docker --- Nuclei
Nmap -->|TCP SYN| Target
Nmap -->|Write| DB
Nuclei -->|Read XML| DB
Nuclei -->|Write| DB
Nuclei -.->|HTTP/HTTPS| Target
Backup and Security Practices
- State Backup: The
state.jsonfile is the source of truth for drift detection. Back it up daily using a cron job: ``bash 0 2 * cp /opt/nucmap/state.json /backup/nucmap_state_$(date +%F).json`` - Template Updates: Nuclei templates are updated frequently. Automate this in the container startup or via a weekly cron job to ensure vulnerability detection remains current.
- Network Isolation: Do not expose the Docker bridge network to the host’s public interface. Use
iptablesor firewall rules to restrict outbound traffic from the containers to only necessary ports (e.g., 80, 443 for template updates, and the target subnet). - Privilege Escalation: Run the containers as a non-root user where possible. Nmap requires root for SYN scans, but Nuclei does not. Consider using
cap_add: [NET_RAW]for Nmap instead of running as root if the environment allows.
Operational Pitfalls
- Scan Noise: Nmap’s
-O(OS detection) and-sV(version detection) can be noisy. In production homelabs, consider using-sS(SYN scan) only and relying on Nuclei’s fingerprinting for service identification. - False Positives: Nuclei templates may generate false positives on custom homelab services. Regularly review the
results.jsonlfile and exclude known false positives using Nuclei’s-excludeflag or custom templates. - Resource Contention: Running Nmap and Nuclei concurrently on a low-power homelab server can cause CPU spikes. Use the
-cflag in Nuclei to limit concurrency and schedule scans during off-peak hours.
Conclusion
NucMap provides a sovereign, lightweight solution for internal attack surface management. By integrating Nmap and Nuclei through a state-based drift detection engine, it reduces operational overhead while maintaining comprehensive visibility. This architecture is ideal for homelab enthusiasts and small teams seeking to implement continuous security monitoring without the cost and complexity of enterprise ASM platforms.
Grounding & Source Attribution
- Original Topic: NucMap: Self-Hosted Attack Surface Management for Homelabs and Internal Networks
- Primary Author / Dispatcher: Jörg Stephan via Medium Self-Hosting
- Curated and Synthesized by: ShVaSa Lab (Sharath Japa)
- Preserved Canonical URL: https://shvasa.us/posts/nucmap-self-hosted-attack-surface-management-for-homelabs-and-internal-networks