Enable credentialed pre-port discovery

Credentialed pre-port discovery authenticates to a host with credentials you already manage and asks the operating system which TCP and UDP ports it is listening on. Pre-port discovery replaces network port inferences with an answer from the host itself.

Credentialed pre-port discovery is a scan template property, so you enable it per scan configuration (default is off). On a host where it succeeds, the network port scan is skipped and the engine moves straight to examining the discovered ports. On a host with no matching credential, or where authentication does not succeed, the scan falls back to a network port scan and that fallback is not reported as an error.

Everything after port discovery is unchanged. Service identification, fingerprinting, vulnerability checks, and policy evaluation run exactly as they do today against the ports that discovery returned.

Pre-port discovery limitations and best uses

Pre-port discovery is most valuable when the scan engine has broad network reachability to the hosts it scans and the goal is faster or more accurate port discovery. Two situations favor a network port scan instead:

  • Heavily segmented networks — When the engine can reach only a handful of ports on each host, pre-port discovery still reports every port the host is listening on. The engine then spends time trying to reach ports a firewall blocks, the scan runs slower, and you get no results for the blocked ports.
  • Results that must stay within a fixed set of ports — Pre-port discovery ignores the port range and excluded ports in your scan template and reports every port the host is listening on. If a compliance requirement means a host’s results must stay within a specific list of ports, scan it with a template that has pre-port discovery turned off.

For how pre-port discovery treats your template’s port settings, see Understand credentialed pre-port discovery.

Before you begin

Use the following checks before you enable credentialed pre-port discovery:

Understand credentialed pre-port discovery

When pre-port discovery is enabled, the engine uses whichever of your existing credentials fit each host:

Credential type Works on Notes
Scan Assistant Windows, Linux, macOS Uses the Scan Assistant you have already deployed. Reachable on TCP 21047 by default.
SSH Linux, macOS, other Unix-like hosts Password or key-based SSH credentials. Connects on TCP 22 by default.
Windows Windows Uses your existing Windows credentials directly, when a Scan Assistant is not in play. Contacts the host on TCP 135, then continues on a dynamically negotiated port.

You do not have to choose a method. The engine picks the best available option for each host from the credentials the scan already has. There is nothing new to deploy because pre-port discovery reuses the same credentials you already configure for authenticated scanning.

When more than one credential would work on a host, they are tried in this priority order:

  1. Scan Assistant
  2. SSH
  3. A direct Windows connection

The first credential that connects and authenticates is used. A credential that fails does not prevent the others from being tried. Once one succeeds, the rest are not attempted, so a host with several working credentials is authenticated to only once.

Enable pre-port discovery

Pre-port discovery is a property of the scan template, which means you enable it per scan configuration. You can enable pre-port discovery in your scan templates using the console or using the REST API.

Note that when pre-port discovery is on:

  • A host the scan engine authenticates to is treated as live.
  • The network port scan is skipped for that host, and the engine examines the ports the host reported.
  • Any host that pre-port discovery does not cover goes through the usual host discovery and network port scan.
Built-in templates cannot be edited

Trying to edit a built-in template won’t work. However, you can copy a built-in template, rename it, and use that instead.

To enable pre-port discovery in the console:

  1. From the Security Console, go to Administration > Scan Templates and edit or copy the template you want to change.

  2. Go to the Asset Discovery section.

  3. Select Use credentialed pre-port discovery.

  4. Save the template and assign it to the sites or scans where you want it used.

To enable pre-port discovery using the REST API:

  1. Retrieve a template using GET /api/3/scan_templates/{id}.

  2. Set discovery.asset.prePortDiscovery to true in the template you retrieved.

  3. Send the updated body as a request using PUT /api/3/scan_templates/{id}.

PUT replaces a template

A PUT operation replaces a whole template rather than patching it. Any setting you leave out of the body is written as its default value, not left at its current value, so always send the template you retrieved with the one property changed.
  1. Verify the update worked using GET /api/3/scan_templates/{id} again.

Verify configuration

Rapid7 recommends initially updating and verifying one scan template. The simplest way to verify your configuration works as expected:

  1. Update a single custom template.

  2. Assign that template to a representative group of hosts, covering each host type and each network segment you plan to include.

  3. Run a scan, and compare the results against those hosts’ previous results: ports found, services identified, scan duration, and any new findings.

If the scan worked as expected, then slowly expand to a few templates at a time. The gains are largest where network port scanning has been slow, such as hardened or rate-limited hosts and large port ranges. A responsive host on a fast network may show little difference, so choose your comparison group with that in mind.

Use the scan log

Check the scan log to quickly see if pre-port discovery worked. If pre-port discovery succeeds, the log names the method that worked and the number of ports it returned:

# The method appears as ssh, scan-assistant, or wmi for a direct Windows connection. [10.4.90.12] Pre-discovered via ssh: 14 TCP, 3 UDP ports.

If pre-port discovery did not work, the logs will not mention pre-discovery, which usually means it is a credentials or port restrictions issue. If pre-discovery is present in the log but results are incomplete, the ports were discovered but reachability is the issue.

To see each unreachable port individually, turn on Enhanced Logging in the scan template so the scan log runs at debug level. The per-port detail is produced by the scan target monitor, which is enabled by default; if it has been turned off, the log still points to a firewall or network restriction as a possible cause but does not list the individual ports.

# With Enhanced Logging on, the scan target monitor names each unreachable port (host and port). [10.4.90.12:5432] No response or remote closed connection within 500ms after 3 attempt(s). [10.4.90.12:5432] Port was found open during pre-port discovery but failed during liveness probing. This may be caused by a host-level firewall or similar network restriction blocking external access to the port.

If issues persist, consult Troubleshooting and the FAQ.

Troubleshooting

Some hosts show incomplete results or a finding about excessive connection errors

Pre-port discovery found ports the engine could not reach, so the engine stopped examining that host early. The finding reports the engine’s experience of the host rather than a problem with the host itself.

The scan log points to a firewall or network restriction as a possible cause. To fix it, adjust your firewall or security-group rules so that the engine can reach the services you intend to scan. For hosts that are intentionally segmented off, use a template with pre-port discovery turned off instead.

Pre-port discovery FAQs