 Reviews:
·Velcom
·TekSavvy Cable
·Rogers Hi-Speed
·Bell Sympatico
·voip.ms
| [Asterisk] FreePBX a couple of security questions I just installed FreePBX on a new (to me) machine, played with it for a bit, but now I wanna set it up so it's available to client devices outside the LAN without leaving my behind exposed. They will sound basic and stupid to some and I should have known #1 before, but I never had a reason to need it.
Let's start with remote administration as it's where I got to now (even though I will go over some hardening cookbooks and post more in this thread) and might come in useful if I deploy an appliance in my dad's office (overseas).
1) I am assuming that I would keep the listen ports for http/https as they are, open a random port like 11546 in the external firewall and forward it to internal port 443 for the machine and forward nothing to 80? [yeah yeah, basic fw config question, by the time I needed it, I was too proud to ask but even I am not THAT stupid not to ask now]
2) They keep talking about changing the default webmin port to 10000, but I couln't dig anything up on that, at least for FreePBX 2.9.0.9. Am I missing something or is the wiki information outdated? I tried looking for the config file elsewhere and couldn't find it, so I am assuming all of that goes through httpd? I don't see anything listening on 10000 when I run netstat -tna
Ok off to shut down the machine as I've played enough with it for today and will need the desk space for work tomorrow. -- If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas. George Bernard Shaw |
|
 Reviews:
·Velcom
·TekSavvy Cable
·Rogers Hi-Speed
·Bell Sympatico
·voip.ms
| Played with it some more.. Yeah, I'm bad lol.. Disabled root login via ssh (figured that would also be a good security tweak before looking into the cookbooks). That brings a couple more questions.
3) Is there a firewall package that I can use instead of IPTABLES that is a bit less cumbersome and easier to tweak (for example by editing config files)? A front end will also do.
4) What's your take on webmin? Helpful or a liability?
5) Any recommendations on security hardening cookbooks for a pbx? -- If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas. George Bernard Shaw |
|
 | I would put the freepbx box behind a real firewall and forward whatever ports you need (protected by the appropriate restrictions.) |
|
 XCOMdigitalnUllPremium join:2002-06-10 Spring, TX | reply to FiReSTaRT Everything you need to know about asterisk plus more.
»ofps.oreilly.com/titles/97805965···dex.html -- [nUll@dcypher ~]$ |
|
 Reviews:
·Velcom
·TekSavvy Cable
·Rogers Hi-Speed
·Bell Sympatico
·voip.ms
| reply to druber said by druber:I would put the freepbx box behind a real firewall and forward whatever ports you need (protected by the appropriate restrictions.) That's a given but there has been some talk of also running a local firewall mostly to keep it protected from security breaches within the LAN.
said by XCOM:Everything you need to know about asterisk plus more.
»ofps.oreilly.com/titles/97805965···dex.html Thanks. I read it a while back, but it's a good idea to re-read it.. Already got some good suggestions 30sec after I clicked on the Security link -- If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas. George Bernard Shaw |
|
 XCOMdigitalnUllPremium join:2002-06-10 Spring, TX Reviews:
·SIPBRI
·Callcentric
·Comcast
·voip.ms
| said by FiReSTaRT:said by druber:I would put the freepbx box behind a real firewall and forward whatever ports you need (protected by the appropriate restrictions.) That's a given but there has been some talk of also running a local firewall mostly to keep Nothing wrong with that. I run my asterisk setup behind pfsense with the ports forward it to the asterisk server. Than at the asterisk server i filter what allow in and out along with dban so it's completely doable. -- [nUll@dcypher ~]$ |
|
 maziloFrom MaziloPremium join:2002-05-30 Lilburn, GA kudos:1 | reply to FiReSTaRT said by FiReSTaRT:I just installed FreePBX on a new (to me) machine, played with it for a bit, but now I wanna set it up so it's available to client devices outside the LAN without leaving my behind exposed. In this case, perhaps you may wanna introduce a layer protection using a session border controller (SBC), i.e. OpenSBC, etc., to protect your IP PBX System. -- don't and stop are the ONLY two 4-letter words considered offensive to men, but not when used together. |
|
 espaethDigital PlumberPremium,MVM join:2001-04-21 Minneapolis, MN kudos:2 Reviews:
·Clear Wireless
| reply to FiReSTaRT said by FiReSTaRT:3) Is there a firewall package that I can use instead of IPTABLES that is a bit less cumbersome and easier to tweak (for example by editing config files)? A front end will also do. Iptables is the front-end for the NetFilter firewall in the Linux kernel. You normally edit a file stored in the /etc directory structure for setting which rules are applied automatically on restart. For instance, on RedHat-based distros that file is /etc/sysconfig/iptables
said by FiReSTaRT:4) What's your take on webmin? Helpful or a liability? Helpful on a LAN when you're just learning how Linux works, but a massive liability on nearly all instances when exposed to a public network.
said by FiReSTaRT:5) Any recommendations on security hardening cookbooks for a pbx? It's really pretty straight forward:
1) Don't create extensions with default / easy passwords. All passwords should be hard to guess, which means choose long passwords and don't worry about special characters. See: »xkcd.com/936/
2) Make sure to set alwaysauthreject and follow one of the many examples out there on how to setup fail2ban for Asterisk.
3) For iptables, start out by only opening the ports you define for the RTP port range in rtp.conf. For example, if you set:
rtpstart=18510 rtpend=18536
then your iptables rule entry would consist of:
-A INPUT -p udp --dport 18510:18536 -j ACCEPT
Always follow the practice of opening up only the ports you absolutely need to, and never any more. |
|
 Reviews:
·Velcom
·TekSavvy Cable
·Rogers Hi-Speed
·Bell Sympatico
·voip.ms
| Thanks guys. It looks like I'm slowly getting there. Experienced GNU/Linux desktop user, but I haven't administered anything open to the Internet so far and am still dependent on many gui tools. Thanks for the config file location. All of the iptables for dummies pages I came across just involved setting up iptables directly in the CLI without any mention of editing config files. Looks like I missed some lol.
One big deal that I'm also missing is changing the SIP usernames (they currently are the x numbers lol). I think I got all of the default passwords out of the way, but my system is nowhere near ready for live testing. -- If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas. George Bernard Shaw |
|
 Reviews:
·Velcom
·TekSavvy Cable
·Rogers Hi-Speed
·Bell Sympatico
·voip.ms
| said by FiReSTaRT:One big deal that I'm also missing is changing the SIP usernames (they currently are the x numbers lol). I think I got all of the default passwords out of the way, but my system is nowhere near ready for live testing. Ok, I'm unable to figure out how to make this happen.. Any ideas other than creating an extension and manually editing the config file? -- If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas. George Bernard Shaw |
|
 | I just found out that FreePBX doesn't allow a different SIP usernames other than the extension numbers. What are your thoughts on the sufficiency of having alwaysauthreject=yes as a security measure for this issue (along with strong passwds)? |
|
|
|
 XCOMdigitalnUllPremium join:2002-06-10 Spring, TX Reviews:
·SIPBRI
·Callcentric
·Comcast
·voip.ms
| reply to FiReSTaRT You dont allow anything to be fully open to the internet. Just forward the required ports to your asterisk server and than let that server handle the security appropriately. My server only talks to callcentric and voip.ms any body out side of that will get drop silently.
Extension numbers are not usernames. You should never use your extension numbers as user names. I use mac addresses as my device names.
alwaysauthreject=yes is all ways a good idea to use unless you like your phones to be ringing when been probe.... strong passwords are a must. -- [nUll@dcypher ~]$ |
|
 espaethDigital PlumberPremium,MVM join:2001-04-21 Minneapolis, MN kudos:2 Reviews:
·Clear Wireless
| reply to FiReSTaRT
said by FiReSTaRT:What are your thoughts on the sufficiency of having alwaysauthreject=yes as a security measure for this issue (along with strong passwds)? It's a start, but even setting this will still let an attacker have an unlimited number of attempts at your extensions unless you also setup fail2ban.
Also, don't allow any more access to your system than is absolutely needed. A basic iptables setup would look something like this:
*filter
:FORWARD DROP [0:0]
:INPUT DROP [0:0]
:OUTPUT DROP [0:0]
-A INPUT -i eth0 -p udp --dport 5060 -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -i eth0 -p udp --dport 5060 -m string --string "REGISTER sip:yourpbx.dns.name" --algo bm -j ACCEPT
-A INPUT -i eth0 -p udp --dport 5060 -j DROP
-A INPUT -i eth0 -p udp --dport 16828:16934 -j ACCEPT <-- SET YOUR RTP RANGE HERE
-A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -d 127.0.0.0/255.0.0.0 -j DROP
-A INPUT -p icmp -m state --state NEW --icmp-type 8 -j ACCEPT
-A INPUT -p tcp -s 1.2.3.4 -m state --state NEW --dport 22 -j ACCEPT <--- Set a trusted IP to access the box only
-A INPUT -p tcp -s 1.2.3.4 -m state --state NEW --dport 80 -j ACCEPT <--- Same for the web interace, ideally this should be 443/HTTPS
-A INPUT -i eth0 -p tcp -j REJECT --reject-with tcp-reset
-A INPUT -i eth0 -p udp -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -d 127.0.0.0/255.0.0.0 -j DROP
-A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
COMMIT
Unless you match the PTR record, random scanners won't be able to guess the DNS name you are using for the PBX. Limiting registration to only those devices that know the DNS name cuts 99.99999+% of your risk, although you can still open yourself up to attacks depending on what SIP clients you use and where. (ie, using a SIP client on public wifi at an airport is like wearing a giant sign that says "PLEASE HACK ME") |
|
 Reviews:
·Velcom
·TekSavvy Cable
·Rogers Hi-Speed
·Bell Sympatico
·voip.ms
| Good news for me: fail2ban already comes set up on freepbx. First time I tried it about a year ago (I think) on a virtual machine, I thought FreePBX had virtualization issues but now I know it was fail2ban locking me out for unsuccessful auth attempts lol. So far the only ignored IP is my personal workstation on the local network. Here's the current definitive list of security measures that are done or will be done before I open up the FreePBX machine to the Internet..
1) http/https closed on the outside fw, https will be forwarded from some random number port (still haven't chosen the #). Still debating whether to tighten it up over the local network as well.
2) Narrowed rtp port range to about 100 as that should be more than enough to meet our needs and set up the outside firewall rule (but commented it out until the machine is ready for "production" testing)
3) No / login via ssh. Have to guess the regular acct name/passwd before being able to su - and guessing the / passwd. Both passwds strong
4) No ALT-F9 I can't believe they allow that lol
5) alwaysauthreject=yes in /etc/asterisk/sip_general_custom.conf
6) IPTABLES in on the to-do list and thanks for giving me such a great start
7) Changing the MySQL passwd on my to-do list
Any other suggestions would be appreciated. -- If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas. George Bernard Shaw |
|
 | You mean alt-f9 on the console? Why is that bad? If someone has physical access to the box, they can get root access if they really want it. |
|
 | reply to FiReSTaRT In my opinion, only allowing numbers in usernames in FreePBX is inflexible for security reasons.
If you go with just plain Asterisk without FreePBX, you can follow the guide called Asterisk: The Definitive Guide.
And by the way, check this out: Log Excerpts From Account Scanning. This is what happens when FreePBX does not allow alphanumeric usernames. -- Current Soft Phone (temp): Ekiga (ordered Yealink T22P to switch from Ekiga) Phone System: Asterisk 1.8; Server: Ubuntu Server 10.04 with Windows Server 2008 R2 Standard as guest |
|
 Reviews:
·Velcom
·TekSavvy Cable
·Rogers Hi-Speed
·Bell Sympatico
·voip.ms
| From what I understand, even in the Log Exerpts article, they mention that setting alwaysauthreject=yes in /etc/asterisk/sip_general_custom.conf (this is where you manually edit what would usually be sip.conf in vanilla *, when you have FreePBX running) would basically send the hacker the same message whether the extension is valid or not. So the hacker could be pounding away at 101 thinking it's a valid X while my X range would be for example 24838201-24838251?
quote: Tip #2: Set alwaysauthreject to yes in the [general] section of /etc/asterisk/sip.conf. This option tells Asterisk to respond as if every account is valid, which makes scanning for valid usernames useless.
Am I missing something? -- If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas. George Bernard Shaw |
|
 espaethDigital PlumberPremium,MVM join:2001-04-21 Minneapolis, MN kudos:2 Reviews:
·Clear Wireless
| All of the scans are actually invalid register attempts; Asterisk just needlessly responds to invalidly formatted requests because you don't configure it with a hostname of which it is aware.
Any valid device would register using 1234@pbx.hostname.tld -- all the scans have register attempts to 1234@127.0.0.1 or 1234@10.10.10.10 -- basically IP addresses or invalid hostnames.
If you block those out in iptables, there is really no risk in using numeric extensions. The only way someone is going to get your hostname is if they capture your SIP traffic, and if they are capturing your sip traffic they already have your alphanumeric username if you used that anyway. |
|
 Reviews:
·Velcom
·TekSavvy Cable
·Rogers Hi-Speed
·Bell Sympatico
·voip.ms
| Thanks.. Looks like I'll have to really get into the nuts and bolts of iptables. Gonna start with Ubuntu's iptables for dummies, play on a virtual machine and work from there. Of course, more questions than answers, as always..
1) What if I do wanna auth from an airport wifi for example? Is there a secure auth scheme that I can use?
2) Is there a major security item missing from this thread? -- If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas. George Bernard Shaw |
|
 espaethDigital PlumberPremium,MVM join:2001-04-21 Minneapolis, MN kudos:2 Reviews:
·Clear Wireless
| said by FiReSTaRT:1) What if I do wanna auth from an airport wifi for example? Is there a secure auth scheme that I can use? If you used a VPN you'd be better off, but SIP itself is cleartext. The passwords are challenge-response authentication so as long as you have fail2ban working they shouldn't be able to derive or brute force your password. They will, however, know your username and PBX hostname which is a good start to begin hacking away. Also, since the RTP streams are unencrypted, and public wifi is unencrypted, anyone running a packet capture agent can capture and playback your phone conversation.
In general, the best approach for public areas is to use cell phones for what they're really good at (making mobile voice calls), and trunk the calls over the PSTN and through your SIP PBX for cheaper calling. Most carriers offer a MyFaves or home calling option so you can get unlimited calls to a specific number -- let that number be a DID on your PBX.
said by FiReSTaRT:2) Is there a major security item missing from this thread? I don't think so. Just keep with the mantra to only expose the connectivity you absolutely need. Where people get burned is leaving things wide open and creating an environment where automated scanning scripts can be successful. |
|