Repository navigation
Description
We will be very grateful, if your problem was described as completely as possible,
enclosing excerpts from logs (if possible within DEBUG mode, if no errors evident
within INFO mode), and configuration in particular of effected relevant settings
(e.g., with fail2ban-client -d | grep 'affected-jail-name' for a particular
jail troubleshooting).
Thank you in advance for the details, because such issues like "It does not work"
alone could not help to resolve anything!
Thanks! (remove this paragraph and other comments upon reading)
Environment:
Fill out and check ([x]) the boxes which apply. If your Fail2Ban version is outdated,
and you can't verify that the issue persists in the recent release, better seek support
from the distribution you obtained Fail2Ban from
- Fail2Ban version (including any possible distribution suffixes):
- OS, including release name/version:
- Fail2Ban installed via OS/distribution mechanisms
- You have not applied any additional foreign patches to the codebase
- Some customizations were done to the configuration (provide details below is so)
The issue:
F2B 0.10.4 still sending "$f2bV_matches" to abuseipdb as seen in prior versions of f2B 0.10.x. I searched for an existing case for this issue and couldn't find it.
Steps to reproduce
Always happens. No need to do anything special to replicate.
Expected behavior
Send log data to abuseipdb via cURL
Observed behavior
from abuseipdb:
Reported IP | Date | Comment | Categories
218.92.0.138 | 37 minutes ago | $f2bV_matches | Brute-Force SSH
222.186.173.226 | 2 hours ago | $f2bV_matches | Brute-Force SSH
218.92.0.173 | 2 hours ago | $f2bV_matches | Brute-Force SSH
176.31.253.204 | 2 hours ago | $f2bV_matches | Brute-Force SSH
51.15.152.61 | 2 hours ago | $f2bV_matches | Fraud VoIP Hacking
69.158.207.141 | 3 hours ago | $f2bV_matches | Brute-Force SSH
Any additional information
Configuration, dump and another helpful excerpts
Any customizations done to /etc/fail2ban/ configuration
Relevant parts of /var/log/fail2ban.log file:
Not sure if this is related:
2020-01-09 12:55:08,244 fail2ban.actions [1823]: ERROR Failed to execute ban jail 'asterisk' action 'abuseipdb' info 'ActionInfo({'family': 'inet4', 'matches': u'[2020-01-09 12:54:45] NOTICE[2175] chan_sip.c: Registration from \'<sip:933@192.168.244.6:5060>\' failed for \'81.171.107.159:56449\' - Wrong password\n[2020-01-09 12:54:45] SECURITY[2212] res_security_log.c: SecurityEvent="InvalidPassword",EventTV="2020-01-09T12:54:45.704-0500",Severity="Error",Service="SIP",EventVersion="2",AccountID="933",SessionID="0x7f5ac400f838",LocalAddress="IPV4/UDP/192.168.244.6/5060",RemoteAddress="IPV4/UDP/81.171.107.159/56449",Challenge="06dfe5d5",ReceivedChallenge="06dfe5d5",ReceivedHash="a19c66a412b1da96592b238594179930"\n[2020-01-09 12:55:07] NOTICE[2175] chan_sip.c: Registration from \'<sip:2146@192.168.244.6:5060>\' failed for \'81.171.107.159:65529\' - Wrong password\n[2020-01-09 12:55:07] SECURITY[2212] res_security_log.c: SecurityEvent="InvalidPassword",EventTV="2020-01-09T12:55:07.191-0500",Severity="Error",Service="SIP",EventVersion="2",AccountID="2146",SessionID="0x7f5ac4c6fb48",LocalAddress="IPV4/UDP/192.168.244.6/5060",RemoteAddress="IPV4/UDP/81.171.107.159/65529",Challenge="52aebef7",ReceivedChallenge="52aebef7",ReceivedHash="d9d18f64601efb30c18a4e5b47f55554"', 'ip': '81.171.107.159', 'F-*': {'matches': [(u'[', u'2020-01-09 12:54:45', u"] NOTICE[2175] chan_sip.c: Registration from '<sip:933@192.168.244.6:5060>' failed for '81.171.107.159:56449' - Wrong password"), u'[2020-01-09 12:54:45] SECURITY[2212] res_security_log.c: SecurityEvent="InvalidPassword",EventTV="2020-01-09T12:54:45.704-0500",Severity="Error",Service="SIP",EventVersion="2",AccountID="933",SessionID="0x7f5ac400f838",LocalAddress="IPV4/UDP/192.168.244.6/5060",RemoteAddress="IPV4/UDP/81.171.107.159/56449",Challenge="06dfe5d5",ReceivedChallenge="06dfe5d5",ReceivedHash="a19c66a412b1da96592b238594179930"', u"[2020-01-09 12:55:07] NOTICE[2175] chan_sip.c: Registration from '<sip:2146@192.168.244.6:5060>' failed for '81.171.107.159:65529' - Wrong password", u'[2020-01-09 12:55:07] SECURITY[2212] res_security_log.c: SecurityEvent="InvalidPassword",EventTV="2020-01-09T12:55:07.191-0500",Severity="Error",Service="SIP",EventVersion="2",AccountID="2146",SessionID="0x7f5ac4c6fb48",LocalAddress="IPV4/UDP/192.168.244.6/5060",RemoteAddress="IPV4/UDP/81.171.107.159/65529",Challenge="52aebef7",ReceivedChallenge="52aebef7",ReceivedHash="d9d18f64601efb30c18a4e5b47f55554"'], 'failures': 4, 'ip4': u'81.171.107.159'}, 'fid': <function <lambda> at 0x7fba90f3b9b0>, 'raw-ticket': <function <lambda> at 0x7fba90f3be60>, 'failures': 4})': Error banning 81.171.107.159
Relevant lines from monitored log files in question:
Activity
sebres commentedon Jan 9, 2020
But it is there (#2310:) And it got fixed in 521de5e, so normally already in 0.10.3.
May be you had manually changed the action, so it has been not upgraded. Or it is simply not the stock action that you're using.
So check (and fix) the code mentioned in #2310 (comment)
Anyway I don't see the issue in current (changed) code of action too:
fail2ban/config/action.d/abuseipdb.conf
Line 89 in 7dbd3a0
Tag
<matches>is enclosed in double-quotes so the variable$f2bV_matcheswill be interpolated there during assignment oflgm.sebres commentedon Jan 9, 2020
As for
ERROR Failed to execute ban jail: this looks like an additional message dumping the ticket info.Do you have still some other lines before or hereafter this error could explain that?
mc4bbs commentedon Jan 9, 2020
@sebres -- thanks for the reply.
I completely erased ALL data and material from the former version of F2B I was running, as abuseipdb is getting rid of API V1 at the end of this month.
I downloaded the NEWEST version available, 0.10.4 and performed a fresh install.
After configuring my jail.local file and /etc/fail2ban/action.d/abuseipdb.conf as required (simple things: an sshd and an asterisk jail and my apikey), it started humming.
When I saw this sort of thing being reported from my account on abuseipdb:
I searched and discovered the write-ups you mentioned, but upon examining "the fix", my code already appears that way.
Either I am missing something, or the fix does not fix the problem with Ubuntu Linux.
Here is the code from my /etc/fail2ban/action.d/abuseipdb.conf file:
What is wrong? What am I not seeing?
sebres commentedon Jan 9, 2020
Well it looks like you have actionban 2 times (the last is wrong but it wins and overwrites the first), so simply remove it or compare the whole file with stock config:
to be sure some local config does not overwrite that also, check the interpolated variant (in the dump) too:
You should see this tag in double-quotes and never in single-quotes.
Also note the time of the ban... You did provide:
222.186.173.226 | 2 hours ago | $f2bV_matches | Brute-Force SSH
...
69.158.207.141 | 3 hours ago | $f2bV_matches | Brute-Force SSH
So check what do you see for the fresh bans.
mc4bbs commentedon Jan 9, 2020
I was wondering about those two statements -- but assumed someone who wrote it knew better than me... I just made the changes and did a fail2ban-client reload and will report back shortly. Thanks!
mc4bbs commentedon Jan 10, 2020
@sebres -- it's not reporting at all now. I gave it several hours (I normally have at least 75 IPs an hour).
I looked closer at the one line I should have:
It does not transmit to the API V2 URL. Is that a mistake? Could that be the problem?
When I replace the URL (see below), it's still not reporting... I'm at my wit's end with this.
I'm dealing with TWO changes -- moving from API V1 to API V2 and upgrading from 0.9.x to 0.10.x of F2B -- so that complicates things for me.
BTW:
I went back to using this section of the script to perform the cURL:
Once again, reports are flowing -- but with the "$f2bV_matches" stuff again...
Reported IP | Date | Comment | Categories
77.247.110.166 | 12 minutes ago | $f2bV_matches | Fraud VoIP Hacking
14.225.3.47 | 16 minutes ago | $f2bV_matches | Brute-Force SSH
222.186.30.31 | 26 minutes ago | $f2bV_matches | Brute-Force SSH
77.247.110.17 | 40 minutes ago | $f2bV_matches | Fraud VoIP Hacking
Thanks for any advise.
sebres commentedon Jan 10, 2020
I don't use abuseipdb so don't have a key and not really familiar with it... so no idea why it does not ban, but your action looks still old. Anyway you can do the tests it from command line.
Your current action would produce something like this:
I get
422 Unprocessable Entityif I try it from shell.However the latest version of this action would produce a command similar this:
I get
401 Unauthorizedhere (pretty clear because tested with artificial key).So change the key (f2bV_abuseipdb_apikey) and try it from the shell.
And if it works in shell but doesn't work in fail2ban, please take a look into fail2ban.log for some errors after
Ban ...and provide it here.Well as already said it was a long fixed bug, but if you still need this old config - you have to replace single quotes with double-quotes (e. g.
"comment=<matches>").mc4bbs commentedon Jan 10, 2020
The URL in the cURL command is invalid for an AbuseIPDB V2 API key.
Like I said above: I'm contending with TWO changes -- moving from API V1 to API V2 and upgrading from 0.9.x to 0.10.x of Fail2Ban
Instructions for the AbuseIPDB V2 API is at https://docs.abuseipdb.com/#introduction
It seems there are INDEED issues with v 0.10.4 in respect to API V2. Considering that API V1 will completely stop working in 15 days, I predict a LOT MORE PEOPLE will have this issue.
From all the testing I have done, it seems that the actual variable "matches" contains the value "$f2bV_matches". My current abuseipdb.conf is here (minus my key, of course):
You'll notice that in my last and final test for today, I replaced the portion of the script that includes the comments with >> --data-urlencode 'comment=' \ <<
This results in the same on abuseipdb.com:
Reported IP | Date | Comment | Categories
222.186.180.223 | 1 hour ago | $f2bV_matches | Brute-Force SSH
222.186.175.181 | 1 hour ago | $f2bV_matches | Brute-Force SSH
This makes me believe the problem is with the part of the script that sets the variable $match
What do you think @sebres ? Whom else should be brought in on this if it's not your expertise?
mc4bbs commentedon Jan 10, 2020
@sebres -- Please re-open this case. It is obviously an issue that needs to be addressed.
sebres commentedon Jan 10, 2020
No. I don't.
Please read attentive (in any of my comments) replace single quotes with double quotes.
I still see single quotes in your version of the action.
So you have 2 possibilities:
like described in this #2310 (comment) that I provided in my first comment to your issue.
Do you really not see the difference?
Although I'm not familiar with abuseipdb, but I can read shell script and know a difference between
'$v'and"$v"in shell:But if you don't believe me, you can ask people contributing to this action: @ajcollett, @todgru, @mercurytoxic. Or even some other participating in discussions on several PR's or issues.
sebres commentedon Jan 10, 2020
I can, but I don't see why it should be necessary.
Neither I don't understand why you won't do what I tell you, nor I don't follow how (and from where) you obtained this "broken" action.
You said it is 0.10.4 - but it is not, if you download our official release 0.10.4, you'll notice it had definitely another file.
mc4bbs commentedon Jan 10, 2020
I've done all you've asked:
This isn't rocket science, but something is wrong and the advise you're providing isn't helping.
sebres commentedon Jan 10, 2020
/config/action.d/abuseipdb.confwith your version of file - it is definitely not what you're describing,I'm not responsible here for every distribution around the world (some things are matter of maintainers of that distribution).
'<matches>';Anyway you don't listen what one tell you, so it makes no sense.
mc4bbs commentedon Jan 10, 2020
@sebres , I understand you are trying to help, but you are being very condescending and making assumptions that I didn't do what you asked because there were no viable results. I do not see anything in the log file that would be helpful.
I use fail2ban integrated with AbuseIPDB in order to be a good netizen and report malicious actors -- I don't have to do it.
Let's start from scratch. I know you are trying to help, but your lack of AbuseIPDB API V2 knowledge and experience is getting in the way here, which is why I asked you to OPEN this case once again so we could engage people who know about AbuseIPDB API V2 integration with fail2ban.
I have (sigh) once again installed fial2ban and reinstalled, getting a fresh download from the site you recommend. Upon installing, I go into the virgin /etc/fail2ban/action.d/abuseipdb.conf to see this;
As you can see, the hard-coded URL points to the AbuseIPDB API V1 URL only. This will NOT WORK as of February 1st 2020. AbuseIPDB has been sending e-mails to everyone still reporting under API V1 to change NOW.
The code you had me install has no AbuseIPDB API V2 and therefore, won't function.
So, now that I only have an API V2 key and the 0.10.4 code does not point to the right URL, now what do I do next?
mc4bbs commentedon Jan 10, 2020
I copied my jail.local over, here's the log so far... if it helps.
fail2ban.log
mc4bbs commentedon Jan 10, 2020
Here's more log file..
fail2ban.log
mc4bbs commentedon Jan 10, 2020
To be VERY, VERY clear -- I have no API V1 key, therefore the URL "https://www.abuseipdb.com/report/json" will do nothing for me at all, ever. They are not giving our new API V1 keys and I no longer have one. I'm on V2 now, which uses the URL "https://api.abuseipdb.com/api/v2/report" exclusively. I have pointed this out a few times already and provided links to the AbuseIPDB API V2 documentation, but you've ignored this.
mc4bbs commentedon Jan 10, 2020
I am migrating this problem to #2594
sebres commentedon Jan 10, 2020
WHY?
I told you just to replace the single config file!
Sure because I suppose you've downloaded stock 0,10.4, but API 2 was not yet implemented there.
It is arrives firstly within #2302 (see commit 8da9bfb), so it is firstly released with 0.10.5.
Then why you're trying that all?
I told you already several times:
HowTo:
fail2ban-client reloadin order to update run-time.sebres commentedon Jan 10, 2020
Do you see that:
the error message is obvious (and had nothing to do with method you're using).
That are probably just really too many requests.
mc4bbs commentedon Jan 10, 2020
Yep -- that's because of the OLD V1 URL.
mc4bbs commentedon Jan 10, 2020
Pretty soon EVERY F2B user who reports to AbuseIPDB will be getting this error when they turn off V1 in 20 days...
sebres commentedon Jan 10, 2020
No, I don't think so. Error "429 too many requests" is to signal that some limit is exceeding (probably they throttle the maximal reports per hour/day (I don't know, please check the docu on abuseipdb site).
Yes, and? What we should do?