Common attacks and weaknesses
- Passwords sniffable on the network.
- Anonymous login exposing or accepting files.
- Old servers with backdoors or traversal bugs (vsftpd 2.3.4, ProFTPD mod_copy).
Legacy file transfer control channel. Credentials and files travel in clear text unless FTPS is used.
Files are sent over port 21 in pieces and reassembled on the other side. Encryption is optional: it only happens if both sides negotiate TLS (STARTTLS).
| Service | Port | Transport | Description | Reference | Updated |
|---|---|---|---|---|---|
| ftp | 21 | TCP, UDP, SCTP | File Transfer Protocol [Control] | RFC 959 | - |
// source: IANA service name and port number registry
Linux
sudo ss -ltnup 'sport = :21' # process listening on 21
sudo lsof -nP -i :21macOS
sudo lsof -nP -i :21
Windows (PowerShell)
Get-NetTCPConnection -LocalPort 21 -State Listen | Select LocalAddress, OwningProcess Get-NetUDPEndpoint -LocalPort 21 netstat -ano | findstr :21
From another machine
nmap -p 21 -sV <host> sudo nmap -sU -p 21 <host> nc -zv <host> 21
Block it in the firewall
sudo ufw deny 21/tcp # Linux (ufw) New-NetFirewallRule -DisplayName "Block 21" -Direction Inbound -LocalPort 21 -Protocol TCP -Action Block # Windows
Legacy file transfer control channel. Credentials and files travel in clear text unless FTPS is used.
Port 21 is registered for TCP and UDP and SCTP. In practice the service mostly uses TCP.
It is rated 7/10 (high) when exposed to the Internet. Passwords sniffable on the network. Replace with SFTP (port 22) or FTPS.
On Linux run "ss -ltnup 'sport = :21'", on macOS "lsof -nP -i :21", and on Windows "netstat -ano | findstr :21" to see the local process. From another machine, "nmap -p 21 <host>" shows whether it is reachable.