ShVaSa Blog
DIY & Self-Hosting • 5 min read

NucMap: Self-Hosted Attack Surface Management for Homelabs and Internal Networks

Published on 2026-11-19 by Sharath Japa, ShVaSa Lab Lead
diyselfhostingsystemsopen-source
Discuss on r/shvasa

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.

YAML
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

  1. Discovery Phase: The nmap-scanner container executes a SYN scan (-sV) against the target subnet. The output is saved as scan.xml.
  2. Processing Phase: The nuclei-scanner reads the XML output. Nuclei’s -l flag allows it to parse Nmap’s XML output directly, mapping open ports to relevant vulnerability templates.
  3. 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

  1. Baseline: On the first run, the system hashes the list of (IP, Port, Service) tuples.
  2. Delta: On subsequent runs, it compares the new hash against the stored baseline.
  3. 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

  1. State Backup: The state.json file 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 ``
  2. 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.
  3. Network Isolation: Do not expose the Docker bridge network to the host’s public interface. Use iptables or firewall rules to restrict outbound traffic from the containers to only necessary ports (e.g., 80, 443 for template updates, and the target subnet).
  4. 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

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

Author Avatar

Sharath Japa, ShVaSa Lab Lead

Systems & AI Infrastructure Researcher, DGX Station homelab lead. Engineering RL environments, edge silicon inference, and local reasoning model distillation. Verified Profiles: Google Scholar • Google Patents • LinkedIn • GitHub (@sharathjapa) • Medium • r/shvasa.


Canonical Source: https://shvasa.us/posts/nucmap-self-hosted-attack-surface-management-for-homelabs-and-internal-networks

Advertisement

Related Research & Architectural Blueprints