<p>Keep in mind there is also a register attempt event but this is probably an ok addition.</p>
<div class="gmail_quote">On Feb 23, 2011 12:59 AM, &quot;jay binks&quot; &lt;<a href="mailto:jaybinks@gmail.com">jaybinks@gmail.com</a>&gt; wrote:<br type="attribution">&gt; check out my patch Ive just posted to jira.<br>
&gt; <a href="http://jira.freeswitch.org/browse/FS-3094">http://jira.freeswitch.org/browse/FS-3094</a><br>&gt; <br>&gt; you can subscribe to &quot;Auth&quot; events now - SWITCH_EVENT_AUTH<br>&gt; which are generic for Register &amp; Invite ( and any other auth&#39;d packet I<br>
&gt; guess )<br>&gt; and there is an auth_state which will tell you if its an auth fail or a<br>&gt; expire etc..<br>&gt; you can get the to_user, to_host, useragent, sip profile and network_ip<br>&gt; <br>&gt; Auth Expires also have a Log messages similar to Auth Failures ( fail2ban<br>
&gt; compatible )<br>&gt; <br>&gt; PLEASE guys give this some testing.  I only banged this together in a few<br>&gt; hours today in my currently sleep deprived state.  So im sure its going to<br>&gt; have things that can be improved or work better, but at least the bones of<br>
&gt; it are there now.<br>&gt; <br>&gt; let me know your thoughts.<br>&gt; <br>&gt; Jay<br>&gt; <br>&gt; <br>&gt; <br>&gt; On Mon, Feb 21, 2011 at 11:08 PM, <a href="mailto:Jmesquita@freeswitch.org">Jmesquita@freeswitch.org</a> &lt;<br>
&gt; <a href="mailto:jmesquita@freeswitch.org">jmesquita@freeswitch.org</a>&gt; wrote:<br>&gt; <br>&gt;&gt; Just an idea for the other developers. Wouldn&#39;t be cool to have and event<br>&gt;&gt; thrown by each module that does authentication so that other application<br>
&gt;&gt; modules are able to listen in those events and do whatever with it? Some<br>&gt;&gt; people might even like to have that running an eel daemon and throw some<br>&gt;&gt; snmp traps based on that?<br>&gt;&gt;<br>&gt;&gt; Just an idea that might be completely ridiculous or might raise some<br>
&gt;&gt; interest. Events are pretty cheap so there wouldn&#39;t be a lot of overhead<br>&gt;&gt; involved.<br>&gt;&gt;<br>&gt;&gt; Regards,<br>&gt;&gt;<br>&gt;&gt; Joćo Mesquita<br>&gt;&gt;<br>&gt;&gt; On 21/02/2011, at 07:28, Spencer Thomason &lt;<a href="mailto:spencer@5ninesolutions.com">spencer@5ninesolutions.com</a>&gt;<br>
&gt;&gt; wrote:<br>&gt;&gt;<br>&gt;&gt; &gt; After tinkering with it, I think that might be the best way.  The<br>&gt;&gt; &gt; iptables method is cool but I&#39;d like to have more dynamic control and<br>&gt;&gt; &gt; with Fail2Ban looking at the challenges you could specifically ignore<br>
&gt;&gt; &gt; certain high traffic IPs and block others.  What would be very cool is<br>&gt;&gt; &gt; if instead of logging every challenge, a log entry was written if<br>&gt;&gt; &gt; there was a high number from a specific IP, then you could decide what<br>
&gt;&gt; &gt; to do about it with fail2ban, similar to the pike module for opensips<br>&gt;&gt; &gt; does.<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; On Feb 21, 2011, at 1:31 AM, <a href="mailto:covici@ccs.covici.com">covici@ccs.covici.com</a> wrote:<br>
&gt;&gt; &gt;<br>&gt;&gt; &gt;&gt; I would change sip auth failure to challenge and then have sufficient<br>&gt;&gt; &gt;&gt; times to only block if there are too many challenges in a certain<br>&gt;&gt; &gt;&gt; time.<br>
&gt;&gt; &gt;&gt; I am not even sure the failure works any more in recent gits.<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; Spencer Thomason &lt;<a href="mailto:spencer@5ninesolutions.com">spencer@5ninesolutions.com</a>&gt; wrote:<br>
&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt;&gt; Yes, that works great if they respond to the challenge with a failed<br>&gt;&gt; &gt;&gt;&gt; auth. But the scenario I&#39;m trying to prevent is if they just send the<br>&gt;&gt; &gt;&gt;&gt; INVITE and never respond to the challenge.  Fail2Ban will not work as<br>
&gt;&gt; &gt;&gt;&gt; every endpoint will initially send an INVITE and receive a challenge.<br>&gt;&gt; &gt;&gt;&gt; Legit calls will then respond correctly and not be logged as a SIP<br>&gt;&gt; &gt;&gt;&gt; auth failure but every call that is challenged will show up as SIP<br>
&gt;&gt; &gt;&gt;&gt; auth challenge in the logs so there is no regex to differentiate<br>&gt;&gt; &gt;&gt;&gt; between legit an non legit traffic.<br>&gt;&gt; &gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt; Spencer<br>&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; On Feb 20, 2011, at 10:39 PM, Ken Rice wrote:<br>&gt;&gt; &gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;&gt; Fail2Ban ... This is block an IP with too many failed attempts from<br>&gt;&gt; &gt;&gt;&gt;&gt; something like SipVicious pretty quickly<br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;&gt; On 2/20/11 11:07 PM, &quot;Spencer Thomason&quot; &lt;<a href="mailto:spencer@5ninesolutions.com">spencer@5ninesolutions.com</a>&gt;<br>&gt;&gt; &gt;&gt;&gt;&gt; wrote:<br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; Hi,<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; We run hosted Freeswitch instances in VMs with the internal profile<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; on<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; port 5060 connecting to clients mostly behind NAT and then the<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt; external profile connecting to our proxies only.  Protecting the<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; external profile its straightforward.. we only allow traffic to/<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; from<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt; our proxies at the firewall level.  But protecting the internal<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; profile seems to be a bit more difficult because the UACs could be<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; theoretically anywhere on the network.<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; I&#39;m currently using Fail2Ban to prevent brute force registration<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; and<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; INVITEs on auth failures, e.g.:<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt; failregex = \[WARNING\] sofia_reg.c:\d+ SIP auth failure \<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; (REGISTER\)<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; on sofia profile \&#39;\w+\&#39; for \[.*\] from ip &lt;HOST&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt;           \[WARNING\] sofia_reg.c:\d+ SIP auth failure \(INVITE\)<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; on sofia profile \&#39;\w+\&#39; for \[.*\] from ip &lt;HOST&gt;<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt; My question is, since its part of a normal SIP dialog to challenge<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; the<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; INVITE, is there any way to prevent a possible DoS from just sheer<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt; volume of incoming INVITEs on an Internet facing server<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; automatically.  I.e., If you block the logged challenge, you&#39;d<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; block<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt; all legitimate INVITEs and registrations.  Since its UDP traffic I<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; couldn&#39;t come up with a way to do it automatically at the iptables<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; level. i.e. number of concurrent connections.  Is there some option<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt; to<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; just not respond if a client is sending a number of requests over a<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; certain threshold?  It might not stop them from sending the traffic<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt; but pretty soon they&#39;d get the idea that it wasn&#39;t going to go<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; anywhere.  My concern is say there are 50 Freeswitch instances on a<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; box (albeit 8 core, 32GB ram, 8 15K raid 10 storage) and someone<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt; starts sending thousands of rouge INVITEs to every VM on a physical<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; box that the CPU load from just challenging the incoming INVITEs<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; would<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt; create a DoS.  We the logs regularly to try to catch people doing<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; this<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; sort of thing and drop them at a router upstream of the core<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt; network,<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; but I&#39;d like to have it happen without human intervention.  Have I<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; completely over thought this and am missing something obvious?<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; Thanks,<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; Spencer<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt; FreeSWITCH-users mailing list<br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt;&gt; &gt;&gt;&gt;&gt;&gt; UNSUBSCRIBE:<br>&gt;&gt; <a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>&gt;&gt; &gt;&gt;&gt;&gt;&gt; <a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;&gt; _______________________________________________<br>&gt;&gt; &gt;&gt;&gt;&gt; FreeSWITCH-users mailing list<br>
&gt;&gt; &gt;&gt;&gt;&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>&gt;&gt; &gt;&gt;&gt;&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt;&gt; &gt;&gt;&gt;&gt; UNSUBSCRIBE:<br>&gt;&gt; <a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>&gt;&gt; &gt;&gt;&gt;&gt; <a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt;<br>&gt;&gt; &gt;&gt;&gt; _______________________________________________<br>&gt;&gt; &gt;&gt;&gt; FreeSWITCH-users mailing list<br>&gt;&gt; &gt;&gt;&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt;&gt; &gt;&gt;&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>&gt;&gt; &gt;&gt;&gt; UNSUBSCRIBE:<br>&gt;&gt; <a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt;&gt; &gt;&gt;&gt; <a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; --<br>&gt;&gt; &gt;&gt; Your life is like a penny.  You&#39;re going to lose it.  The question is:<br>
&gt;&gt; &gt;&gt; How do<br>&gt;&gt; &gt;&gt; you spend it?<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt;        John Covici<br>&gt;&gt; &gt;&gt;        <a href="mailto:covici@ccs.covici.com">covici@ccs.covici.com</a><br>&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; _______________________________________________<br>&gt;&gt; &gt;&gt; FreeSWITCH-users mailing list<br>&gt;&gt; &gt;&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt;&gt; &gt;&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>&gt;&gt; &gt;&gt; UNSUBSCRIBE:<br>&gt;&gt; <a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt;&gt; &gt;&gt; <a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; _______________________________________________<br>&gt;&gt; &gt; FreeSWITCH-users mailing list<br>
&gt;&gt; &gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>&gt;&gt; &gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt;&gt; &gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>&gt;&gt; &gt; <a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>
&gt;&gt;<br>&gt;&gt; _______________________________________________<br>&gt;&gt; FreeSWITCH-users mailing list<br>&gt;&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt;&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>&gt;&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt;&gt; <a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>&gt;&gt;<br>&gt; <br>&gt; <br>&gt; <br>&gt; -- <br>&gt; Sincerely<br>&gt; <br>&gt; Jay<br></div>