An unexpected listening port is either a service nobody documented or something that should not be there, and until you trace it to a process, a binary and an owner you cannot tell which. Scanners, vulnerability tools and EDR consoles raise these findings every day, and too many are closed as "probably fine" or left open indefinitely. This guide gives system administrators and SOC analysts a repeatable method: confirm the listener, map it to a process and verified binary on Linux, Windows and macOS, find the owner through the CMDB, assess the risk and record a keep, restrict or remove decision. It ends with how to baseline listeners so the next surprise is caught automatically. All steps are read-only until the decision stage, and nothing here involves probing systems you do not own.
Key takeaways
- Confirm on the host before you act. A scanner result says something answered; only the host's own socket table tells you which process holds the port and on which address.
- The bind address matters as much as the port. A listener on 127.0.0.1 is reachable only locally; one on 0.0.0.0 or :: answers on every interface, including any that face the internet.
- Verify the binary, not the process name. Check path, signature or package ownership and hash; a familiar name in an unusual folder is a classic warning sign.
- Every listener needs an owner and a reason. Use the CMDB and change records to find who runs it; no owner after a set period means restrict or remove.
- Baseline listeners and alert on drift. A per-role allow list of expected ports and binaries turns a manual hunt into an automated detection.
Confirm the listener
Start from the finding (a scan result, a vulnerability scanner plugin, an EDR alert or an audit) and record exactly what was observed: target IP, port, protocol, time and the scanning source. Then confirm it on the host.
- Check you are on the right host. Match the IP to the asset record. DHCP changes, NAT, load balancers and container hosts often mean the scanned IP is not the machine you think it is.
- Check the socket table. Use the commands below. A listener present in the table confirms the finding; if it is absent, check whether a port forward, load balancer, hypervisor or container runtime answered on the host's behalf.
- Note the bind address. 0.0.0.0 or :: means all interfaces; a specific interface address means only that network; 127.0.0.1 or ::1 means localhost only, so an external scanner should not have reached it.
- Check TCP and UDP. UDP listeners do not show a "LISTEN" state and are easy to miss.
- Preserve evidence if anything looks wrong. Save the command output with timestamps before changing anything. If the process looks malicious, stop and follow your incident process rather than killing it.
| OS | Command | What it shows |
|---|---|---|
| Linux | sudo ss -tulnp | TCP and UDP listening sockets, numeric, with owning process and PID (-e adds owning UID and inode) |
| Linux | sudo ss -ltnp 'sport = :8443' | Listeners on one port, using the ss filter syntax |
| Linux and macOS | sudo lsof -nP -iTCP -sTCP:LISTEN | Listening TCP sockets with command, PID and user; root is needed to see other users' processes |
| Linux and macOS | sudo lsof -nP -i :8443 | Any process using port 8443 |
| Windows (PowerShell) | Get-NetTCPConnection -State Listen | Select-Object LocalAddress, LocalPort, OwningProcess | Listening TCP sockets with the owning PID |
| Windows (PowerShell) | Get-NetUDPEndpoint | Select-Object LocalAddress, LocalPort, OwningProcess | UDP endpoints with the owning PID |
| Windows (cmd, elevated) | netstat -anob | All connections and listening ports, numeric, with PID and the executable that opened each one (-b needs elevation and can be slow) |
Running these commands on your own hosts is normal administration, but note that ATT&CK lists the same activity as T1049 System Network Connections Discovery when an intruder does it, so expect EDR tools to log it.
Map port to process and binary
A PID and a process name are a starting point, not an identification. Work from the PID to the executable on disk, then prove what that executable is.
Linux
- Executable path:
sudo ls -l /proc/<PID>/exeshows the binary the process is running, even if it was renamed. A target marked "(deleted)" means the file on disk was removed after start, which needs explaining. - Command line and parent:
ps -o pid,ppid,user,lstart,args -p <PID>gives the user, start time and full arguments; follow the parent PID to see what launched it. - Service unit:
systemctl status <PID>shows the systemd unit, if any, that owns the process, and the unit file location. - Package ownership:
rpm -qf <path>ordpkg -S <path>shows which package installed the file;rpm -Vf <path>ordpkg --verify <package>reports whether its files differ from the package database. - Containers: if the process runs in a container, identify the container and image and investigate at that level; the host binary will be the container runtime.
Windows
- Process and path:
Get-Process -Id <PID> | Select-Object Name, Path, StartTime. - Hosted services: many Windows services share
svchost.exe.tasklist /svc /fi "PID eq <PID>"orGet-CimInstance Win32_Service -Filter "ProcessId=<PID>"lists the services in that process. - Signature:
Get-AuthenticodeSignature -FilePath <path>returns the signature status and signer certificate; where a file is both embedded-signed and catalog-signed, the catalog signature is used. Sysinternals Sigcheck shows version, signature, certificate chain and hashes, and can check a hash against VirusTotal; it uploads the file only if the upload option is chosen, so avoid that for internal or sensitive binaries. - Kernel listeners: PID 4 (System) owning a port usually means a kernel-mode service such as HTTP.sys or SMB; use
netsh http show servicestateto see which applications registered HTTP.sys URLs.
Checks on every OS
| Check | Expected for a legitimate service | Warning sign |
|---|---|---|
| Path | Standard install location (Program Files, System32, /usr/bin, /usr/sbin, /opt/<vendor>) | Temp, Downloads, user profile, /tmp, /dev/shm, hidden directories |
| Signature or package | Valid signature from the expected publisher, or owned by an installed package with no verify differences | Unsigned, invalid or unexpected signer; file not owned by any package; verify differences |
| Hash | Matches the vendor's published hash or other hosts with the same build | Unique to this host |
| Parent and launch | Service manager (systemd, services.exe) or a known scheduler | Office apps, browsers, script hosts or a shell spawned by a web server |
| User | Dedicated service account with least privilege | root, SYSTEM or an interactive user for a network service that does not need it |
| Port | Documented port for that product | Common product name on an unusual high port (see ATT&CK T1571 Non-Standard Port) |
Identify the owner and purpose
Once you know the software, find who is accountable for it.
- Query the CMDB for the host's owner, application service and support group. Many CMDBs record installed software and expected ports per application; compare.
- Search change records for recent installs or configuration changes on the host or the application.
- Check deployment sources: configuration management code, golden images, container manifests and software distribution logs show whether the listener was deployed deliberately.
- Ask the named owner to confirm the purpose, the clients that need to connect and whether the listener needs to be reachable beyond the host.
- Record the answer against the asset, including the expected port, bind address and binary, so the next finding resolves itself.
Common outcomes include a vendor agent that opened a management port, a developer tool or database left running on a server, a debugging or profiling endpoint enabled in production, a remote support tool and a forgotten pilot. Where no owner is found within an agreed period (for example two working days), escalate to the system owner's manager and treat the listener as unauthorised. See the Asset Inventory and CMDB Security Guide for keeping these records trustworthy.
Assess risk
Score the listener on a few factors rather than on the port number alone. Port numbers are conventions; what matters is what answers and who can reach it.
| Factor | Lower risk | Higher risk |
|---|---|---|
| Reachability | Localhost only, or a management network with filtering | All interfaces on an internet-facing or flat network |
| Authentication | Strong authentication and encryption (for example mutual TLS or SSH keys) | No authentication, default credentials or a shared static API key |
| Privilege | Dedicated low-privilege service account | root or SYSTEM |
| Software state | Supported version, patched | End of life, unpatched or unknown version |
| Function | Read-only status or metrics | Remote administration, code execution, database or file transfer |
| Provenance | Signed, package-owned, deployed by change | Unsigned, unknown origin, no change record |
A listener that combines high-risk reachability with remote administration and no owner should be treated as a possible incident. Indicators such as an unknown binary, a deleted executable, unusual parent processes, or a service account credential found in its configuration all point the same way. The Network Ports and Protocols Security Guide lists ports that should never face the internet. Port knocking (ATT&CK T1205.001) can hide a listener until a trigger sequence arrives, so a host-side check is more reliable than an external scan alone.
Decide: keep, restrict or remove
| Situation | Decision | Actions |
|---|---|---|
| Owned, needed, verified binary, appropriate exposure | Keep | Record in the CMDB and the listener baseline; set a review date |
| Owned and needed, but wider exposure than necessary | Restrict | Bind to localhost or a specific interface; add host and network firewall rules limiting sources; require authentication and TLS |
| Owned, but not needed (feature enabled by default, finished pilot) | Remove | Disable or uninstall the service through change management; confirm the port is closed |
| No owner after the agreed period, binary verified as legitimate | Restrict, then remove | Block with the host firewall and notify; remove at the next change window if still unclaimed |
| Binary unverified or indicators of compromise | Incident | Isolate the host through EDR or network controls, preserve memory and disk evidence, follow the incident response plan; do not just kill the process |
For changes, use the normal change process: test in a non-production environment where one exists, notify the owner, make the change in a window, verify with the same socket command and an external scan, and keep a rollback (the previous service configuration or firewall rule) ready. Where an application turns out to rely on the listener, roll back, then restrict instead of remove. See Host Firewall vs Network Firewall for where to enforce restrictions.
Prevent surprises
- Baseline per role: keep an allow list of expected listeners per server role and image (port, protocol, bind address, binary path and signer). Build it from configuration management rather than from what is currently running.
- Collect listener inventory: schedule the socket queries above through your endpoint management or EDR tooling, or an endpoint query agent, and compare against the baseline.
- Windows audit events: enable the Audit Filtering Platform Connection subcategory (for example
auditpol /set /subcategory:"Filtering Platform Connection" /success:enable). Event 5154 records each time the Windows Filtering Platform permits an application to listen, with process ID (in hexadecimal), application path, local address, port and protocol. Microsoft recommends alerting on listeners not on an allow list and on applications outside standard folders. The volume can be high, so filter to servers or forward selectively, and correlate with process creation event 4688. - External view: scan your own internet-facing ranges on a schedule and reconcile every open port with a CMDB record. See the Attack Surface Management Guide.
- Default deny: host firewalls with inbound default deny on servers and endpoints mean a new listener is unreachable until someone opens it deliberately.
- Remove unneeded services: build images with only required services enabled, in line with CIS Controls v8.1 Safeguard 4.8 (Uninstall or Disable Unnecessary Services on Enterprise Assets and Software) and NIST SP 800-53 CM-7 Least Functionality.
- Credentials on listeners: services that accept connections often authenticate clients with API keys, tokens or service account passwords. Record those non-human credentials against the service owner so they are rotated or revoked when the listener is retired. See the NHI Ownership Guide.
Measuring it
| Metric | What it shows |
|---|---|
| Listeners not in the baseline, per week | Drift and control effectiveness |
| Median time from finding to decision | Investigation speed |
| Share of listeners with a recorded owner | Asset record quality |
| Internet-reachable listeners without a CMDB record | Highest-risk exposure |
| Findings that became incidents | True positive rate and threat level |
Framework mapping
| Activity | NIST SP 800-53 Rev. 5 | NIST CSF 2.0 | ATT&CK / D3FEND |
|---|---|---|---|
| Inventory of services and owners | CM-8 System Component Inventory | ID.AM-01 | None mapped |
| Baseline of expected listeners | CM-2 Baseline Configuration; CM-6 Configuration Settings | PR.PS-01 | D3-NTPM Network Traffic Policy Mapping |
| Disable unneeded services | CM-7 Least Functionality | PR.PS-01 | None mapped |
| Restrict exposure | SC-7 Boundary Protection | None mapped | None mapped |
| Monitor for new listeners | SI-4 System Monitoring | DE.CM-01, DE.CM-09 | T1571 Non-Standard Port; T1205.001 Port Knocking; T1543 Create or Modify System Process |
Practitioner checklist
- Record the original finding: IP, port, protocol, time and scan source.
- Confirm the listener and bind address on the host for both TCP and UDP.
- Map the PID to the executable path, parent, user and service unit or Windows service.
- Verify the binary by signature or package ownership and by hash.
- Find the owner through the CMDB and change records and confirm the purpose.
- Score the risk on reachability, authentication, privilege, software state, function and provenance.
- Record a keep, restrict, remove or incident decision with a review date.
- Add kept listeners to the per-role baseline and alert on anything outside it.
- Enable Windows event 5154 auditing on servers and correlate with 4688.
Standards and references
- Linux man-pages: ss(8)
- Linux man-pages: lsof(8)
- Microsoft Learn: Get-NetTCPConnection
- Microsoft Learn: netstat
- Microsoft Learn: Event 5154 The Windows Filtering Platform has permitted an application or service to listen on a port
- Microsoft Learn: Get-AuthenticodeSignature
- Microsoft Sysinternals: Sigcheck
- CIS: Control 4 Secure Configuration of Enterprise Assets and Software
Related NHI Mgmt Group resources: Network Ports and Protocols Security Guide · Asset Inventory and CMDB Security Guide · Host Firewall vs Network Firewall · Attack Surface Management Guide