Security · · The Wafflr team

Is your PBX exposed to the internet? A ten-minute check

A padlock in the live pocket of a three by three waffle grid

A PBX exposed to the internet can be found by the automated scanners that look for phone systems, web consoles and remote logins, and a system that is found gets probed. To check whether yours is, look at it from outside: scan your public address from a network that is not yours and see which ports answer. The ten-minute check below shows what a stranger can see, which answers are acceptable and what to change when they are not.

What you need before you start

  • A computer on a different network. A phone's mobile hotspot works, and so does a small cloud server. Scanning from inside your own network tests the inside, which is not what the internet sees.
  • Your public address. For a system behind a router it is the address of your internet connection, which any "what is my IP" page shows from inside the network. If the phone system has its own public address, or an IPv6 address, test that too.
  • A scanning tool. The commands below use nmap, which is free and runs on Windows, macOS and Linux. A scan of UDP ports needs administrator or root rights.
  • Permission. Scan only addresses you own or are authorised to test. If your phone system is hosted by someone else, ask first, because their terms may forbid scanning.

The ten-minute check for a PBX exposed to the internet

Replace ADDRESS with your public address in each command.

  1. Scan the ports a phone system and its server tend to leave open. The -Pn option stops nmap from skipping a host that does not answer pings, which firewalls often drop.

    nmap -Pn -p 22,80,443,1433,3306,3389,5038,5060,5061 ADDRESS
    
  2. Ask the SIP port a SIP question. UDP scans are unreliable because a silent port can be open or filtered, and nmap reports it as open|filtered. A SIP request settles it, because a SIP server answers.

    nmap -Pn -sU -p 5060 --script sip-methods ADDRESS
    
  3. Check the encrypted SIP port. This asks the port for its certificate, and an expiry date in the answer is useful too.

    nmap -Pn -sV -p 5061 --script ssl-cert ADDRESS
    
  4. Repeat for IPv6 if the system has a public IPv6 address, adding -6 to each command.

  5. Look at your own logs. A SIP server that answers anyone shows failed registration and call attempts from addresses you do not recognise. A steady stream of them over the last day means the port is exposed and has been found.

How to read the results

Port What it usually is Should the internet reach it?
22 Remote login to a Linux server No. Use a VPN, or allow only the addresses that administer it
3389 Windows Remote Desktop No. Put it behind a VPN or a remote access gateway
1433, 3306 A database (SQL Server, MySQL or MariaDB) Never
5038 The Asterisk manager interface No
80, 443 The administration console, the web phone or the provisioning address The console, no. Provisioning only if phones outside the office need it, and then restricted
5060 SIP, unencrypted Only from the addresses that need it: your carrier and any remote phones
5061 SIP over TLS The same, and preferred to 5060

An answer from a port that should be closed is the finding. An open|filtered from UDP 5060 with no answer to the SIP request is a pass, and a closed port is a pass.

What to do with each answer

  • Close management ports to the world. Reach the console and remote login through a VPN, or allow only the fixed addresses of the people who administer the system.
  • Allow SIP only from who needs it. If a carrier authenticates you by address, allow its addresses and nothing else. If your phone system registers out to the carrier, no one needs to reach port 5060 from the internet at all, because the replies come back through the connection the system opened.
  • Remote phones are the hard case. Use encrypted signalling and audio, strong credentials that are different for every device, and a limit on failed attempts that bans an address after a few. A VPN or a session border controller at the edge keeps the phone system itself out of sight.
  • Change every default. A default password on a console or an extension that is reachable is the first thing a scanner tries.
  • Limit what a stolen extension can do. Barring international and premium-rate numbers for anyone who does not need them caps the damage if one is found. The post on how to prevent toll fraud has the whole list, in order of cost.
  • Scan again after any firewall or router change. A rule added to fix a fault tends to stay long after the fault is gone.

Questions people ask

Is a closed port 5060 enough to be safe?

It is good, but a UDP scan alone cannot prove it, which is why step 2 sends a real SIP request. Also check TCP and TLS, where SIP may be listening on a different port than the standard one.

Do I have to open SIP to the internet to use a SIP trunk?

Not always. If the phone system registers out to the carrier, it opens the connection and the replies come back through it, so no inbound SIP port needs to face everyone. If the carrier recognises you by your address, you allow the carrier's addresses and no others. Your carrier's documentation says which applies, and the guide to SIP registration failures explains what the responses mean when a registration is refused.

You may test a system you own, or one you have written permission to test. Do not scan addresses that are not yours, and ask a hosting provider before scanning anything it runs.

In Wafflr

Wafflr is in development and has not launched, so this section describes its console as it is being built. Its draft installation guide lists the ports a site opens: 5060 over UDP for SIP, 5061 over TCP for SIP over TLS, 443 over TCP for the console and the signalling of the browser softphone, and 16384 to 32768 over UDP for audio, and says who needs to reach each one. Each extension has a class of service that says which kinds of number it may dial. A toll-fraud watch suspends an extension that passes its spending limits, alerts can be sent by email or to an HTTPS address, and the audit trail records every change to the configuration with the account that made it. The toll fraud guide describes each of these, and the post on inheriting a phone system puts this scan on the list of first-week jobs.