Skip to main content

Beginner-Friendly Topic

Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!

Lesson 6 of 11

Common Ports, Services & Attack Surface

Every open port on a system is a potential entry point for attackers. Security professionals must know the standard port-to-service mapping to identify unexpected services, understand firewall rules, and read security scan reports.

40 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

Critical Ports Security Map

Critical Ports Security Map
Port  | Protocol | Service     | Security Risk
------|----------|-------------|------------------------------------------
21    | TCP      | FTP         | Cleartext credentials - use SFTP instead
22    | TCP      | SSH         | Brute force target - restrict, use keys  
23    | TCP      | Telnet      | NEVER use - cleartext, replace with SSH
25    | TCP      | SMTP        | Email relay - restrict to authorized IPs
53    | TCP/UDP  | DNS         | DDoS amplification, tunneling, poisoning
80    | TCP      | HTTP        | Cleartext - redirect all to HTTPS (443)
443   | TCP      | HTTPS       | Secure web - ensure TLS 1.2+ only
3306  | TCP      | MySQL       | Database - NEVER expose to internet
3389  | TCP      | RDP         | Ransomware entry point - restrict access
5432  | TCP      | PostgreSQL  | Database - internal network only
6379  | TCP      | Redis       | Often exposed without auth - critical!
8080  | TCP      | HTTP-alt    | Dev servers, proxy - avoid in production
27017 | TCP      | MongoDB     | Exposed MongoDB = guaranteed breach
11211 | TCP/UDP  | Memcached   | DDoS amplification source

Real-World Exposed Service Breaches

  • MongoDB: Over 27,000 MongoDB databases were discovered exposed to the internet without authentication in 2017 - ransomware groups wiped and extorted within hours
  • Redis: Exposed Redis instances (default: no auth) allow attackers to write SSH keys to the root user's authorized_keys file - achieving code execution without exploiting any vulnerability
  • RDP (Port 3389): The primary entry point for most enterprise ransomware attacks - brute-forced or accessed via stolen credentials. Always restrict RDP to VPN or specific IP ranges
  • Memcached (Port 11211): Abused in the GitHub DDoS (2018) for reflection amplification - small UDP request returns up to 50KB response; amplification factor 51,000x

Minimizing Attack Surface

  • Default deny: Block all ports by default - only open what is explicitly required for business operations
  • Service inventory: Know every service running on every system - unknown services are a red flag
  • Unnecessary service removal: Disable FTP, Telnet, rsh, rexec and any legacy service not in use
  • Internal services never exposed: Databases (MySQL, PostgreSQL, Redis, MongoDB) should have no path from the internet - access only via VPN or application servers
  • Regular port scans on your own infrastructure: Run nmap against your own perimeter monthly to identify unauthorized exposed services

Common Mistakes

  • Exposing databases directly to the internet - even with strong passwords, databases should never be internet-facing
  • Leaving development ports open in production (8080, 8443, 3000) - expose technical stack and may run with debug-mode vulnerabilities
  • Not auditing firewall rules regularly - rules accumulate over time; old rules for decommissioned services create forgotten open doors

Tip

Tip

Practice Common Ports Services Attack Surface in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.

Diagram
Loading diagram…

The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).

Practice Task

Note

Practice Task - (1) Write a working example of Common Ports Services Attack Surface from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.

Quick Quiz

Common Mistake

Warning

A common mistake with Common Ports Services Attack Surface is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.

Key Takeaways

  • Every open port on a system is a potential entry point for attackers.
  • MongoDB: Over 27,000 MongoDB databases were discovered exposed to the internet without authentication in 2017 - ransomware groups wiped and extorted within hours
  • Redis: Exposed Redis instances (default: no auth) allow attackers to write SSH keys to the root user's authorized_keys file - achieving code execution without exploiting any vulnerability
  • RDP (Port 3389): The primary entry point for most enterprise ransomware attacks - brute-forced or accessed via stolen credentials. Always restrict RDP to VPN or specific IP ranges

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/11 done