Beginner·14 min read·Updated 2026-10-15

Open Port Security Audit: Attack Surface Discovery & Remediation

Original WeSecureX guide for authorized testing of sites you own. Linked Sources are citations for verification - not copied articles. Ads are not served on this page.

Every network service running on a web server listens for incoming connections on a specific TCP or UDP port. While web servers intentionally expose port 80 (HTTP) and port 443 (HTTPS) to the public internet, development oversights and cloud security group misconfigurations frequently leave sensitive administrative and database ports exposed directly to the outside world. Automated mass-scanning botnets continuously sweep IPv4 and IPv6 address ranges seeking exposed database engines (MySQL on port 3306, PostgreSQL on port 5432, Redis on port 6379, MongoDB on port 27017), remote management interfaces (SSH on port 22, RDP on port 3389), and internal debug interfaces (Kubernetes Kubelet on port 10250). Discovering an unauthenticated database or legacy service exposed to the internet represents an immediate path to enterprise data compromise. This comprehensive guide details port scanning methodologies, dangerous port signatures, and firewall hardening using the [WeSecureX Open Port Scanner](/tools/open-port-scanner) and [Attack Surface Reconnaissance Tool](/surface).

Quick Answer

Audit and secure open ports by adopting a Default-Deny firewall policy: restrict public internet ingress exclusively to ports 80 and 443, bind internal services (Redis, databases) strictly to `127.0.0.1` or private VPC subnets, require encrypted VPNs or SSH bastions with key-based authentication for management, and automate port scanning using WeSecureX.

Key Takeaways
  • Public web servers should only expose port 80 (HTTP) and port 443 (HTTPS) to the public internet.
  • Exposed databases (Redis, MongoDB, MySQL) are the leading cause of automated ransomware incidents.
  • Docker routinely bypasses Linux UFW rules unless ports are explicitly bound to localhost.
  • Continuous external port scanning is required to detect configuration drift and rogue open services.
Visual Diagram · Public Internet Perimeter vs. Hardened Private VPC Architecture
1

1. Internet Ingress

Public visitors, automated port scanners, and malicious adversaries probe public server IP addresses.

2

2. Edge Cloud Firewall

Security groups allow only ports 80/443; all other TCP/UDP ingress traffic is silently dropped.

3

3. Reverse Proxy Gateway

Nginx or an Application Load Balancer terminates TLS and forwards requests into private subnets.

4

4. Isolated Backend Tier

Databases (PostgreSQL, Redis) listen exclusively on private VPC interfaces with zero public IP exposure.

ShareShare on XLinkedIn

1. High-Risk Open Ports & Common Service Exploitation Vectors

WeSecureX Attack Surface Reconnaissance detecting exposed ports and unauthorized network services
WeSecureX Attack Surface Reconnaissance detecting exposed ports and unauthorized network servicesWeSecureX Platform View

Understanding network attack surfaces begins with categorizing which ports must remain public and which represent severe security liabilities when exposed. Web applications require port 80 (for HTTP redirection) and port 443 (for TLS encrypted HTTPS). Any additional open port exposed to 0.0.0.0/0 widens your attack perimeter and introduces potential zero-day vulnerabilities.

Database Services (Ports 3306, 5432, 6379, 27017, 9200): Databases are engineered for private network communication between application workers and storage engines; they are never designed to face the public internet. Redis, by default, is packaged with zero authentication, assuming it operates within a trusted private environment. An exposed Redis instance allows an attacker to dump all cached sessions, write arbitrary SSH keys to the server disk via the CONFIG SET dir command, and gain complete root remote code execution. Similarly, exposed Elasticsearch and MongoDB instances have fueled thousands of catastrophic ransomware incidents where automated scripts discover open databases, exfiltrate the data, and drop ransom notes.

Remote Management (Ports 22, 3389): Exposing SSH (22) or Windows Remote Desktop (3389) directly to the public internet subjects authentication daemons to millions of automated brute-force attempts per day. If a developer uses a weak password or an unpatched OpenSSH vulnerability emerges, the server is compromised instantly. Management ports must always be shielded behind VPNs or zero-trust identity-aware proxies. Discover how attackers leverage perimeter reconnaissance in our Attack Surface Management Guide and test your public IP right now using the Free Open Port Scanner.

Port NumberDefault ServiceAssociated Security RiskHardening Recommendation
21FTP (File Transfer)Transmits credentials and files in unencrypted cleartextDecommission FTP; migrate to SFTP (SSH) or private S3 buckets
22SSH (Secure Shell)Subject to brute-force credential stuffing and zero-day SSH exploitsRestrict to VPN/bastion IPs; disable password auth; use ed25519 keys
23TelnetLegacy cleartext remote management terminalDisable immediately; zero legitimate modern use cases
3306MySQL DatabaseExposes database to brute-force and remote query exploitationBind to 127.0.0.1; isolate inside private VPC subnet
5432PostgreSQLSubject to unauthorized connection attempts and denial of serviceBind to 127.0.0.1; allow access only via authorized VPC security group
6379Redis In-Memory StoreFrequently unauthenticated; allows arbitrary remote file writing / RCEBind to localhost; configure strong password; never expose publicly
27017MongoDBHigh risk of automated ransomware wiping and data breachesEnable authentication; isolate in private network
3389RDP (Windows Remote Desktop)High-value target for ransomware gangs and brute-force toolsPlace behind Azure Bastion, AWS Systems Manager, or corporate VPN

2. Firewall Architecture & Host Hardening Workflows

WeSecureX Free Tools Directory providing network and infrastructure security checkers
WeSecureX Free Tools Directory providing network and infrastructure security checkersWeSecureX Platform View

Securing your server infrastructure against port exposure requires implementing a layered defense combining host-level firewalls, cloud provider security groups, and service binding configurations.

1. Host-Level Service Binding: Never configure services to listen on wildcard addresses (0.0.0.0 or ::) unless they explicitly serve public web traffic. In database configuration files (such as /etc/mysql/mysql.conf.d/mysqld.cnf or /etc/redis/redis.conf), explicitly set bind 127.0.0.1. When a service is bound exclusively to the loopback interface, external network packets cannot establish a connection, even if the firewall is accidentally misconfigured.

2. Default-Deny Firewall Configuration: On Linux servers, configure Uncomplicated Firewall (ufw) or nftables to adopt a strict Default-Deny posture. Block all incoming connections by default, and explicitly allow only ports 80 and 443. If SSH access is required, restrict ingress rules to static office IP addresses or configure SSH port knocking and WireGuard VPN tunnels.

3. Cloud Security Groups (AWS / GCP / Azure): In cloud environments, cloud security groups operate outside the virtual machine operating system, discarding unauthorized traffic before it consumes server network bandwidth. Verify that all database security groups allow inbound connections exclusively from the security group ID of your application servers, with zero ingress rules pointing to 0.0.0.0/0. Verify your SSL/TLS configurations on open web ports using our SSL Certificate Checker.

bash
# Linux Host Hardening with UFW (Uncomplicated Firewall)
# 1. Set strict default policies: Deny all incoming, allow outgoing
$ sudo ufw default deny incoming
$ sudo ufw default allow outgoing

# 2. Allow standard web traffic
$ sudo ufw allow 80/tcp comment 'HTTP Web Traffic'
$ sudo ufw allow 443/tcp comment 'HTTPS Encrypted Web Traffic'

# 3. Restrict SSH (Port 22) exclusively to trusted corporate IP
$ sudo ufw allow from 203.0.113.50 to any port 22 proto tcp comment 'Corporate VPN SSH'

# 4. Enable firewall and verify status
$ sudo ufw enable
$ sudo ufw status verbose

3. Automated Perimeter Discovery with WeSecureX Scanner

WeSecureX Website Scanner discovering open ports and analyzing perimeter attack surfaces
WeSecureX Website Scanner discovering open ports and analyzing perimeter attack surfacesWeSecureX Platform View

Manual firewall reviews cannot detect unauthorized ports introduced by container orchestration tools, Docker port mappings, or temporary developer testing rules. When developers launch a container with docker run -p 8080:8080, Docker automatically manipulates iptables rules on Linux hosts, often completely bypassing user-configured UFW firewall rules and exposing the container port directly to the public internet.

The WeSecureX Open Port Scanner and Website Security Scanner continuously probe your public IP addresses and domain names across the top 1,000 most frequently exploited TCP and UDP ports. The scanner identifies active listening services, captures service banners, detects outdated software versions, and flags critical vulnerabilities like unauthenticated databases and exposed administrative consoles.

Take control of your external attack surface by auditing your domain with the Free Open Port Scanner, checking your subdomains with the Subdomain Finder, and learning how continuous testing protects modern applications in our Shift to Continuous Testing Guide.

bash
# Running an automated port audit via WeSecureX CLI
$ wesecurex port-scan --target example.com --top-ports 1000

[INFO] Resolving example.com -> 198.51.100.25...
[SCAN] Probing top 1000 TCP ports for open listening services...
[PASS] Port 80/tcp   OPEN  (nginx 1.24.0 - HTTP)
[PASS] Port 443/tcp  OPEN  (nginx 1.24.0 - HTTPS / TLS 1.3)
[WARN] Port 22/tcp   OPEN  (OpenSSH 8.9p1 - SSH)
[ALERT] Port 6379/tcp OPEN (Redis 7.0.5 - NO AUTH REQUIRED!)
[CRITICAL] High Severity Finding: Unauthenticated Redis database exposed to public internet!
[REMEDY] Immediately bind Redis to 127.0.0.1 and close port 6379 in cloud security group.

Apply it with WeSecureX

Add a hostname you own or are allowed to test, run a scan, and open the findings for that target. A confirmed result includes the request WeSecureX sent and the response the site returned, so you can reproduce it, fix it in your own application, and rescan the same host to confirm the issue is gone. WeSecureX is automated testing, not a manual penetration test, and a clean report is not a promise that every weakness is gone.

Checks that belong with this topic

  • Enforce a strict Default-Deny firewall rule on all public server interfaces.
  • Bind all internal databases and caches (MySQL, PostgreSQL, Redis) strictly to `127.0.0.1`.
  • Ensure Docker container port mappings explicitly specify `127.0.0.1:<port>:<port>`.
  • Protect SSH and administrative management interfaces behind corporate VPNs or IP whitelists.
  • Continuously scan public IP ranges using the WeSecureX Open Port Scanner.

Common Mistakes to Avoid

❌Assuming Docker respects UFW firewall rules on Linux hosts

Why it happens: Docker by default modifies `iptables` directly to route container traffic, bypassing standard UFW rules.

Why it matters: Publishing a port with `docker run -p 3306:3306` exposes MySQL to the entire internet even if UFW is configured to block port 3306.

Correct approach: Explicitly bind Docker ports to localhost: `docker run -p 127.0.0.1:3306:3306` or configure Docker with `--iptables=false`.

❌Leaving database ports open during development and forgetting to close them before production

Why it happens: Developers open port 5432 or 27017 to connect from local GUI clients (TablePlus, DBeaver) during initial setup.

Why it matters: Automated scanner bots detect exposed databases within hours, leading to automated ransomware attacks and data extortion.

Correct approach: Connect to remote development databases using SSH tunneling (`ssh -L 5432:localhost:5432`) rather than opening firewall ports.

❌Changing default port numbers (e.g., SSH to 2222) and assuming the service is secure

Why it happens: Teams practice 'security through obscurity', believing attackers only scan standard port numbers.

Why it matters: Modern port scanners (like Masscan or Nmap) scan all 65,535 ports in seconds and inspect service banners to identify the daemon.

Correct approach: Rely on cryptographic authentication, IP whitelisting, and VPN access controls rather than obscure port numbers.

❌Auditing IPv4 firewall rules while leaving IPv6 completely unshielded

Why it happens: Engineers configure security groups and firewalls for IPv4 addresses without realizing the host has an active public IPv6 interface.

Why it matters: Attackers scan IPv6 ranges and connect directly to internal services that were only blocked on the IPv4 firewall.

Correct approach: Apply identical firewall filtering policies across both IPv4 (`iptables`) and IPv6 (`ip6tables`).

Troubleshooting Guide

Problem: A port scanner reports a port as 'Filtered' instead of 'Closed' or 'Open'

Possible Causes:

  • A firewall or packet filter dropped the probe packet without returning an ICMP unreachable or TCP RST packet.

How to verify: Run `nmap -Pn -p <port> <target>` to inspect TCP SYN/ACK behavior.

How to fix: This is the desired behavior for a hardened firewall; 'Filtered' indicates that unauthorized packets are being silently dropped.

Problem: A service is running on the server but external clients cannot connect

Possible Causes:

  • The daemon is bound to `127.0.0.1` (localhost only) rather than the external or private network interface.
  • An upstream cloud provider security group is blocking the traffic.

How to verify: Run `ss -tlpn` or `netstat -tlpn` on the server to inspect the listening IP address.

How to fix: If external access is required, bind the service to the server's private VPC IP address and whitelist client IPs in your cloud firewall.

Problem: WeSecureX alerts on an exposed port that was supposed to be closed

Possible Causes:

  • A recent container deployment or cloud orchestration script modified security group ingress rules.

How to verify: Inspect the AWS EC2 security group or run `sudo iptables -L -n -v` on the host to trace the open rule.

How to fix: Remove the offending 0.0.0.0/0 ingress rule from the security group and enforce Infrastructure as Code (IaC) configuration drift detection.

Actionable Checklist

WeSecureX Platform · Scanner Engine

Automated Vulnerability Scanner

Launch targeted or full-domain security audits to detect OWASP Top 10 vulnerabilities automatically.

Includes: OWASP Top 10 automated test suites · Real-time severity scoring (CVSS v3.1) · Instant remediation code snippets

Frequently Asked Questions

Exposing SSH publicly subjects your authentication daemon to constant credential stuffing and brute-force attacks from global botnets. If an unpatched zero-day vulnerability in OpenSSH is discovered, attackers can exploit it without needing valid credentials.

An 'Open' port has an active service listening and accepting connections. A 'Closed' port has no service listening, but the host returns a TCP RST packet. A 'Filtered' port has a firewall dropping packets, preventing scanners from determining if a service exists.

Use SSH Port Forwarding (SSH tunneling) or a private VPN. For example: `ssh -L 5432:localhost:5432 user@server.com` securely tunnels database traffic over an encrypted SSH connection without exposing port 5432 publicly.

Authoritative Sources & References

  • NIST SP 800-41 Rev. 1: Guidelines on Firewalls and Firewall PolicyNIST (official)
    View Source
  • CIS Benchmarks for Network Security & Firewall HardeningCIS (official)
    View Source

Continue exploring related technical architecture and defensive guides

Security Research & Engineering Articles

All articles