Just a bit of advice for those who have their Trixboxes on the internet.

percykwong
Posts: 758
Member Since:
2007-04-30

I have been working with quite a few clients and one of the things I noticed is that many clients aren't properly securing their boxes from harm properly. I would suggest running iptables on your boxes and restrict connections coming to your Trixboxes to only allow tftp and ssh access from trusted ips.

If you're of the mindset of, "Well, I'm behind a firewall and thus, I must be protected." All I can say is if your box is accessible from the internet, it isn't as protected as you think. Here's a little something you might want to try just to prove my point.

1. If your box is accessible via ssh (even on a non-standard port) from the internet, type the following at the shell prompt.

cat /var/log/secure|grep 'nvalid user'

you'll see all the ssh attempts at accessing your box from unsavory script kiddies and blackhats.

You can do something similar to your http logs to get an idea of how many http attempts at authentication into your admin interface as well.

Now the question is.. What do you do about it? While you can't secure yourself from every unsavory character on the internet, you can do a little "magic" to protect your box.

There's a wonderful little application called "fail2ban" that (if configured properly) will actually shut out an ip address from intrusion attempts for a certain period of time (as per your definition). After the set period of time, it will unban the ip address so your iptables chains don't get ridiculously long.

While fail2ban isn't a simple "click to configure" kind of thing, it is incredibly effective at stopping some of that bad mojo that's on the internet.

I've got mine doing some pretty cool stuff (like banning invalid users on ssh and the web portals). Basically, any type of ssh probing automatically gets banned for 60000 seconds after the first attempt. Failed Web Authentications get banned after the third attempt for the same amount of time.

The setup basically makes my PBX unresponsive to those ip addresses for some period of time. It also gives me peace of mind.

On another note, people might want to look into Argus as well. This wonderful little network monitoring program allows me to monitor my SIP and IAX trunks and if they become unresponsive, it basically reloads the sip and iax trunk registrations accordingly (while notifying me on my cellphone via text messaging).

You'd be surprised at how easily it is to catch your ITSPs doing something they're not supposed to be doing in the middle of the day (like taking down SIP proxies, et. al.) In other words, monitor your boxes for security and your trunks and ITSPs for uptime.

While these things require a fair amount of setup time, the headache and pain they save you in the long run is well worth the time investment. If you don't have the skill-base to accomplish these two things, but would like them installed, I'm available for hire (shameless plug for my consulting services).

In all seriousness though, anyone running a trixbox that is even remotely accessible on the internet really should look into implementing these features. You really get alot of insight into how reliable and insecure your boxes really are. Oh yeah.. one word of advice... CHANGE THE DEFAULT PASSWORDS PEOPLE.

Cheers.

--

-----------------------------------------------
Percy Kwong
Trixbox Tech Support - 202.600.3884

Swimminginthought.com



jahyde
Posts: 2002
Member Since:
2006-06-02
good tip on the fail2ban

good tip on the fail2ban Percy. I also like denyhosts

--

--my PBX is run on 2 V8's



SkykingOH
Posts: 9537
Member Since:
2007-12-17
Welcome back

Thanks for that information, especially the tip on Argus. That will be on the top of my list of "to do's" tomorrow.

In your follow up post to the person who had their machine compromised you mentioned the best advice of all "don't expose the services in the first place".

Not being an applications expert it is far easier for me to isolate a server in a physical DMZ (VLAN's are wonderful things) than it is for me to try and lock down problems above layer 3.

Scott

--

Scott

aka "Skyking"



percykwong
Posts: 758
Member Since:
2007-04-30
I looked into denyhosts as

I looked into denyhosts as well, but fail2ban was infinitely more configurable (at least to me). It's also still actively developed (that was the clincher for me). While I will say that the fail2ban documentation really bites the big kahuna, the program seems to be pretty rock solid. I've since made it a staple of every *nix box I install and administer full-time. I do ask clients with existing installations if they would like it installed. It's a pity that some clients will turn down my offer with the comment, "I have a firewall".

-----------------------------------------------
Percy Kwong
www.swimminginthought.com

--

-----------------------------------------------
Percy Kwong
Trixbox Tech Support - 202.600.3884

Swimminginthought.com



eoo
Posts: 448
Member Since:
2006-10-30
thanks percy! i have felt

thanks percy!

i have felt like the lone ranter on this subject for a long time so I am glad to get some company. i have had uncounted number of people call for help and they give me a URL to "take a look", where I find the freePBX page comes up complete with messages to the effect that default passwords are all still in effect. I got on one client's server and actually found and caught a cracker in the act ---- and the client did not believe it.

All the preaching about only using SSH across the web is valid but not working. Most users are only going to use a GUI - otherwise they probably would not be using trixbox in the first place. I have seen dozens of posts starting out "never ever...on the internet" [I have made that post myself more than once] but still there are hundreds of thousands of unsecured trixboxes sitting with the http GUI on the internet, with no SSL, default passwords with open access to config files and the mysql database.

The excuses, even from some relatively sophisticated users, makes a sorry list:

(a) its behind a firewall
(b) its only a small/hobby/old computer so it does not matter
(c) there's nothing on it worth stealing on the box
(d) i moved the GUI and/or SSH ports so no one will find it
(e) i tried changing the passwords and locked myself out so I gave that up
(f) installing SSL and a [self signed certificate] is a too hard
...

We as a community need to think about security more seriously, otherwise those members in business selling security will be meeting a new line of customer resistance: "oh, you mean that system where people come in a steal my phone service?".



TDF
Posts: 483
Member Since:
2006-12-19
(No subject)


atilio
Posts: 288
Member Since:
2006-06-01
Have you looked at the

Have you looked at the fail2ban site. http://www.fail2ban.org
I believe that they have some documentation there.



TDF
Posts: 483
Member Since:
2006-12-19
I've struggled to install

I've struggled to install fail2ban, for my last attempt I tried this

wget ftp://download.fedora.redhat.com/pub/fedora/linux/development/sou...

rpm -i fail2ban-0.8.3-16.fc10.src.rpm

but got this

[local.domain ~]# rpm -i fail2ban-0.8.3-16.fc10.src.rpm
warning: fail2ban-0.8.3-16.fc10.src.rpm: Header V3 DSA signature: NOKEY, key ID 0b86274e
error: cannot create %sourcedir /usr/src/redhat/SOURCES

is it ok to give up here, is it part installed or will it cause any trouble ?



necits
Posts: 419
Member Since:
2008-02-23
Try creating

Try creating /usr/src/redhat/SOURCES manually then try to install the RPM.

--

Michael Mathewson CCNA,MCSE
Owner/Consultant
Northeast CT IT Solutions



TDF
Posts: 483
Member Since:
2006-12-19
.

.



TDF
Posts: 483
Member Since:
2006-12-19
.

.



mustardman
Posts: 1289
Member Since:
2006-06-18
Well I might as well rile

Well I might as well rile things up. I certainly am not going to say don't secure things but I also think IT guys tend to get a bit too paranoid about it. All you really need is a strong root password and of course be behind a firewall. The most I would do is not allow root login from SSH so that they would have to get through 2 login prompts and find 2 passwords. Automatically banning IP's that try brute force multiple attempts is the absolute most I would ever do.

After that, if it makes usability/administration more difficult I won't do it. That is the trade off. Name one person who had a properly configured Asterisk box behind a firewall and a strong root password get hacked? Of course you will always see a lot of questionable traffic. It is always there and most of it is harmless. A lot of robots are always out there scanning. That's just the way it is. There really is no limit to how paranoid you can get and how much you can do to attempt to make it impossible to hack or justify your hourly rate or whatever. Yea, I know about all the paranoia articles about security. Look who is putting those out there. Security consultants and security software companies.

Case in point just look at the people above having problems installing that software. enabling iptables/selinux etc. which are notorious for creating usability problems with Asterisk/FreePBX is just another headache to deal with IMHO. That's just me and my opinion. Do whatever you want with your installs and if you can get more money out of the customer for doing it more power to you. I prefer sticking with the KISS principle. It's complicated enough just dealing with standard Asterisk/FreePBX stuff. I don't need to add more unnecessary complication.



jchuby
Posts: 611
Member Since:
2006-07-20
Maybe in light of the recent

Maybe in light of the recent SIP and future IAX brute force attacks someone who knows what theyre doing can do a quick writeup on installing Fail2Ban with a 12 hour Deny.
I do not use a firewall on trixbox, i keep the machines lean as possible, and use a strict physical firewall, strong SSH, and password requirements (NO root, etc).

Maybe it would be possible to integrate an application like this into the core Trixbox Distro preconfigured to block IPs that try to brute force for a few hours.

--

JChuby
Experienced Trixbox Tech for Hire in Greater NYC
Experienced in Remote Tech Support / Custom DialPlan / Assistance As Well
JChubak@gmail.com or PM me on Trixbox.org Forums



TDF
Posts: 483
Member Since:
2006-12-19
There is a wiki article

There is a wiki article here

http://voip-info.org/wiki/index.php?page_id=5348

and some info in this thread

http://www.trixbox.org/forums/trixbox-forums/help/iptables-does-n...

theres just a little issue with the timestamps that needs sorting out for it to be perfect, then I'll write it up if no one else wants to, although to be fair the wiki article only needs a few tweaks and a couple of corrections.



jchuby
Posts: 611
Member Since:
2006-07-20
Yea, I just followed that to

Yea, I just followed that to get SSH and the Asterisk-Block to be in effect.

I use strong passwords too, but i think this should be a feature turned on Automatically on the next trixbox update

Kerry - maybe we can get a simple setup script that installs IPtables (Blank Rules, so if you dont want to use more) and Fail2Ban with SIP/IAX/SSH Ban of 6-24 hours (I dont know what the best one to choose would be) so that Trixbox can announce that they are doing something to stop the Threat of ScriptKiddies hacking usernames and spending money calling 900 numbers in the caribean or spaming people in the USA....

--

JChuby
Experienced Trixbox Tech for Hire in Greater NYC
Experienced in Remote Tech Support / Custom DialPlan / Assistance As Well
JChubak@gmail.com or PM me on Trixbox.org Forums



TDF
Posts: 483
Member Since:
2006-12-19
This might be a good

This might be a good starting point. It maybe wants a few tweaks by someone with more knowledge than me, I think a few are in the wrong order at least. It has every port I can think might be needed, once its in place it is fairly simple for even a beginner (me) to edit using webmin, just delete the rules for whatever you don't need.

# Generated by iptables-save v1.3.5 on Sun Sep 21 03:11:00 2008
*nat
:PREROUTING ACCEPT [8:408]
:POSTROUTING ACCEPT [2:129]
:OUTPUT ACCEPT [2:129]
COMMIT
# Completed on Sun Sep 21 03:11:00 2008
# Generated by iptables-save v1.3.5 on Sun Sep 21 03:11:00 2008
*mangle
:PREROUTING ACCEPT [287:33378]
:INPUT ACCEPT [287:33378]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [288:38355]
:POSTROUTING ACCEPT [288:38355]
COMMIT
# Completed on Sun Sep 21 03:11:00 2008
# Generated by iptables-save v1.3.5 on Sun Sep 21 03:11:00 2008
*filter
:FORWARD ACCEPT [0:0]
:INPUT DROP [0:0]
:OUTPUT ACCEPT [0:0]
# Accept traffic from internal interfaces
-A INPUT ! -i eth0 -j ACCEPT
# Accept traffic with the ACK flag set
-A INPUT -p tcp -m tcp --tcp-flags ACK ACK -j ACCEPT
# Allow incoming data that is part of a connection we established
-A INPUT -m state --state ESTABLISHED -j ACCEPT
# Allow data that is related to existing connections
-A INPUT -m state --state RELATED -j ACCEPT
# Accept responses to DNS queries
-A INPUT -p udp -m udp --dport 1024:65535 --sport 53 -j ACCEPT
# Accept responses to pings
-A INPUT -p icmp -m icmp --icmp-type echo-reply -j ACCEPT
# Accept notifications of unreachable hosts
-A INPUT -p icmp -m icmp --icmp-type destination-unreachable -j ACCEPT
# Accept notifications to reduce sending speed
-A INPUT -p icmp -m icmp --icmp-type source-quench -j ACCEPT
# Accept notifications of lost packets
-A INPUT -p icmp -m icmp --icmp-type time-exceeded -j ACCEPT
# Accept notifications of protocol problems
-A INPUT -p icmp -m icmp --icmp-type parameter-problem -j ACCEPT
# Allow connections to SSH server
-A INPUT -p tcp -m tcp --dport ssh -j ACCEPT
# Allow connections to IDENT server
-A INPUT -p tcp -m tcp --dport auth -j ACCEPT
# Allow connections to WEB server
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
# Allow connections to SSH server
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
# Allow connections to Webmin server
-A INPUT -p tcp -m tcp --dport 10000 -j ACCEPT
# Allow connections to FOP server
-A INPUT -p tcp -m tcp --dport 4445 -j ACCEPT
# Allow connections to SIP server
-A INPUT -p udp -m udp --dport 5060:5061 -j ACCEPT
# Allow connections to RTP server
-A INPUT -p udp -m udp --dport 10000:20000 -j ACCEPT
# Allow connections to IAX2 server
-A INPUT -p udp -m udp --dport 4569 -j ACCEPT
# Allow connections to IAX server
-A INPUT -p udp -m udp --dport 5036 -j ACCEPT
# Allow connections to MGCP server
-A INPUT -p udp -m udp --dport 2727 -j ACCEPT
# Allow all NTP records 
-A INPUT -p tcp -i eth0 --dport 123 -j ACCEPT
# Allow connections to HTTPS server
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
# Allow remote connections to WEBMIN server
-A INPUT -p tcp -m tcp --dport 9001 -j ACCEPT
# Allow connections to ASTERISK MANAGER server
-A INPUT -p tcp -m tcp --dport 5038 -j ACCEPT
# Allow connections to TFTP server
-A INPUT -p udp -m udp --dport 69 -j ACCEPT
COMMIT
# Completed on Sun Sep 21 03:11:00 2008


kerryg
Posts: 6790
Member Since:
2006-05-31
I would refer to Engineer

I would refer to Engineer Tim's document on this topic. This is what I think we are going to use in future builds as he is very familiar with it. Please read his document on his website at http://engineertim.com

--

Kerry Garrison
http://www.VoipStore.com - http://3cxbook.com
(888) VOIPSTORE - (888) 864-7786



tyardley
Posts: 209
Member Since:
2007-09-09
My Take

Personally, I don't like having to write custom IPTABLES rules. And I know for some that this can be a daunting task. I know I also push the APF/BFD solution quite hard. To me, APF itself is easy to implement and there are zero rules that you have to create by hand. Not only that it is easy to customize using a single config file, supports spamhaus and other online rules grabbing. With that in mind I am going to see if I can get fail2ban to work with APF. BFD does a good job, and I have written a rule that is a drop in for asterisk. Been testing it here. However, I know there is strong movement for fail2ban use. So if I can get it to play nice then I will include it in my document that I wrote. I would still like someone to give the APF/BFD option a chance. I have a install script that you run and it grabs the most current and installs it. Pretty cut and dry. Only part you have to edit is the config file for APF and if you want the asterisk rule I will post it on engineertim.com.

I want to avoid a pissing match that this or that is better, security should be neutral and we all should be giving valid input. I would strongly recommend that everyone take a closer look at all of their installs. I personally have nagios, ossec, cacti, phplogcon, and some other magic, monitoring my systems. If so much as a checksum on a single file changes I get a email. If I have too many calls going out, I get a email and a graph sent to me. I will try and get this next document that includes these setups done in the coming weeks. Sooner if I can get the dedicated time to do it. In the meantime look at the doc I wrote, even if you don't implement the items I put in there you might be a little more informed if not surprised.

Thank you for your time,
Engineer Tim

Trixbox Engineer
http://engineertim.com



nobaloney
Posts: 13
Member Since:
2007-11-11
Quote: Well I might as well
Quote:
Well I might as well rile things up. I certainly am not going to say don't secure things but I also think IT guys tend to get a bit too paranoid about it. All you really need is a strong root password and of course be behind a firewall. The most I would do is not allow root login from SSH so that they would have to get through 2 login prompts and find 2 passwords.

We do exactly that; our passwords are generated by a secure password generator in the office and aren't shared anywhere except in a secure password system in the office.

Yet we were hacked a few minutes after midnight this morning. Used as a phishing target. The machine is now down for rebuilding (new drives so we can do forensics on the old ones) and we'll add secure http access on a non-standard port and a few other changes as well. Such as remove ftpd, tftpd, etc.

I suppose I was naive to think an ISO with an automatic install would be fairly secure by default; it won't happen again.

Jeff



kerryg
Posts: 6790
Member Since:
2006-05-31
Quote: I suppose I was naive
Quote:
I suppose I was naive to think an ISO with an automatic install would be fairly secure by default

Its a phone system, not a firewall, not a router, not an edge device. We make no claims about it being any more secure than you would expect any out-of-the-box phone system to be. Unfortunately we are now being forced to address security because of the automated scripts that are out there now.

On the plus side, our trixbox Pro and PBXtra systems are not as vulnerable because the logins and passwords are based on MAC addresses and not extension numbers and potentially matching or easy to crack passwords. We are looking into this for the next endpoint manager to help protect systems even more.

--

Kerry Garrison
http://www.VoipStore.com - http://3cxbook.com
(888) VOIPSTORE - (888) 864-7786



mustardman
Posts: 1289
Member Since:
2006-06-18
Are any of these

Are any of these vulnerabilities Linux based? I don't use distributions. I install CentOS/Asterisk/FreePBX from scratch so I would be interested to know if there are any things (beyond the paranoid) I should be aware of.



kerryg
Posts: 6790
Member Since:
2006-05-31
The current issues we are

The current issues we are seeing are tools like sipvicious that can scan a network for Asterisk systems, then you run another tool against that list to find a list of extensions, then a third tool to crack the extension passwords. Your system could be 100% secure but if you have UDP 5060 open for remote phones you can be hit by this.

--

Kerry Garrison
http://www.VoipStore.com - http://3cxbook.com
(888) VOIPSTORE - (888) 864-7786



mustardman
Posts: 1289
Member Since:
2006-06-18
That sucks :-(. Any simple

That sucks :-(. Any simple and practical ways to reduce the likelyhood of this happening. Again, simple and practical.



TDF
Posts: 483
Member Since:
2006-12-19
Install fail2ban. Ive got it

Install fail2ban. Ive got it looking for failed registration attempts, 1 failed attempt and the IP is banned for 24 hours. Theres a post half way up this thread with some links, or Tim has a APF/BFD solution.



tyardley
Posts: 209
Member Since:
2007-09-09
IP List

I would like to start generating a list of IP addresses (CIDR) that are attacking. Can someone start posting any suspicious IP addresses that they see trying to login via SIP? This is very important to me and would greatly appreciate it. Maybe we could start a new forum thread just for this. I was thinking maybe post the IP address, the portion of the log file that is relevant. Then we can validate the IP address as being nefarious and maybe generate a ban list for users to use? Thoughts?

Thank you,
Engineer Tim

Trixbox Engineer
http://engineertim.com



UncleWard
Posts: 358
Member Since:
2006-05-31
Huh?

With numerous sites that support and encourage IP address cloaking, this would appear to be a big waste of both time and resources.



tyardley
Posts: 209
Member Since:
2007-09-09
I see your point

However, I still feel this information is relevant. I would still like to see the IP's that are attempting to make connections. If anyone wants to share them please post them.

Thank you,
Engineer Tim

Trixbox Engineer
http://engineertim.com



TDF
Posts: 483
Member Since:
2006-12-19
Not been attacked myself,

Not been attacked myself, but I do have the ultimate blacklist already, sorry cant share it with you as it will only be generated after the first failed login attempt.

Did find this while browsing around though http://deepliquid.com/blog/archives/19 it has 3 IPs mentioned

216.40.234.82
204.11.16.135
207.150.180.66

I agree with Ward though a blacklist may not be all that helpful and in my view is unnecessary if you use fail2ban or whatever.

Lets keep this in proportion, the problem is securing SIP extensions a simple enough job. Do we really need more firewalls, tools for configuring firewalls, spamhaus lists, our own list, etc. Security should not be the job of a PBX (as we often here) lets not take a sledgehammer to crack a nut.



kerryg
Posts: 6790
Member Since:
2006-05-31
Quote: Security should not
Quote:
Security should not be the job of a PBX

While that has been the mantra, especially with me for a long time, I do feel security of the PBX functionality itself is going to have to be a feature of the PBX to some extent now. If you have legit users that move around to different IP addresses and come in over the open internet then your firewall rules are going to let the SIP hacking scripts right in. At that point the PBX is going to have to have some level of security in order to prevent malicious scripts from attacking and taking over the SIP extensions.

Yes, this is a reversal of opinion on my part to an extent although I am going to stick to my opinion that the PBX should NEVER be an edge device or connected directly to the open internet. While there should always be a separate firewall in between the internet and the PBX, PBX's moving forward are going to have to protect their pieces that are still exposed to the outside world.

--

Kerry Garrison
http://www.VoipStore.com - http://3cxbook.com
(888) VOIPSTORE - (888) 864-7786



TDF
Posts: 483
Member Since:
2006-12-19
My point was you only need

My point was you only need to add fail2ban and the extensions are secured, job done.

Everything else is unnecessary and in my view a step too far.



SkykingOH
Posts: 9537
Member Since:
2007-12-17
TDF and Kerry I could not

TDF and Kerry I could not agree more.

This is where the OSI model makes so much sense. Firewalls provide layer 3 security. The PBX should never be expected to provide security at Layer 3. Application level security makes sense for the PBX. These are new attack vectors, revisiting our security process in light of the new threat is a reasonable response.

--

Scott

aka "Skyking"



Praeter
Posts: 387
Member Since:
2006-10-26
Also, you are asking for

Also, you are asking for lists of IP's from who? Do you know and trust ALL of your submitters so you don't inadvertently block some major site just because the submitter has a vendetta against them?

--

James Fainer - FtOCC
Praeter Tech
www.praetertech.com
nexusRE - Real Estate Audio Listing



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.