跳至内容
Odoo 菜单
  • 登录
  • 免费试用
  • 应用程序
    财务
    • 会计
    • 发票
    • 费用
    • 电子表格 (BI)
    • 文档
    • 电子签名
    销售
    • 客户关系管理
    • 销售
    • POS 销售点管理-零售
    • POS 销售点管理 - 餐厅
    • 订阅
    • 租赁
    网站
    • 网站设计
    • 电子商务
    • 博客
    • 论坛
    • 在线客服
    • 在线学习
    供应链
    • 库存
    • 制造
    • 产品生命周期
    • 采购
    • 维护保养
    • 品控
    人力资源
    • 员工
    • 招聘
    • 休假
    • 评价
    • 内部推荐
    • 车队
    营销
    • 社媒营销
    • 电邮营销
    • 短信营销
    • 近期活动
    • 营销自动化
    • 网上调查
    服务
    • 项目管理
    • 工时单
    • 现场服务
    • 服务台
    • 排期
    • 预约
    生产力
    • 讨论
    • 批核
    • IoT物联网
    • VoIP
    • 知识库
    • WhatsApp
    第三方应用软件 Odoo 定制 Odoo云端平台
  • 行业
    零售
    • 书店
    • 服装店
    • 家具店
    • 食品杂货店
    • 五金店
    • 玩具店
    餐饮与酒店服务
    • 酒吧及酒馆
    • 餐厅
    • 快餐
    • 民宿
    • 饮品分销商
    • 酒店
    房地产
    • 房地产代理
    • 建筑师事务所
    • 建造业
    • 地产管理
    • 园艺
    • 业主协会
    咨询
    • 会计师事务所
    • Odoo合作伙伴
    • 市场推广公司
    • 律师事务所
    • 人才招聘
    • 审核 & 认证
    制造
    • 纺织
    • 金属
    • 家具
    • 食品
    • 啤酒厂
    • 企业礼品
    保健与健身
    • 体育俱乐部
    • 眼镜店
    • 健身中心
    • 健康从业者
    • 药房
    • 发型屋
    商贸服务
    • 维修人员
    • IT 硬件及支持
    • 太阳能系统
    • 鞋匠
    • 清洁服务
    • 暖通空调服务
    其他
    • 非营利组织
    • 环境机构
    • 广告牌租赁
    • 摄影服务
    • 自行车租赁
    • 软件经销商
    浏览所有行业
  • 社区
    学习
    • 教学视频
    • 文档
    • 认证
    • 培训
    • 博客
    • 播客
    赋能教育
    • 教育计划
    • Scale Up! 商业游戏
    • 参观Odoo
    获取软件
    • 下载
    • 版本对比
    • 发布
    合作
    • Github
    • 论坛
    • 近期活动
    • 翻译
    • 成为合作伙伴
    • 合作伙伴服务
    • 注册您的会计事务所
    获取服务
    • 寻找合作伙伴
    • 查找会计服务
    • 预约顾问咨询
    • 安装及推行服务
    • 客户参考
    • 支持
    • 升级
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    获取演示
  • 定价
  • 技术支持

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • 客户关系管理
  • e-Commerce
  • 会计
  • 库存
  • PoS
  • 项目
  • MRP
All apps
只限注册用戶才可与社群互动。
所有帖文 人 徽章
标签 (查看所有)
odoo accounting v14 pos v15
关于此论坛区
只限注册用戶才可与社群互动。
所有帖文 人 徽章
标签 (查看所有)
odoo accounting v14 pos v15
关于此论坛区
帮助

Fail2ban not detecting failing logins from Odoo 11 log

订阅

此帖文有活动时,接收通知

此问题已终结
securityfail2banV11
8 回复
13883 查看
形象
Yenthe Van Ginneken (Mainframe Monkey)

Hi there,

Recently Odoo has made a commit to improve the way failing logins are handled. Thanks to this commit it should be possible to configure and use fail2ban security very easily in V11. This fix was introduced at https://github.com/odoo/odoo/commit/86ffb549bf80b054f8bb5131c52d3e7757accb29 
No matter what I try the Fail2ban does not seem to detect the logfile changes and does not invoke the auto ban functionalities. This is how I've configured fail2ban:

1. Install fail2ban:

sudo apt-get install fail2ban

2. Copy the default fail2ban file:

cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

3. Add in the file:

[odoo-login]
    enabled = true
    port = http,https
    bantime = 900  ; 15 min ban
    maxretry = 4  ; if 4 attempts
    findtime = 600  ; within 10 min
    logpath = /var/log/odoo11/odoo11-server.log

4. Create a custom filter.d record:

nano /etc/fail2ban/filter.d/odoo-login.local

5. Add in the following content:

[Definition]
    failregex = ^ \d+ INFO \S+ \S+ Login failed for db:\S+ login:\S+ from <HOST>
    ignoreregex =

6. Reload fail2ban:

sudo fail2ban-client reload


However when I now make multiple failing logins within a minute nothing is being logged in /var/log/fail2ban.log.
The Odoo log contains new lines that show the failing logins and I do see the configuration is loaded and applied for fail2ban:

2018-05-29 09:08:18,601 fail2ban.actions        [1048]: INFO    Set banTime = 900
2018-05-29 09:08:18,605 fail2ban.filter         [1048]: INFO    Set maxRetry = 4
2018-05-29 09:08:18,605 fail2ban.filter         [1048]: INFO    Set jail log file encoding to UTF-8
2018-05-29 09:08:18,613 fail2ban.filter         [1048]: INFO    Added logfile = /var/log/odoo11/odoo11-server.log
2018-05-29 09:08:18,617 fail2ban.filter         [1048]: INFO    Set findtime = 600
2018-05-29 09:08:18,636 fail2ban.jail           [1048]: INFO    Jail 'sshd' started
2018-05-29 09:08:18,655 fail2ban.jail           [1048]: INFO    Jail 'odoo-login' started
Does anybody have any idea what I am missing or what might be wrong?

Regards,
Yenthe


5
形象
丢弃
形象
Yenthe Van Ginneken (Mainframe Monkey)
编写者 最佳答案

Hi all,

There are already two answers but I was not able to pinpoint the issue with both. Here are the steps to configure fail2ban with Odoo:

1. Install fail2ban:

sudo apt-get install fail2ban

2. Copy the default jail.conf file:

sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
3. Edit the copied file:
sudo nano /etc/fail2ban/jail.local

4. Add the following code at the end of the file and then save it:

[odoo-login]
enabled = true
port = http,https
bantime = 90000  ; 15 min ban
maxretry = 5  ; if 5 attempts
findtime = 7260  ; within 1 min - by default fail2ban is in local time so 1h diff
logpath = /var/log/odoo/odoo-server.log ; be sure it matches with your logfile location
5. Create an odoo-login local file:
/etc/fail2ban/filter.d/odoo-login.local

6. Add in the following definition in the file:

[Definition]
failregex = ^ \d+ INFO \S+ \S+ Login failed for db:\S+ login:\S+ from <HOST>
ignoreregex =
7. Restart the fail2ban client:
sudo fail2ban-client restart

If you would now make more than 5 invalid login attempts you'll see a notice with a "BAN" in the logfile of the fail2ban log. See /var/log/fail2ban.log

Regards,
Yenthe

3
形象
丢弃
形象
Nils
最佳答案

Hey Folks,

is there any reliable work-around for this? I am facing the same issue and tried several approaches already.

My regex file is manyually tested with the logfile and its working fine, matching the login attemps. For some reason, its not handed over to f2b properly and its not taking notice of the bad login attempt.

I am testing on V14 CE with f2b 0.11.1... f2b is working well with the standard jails (ssh for example), the IP of the logging user is handed over correctly and not translated to the localhost by nginx. This is what the Odoo-log is presenting. Same with system-log.

Would be great to hear if there is any progress.

1
形象
丢弃
形象
Andreas Perhab
最佳答案

As an update to this answer, these days i discovered another Log line was added a few versions ago that we added to our fail2ban config: https://github.com/odoo/odoo/blob/17.0/addons/auth_signup/controllers/main.py#L88

_logger.info(
"Password reset attempt for by user from %s",
login, request.env.user.login, request.httprequest.remote_addr)


we now have the following fail2ban filter:

failregex = ^.*Login failed for db:[^ ]* login:[^ ]* from .*$
^.*Password reset attempt for \S+ by user \S+ from .*$
0
形象
丢弃
形象
Lewi S. Kristianto
最佳答案

experiencing this also, in environment centos 7, but found out that checking regex in https://regexr.com/ worked, 

seem fail2ban not recognize \S+
# fail2ban-regex  -v "/var/log/messages" "/etc/fail2ban/filter.d/odoo-login.conf"
-> not working

need to modify /etc/fail2ban/filter/odoo-login.conf:
[Definition]
#string log -> Oct  7 14:07:38 support journal: Odoo Server 12.0:HR:INFO:odoo.addons.base.models.res_users:Login failed for db:HR login:123 from x.x.x.x
#failregex = ^ \d+ INFO \S+ \S+Login failed for db:\S+ login:\S+ from <HOST>
failregex :Login failed for db:\S+ login:\S+ from <HOST>$
ignoreregex =

file /etc/fail2ban/jail.d/odoo-login.conf
[odoo-login]
enabled = true
filter = odoo-login
action = iptables-multiport-tcp[name=odoo-login, port="80,443", protocol=tcp]
                mail-whois-lines[name=odoo-login, dest=root, sender=fail2ban]
logpath = /var/log/messages
findtime = 7200
bantime = 7200
maxretry = 10

in /etc/odoo12.conf, require to add:
syslog = True

0
形象
丢弃
形象
Ryanto The
最佳答案

Telling fail2ban that odoo log is in UTC is better than adding time difference to bantime and/or findtime. I use the following conf in jail.local file. (Tested on Odoo v11 and Fail2ban v0.10.2)

[odoo-login]
enabled = true
port = http,https
bantime = 15m ; this syntax only works on fail2ban v0.10, else use number in seconds
maxretry = 5 ; if 5 attempts
findtime = 1m ; within 1 min
logpath = /var/log/odoo/odoo-server.log ; be sure it matches with your logfile location
logtimezone = UTC ; tell fail2ban that odoo log time is in UTC
0
形象
丢弃
形象
Roberto Barreiro
最佳答案

In my case, seems that fail2ban option logtimezone = UTC doesn't works. I'm at GMT+2, and setting findtime = 10800 (3 hours) at odoo jail, solves the issue.

0
形象
丢弃
形象
Ermin Trevisan
最佳答案

The regex expression does not match. Try the following with a regex tester:

INFO \S+ \S+ Login failed for db:\S+ login:\S+
0
形象
丢弃
Yenthe Van Ginneken (Mainframe Monkey)
编写者

Actually it does match (see https://pythex.org/?regex=%5Cd%2B INFO %5CS%2B %5CS%2B Login failed for db%3A%5CS%2B login%3A%5CS%2B from &test_string=2018-05-29 08%3A36%3A21%2C970 1439 INFO test odoo.addons.base.res.res_users%3A Login failed for db%3Atest login%3Ademo from 127.0.0.1&ignorecase=0&multiline=0&dotall=0&verbose=0)

and you need <HOST> for fail2ban which I assume is parsed to the actual IP from the person trying to login?

Ermin Trevisan

In my Odoo log I do not have "from <host>" at the end of the line.

Yenthe Van Ginneken (Mainframe Monkey)
编写者

Did you test on an 11.0 with the commit from https://github.com/odoo/odoo/commit/86ffb549bf80b054f8bb5131c52d3e7757accb29 though? It has only been introduced 13 days ago

Ermin Trevisan

I did test with the latest nightly build (deb).

Ermin Trevisan

...from today, I meant.

Yenthe Van Ginneken (Mainframe Monkey)
编写者

Hmm, odd :-/ I do see it logged in the Odoo log, fail2ban just doesn't seem to detect it.

Ermin Trevisan

Sorry for the noise, now I see it also, after a -u all, finally.

Ermin Trevisan

Did you try this: https://fail2ban.readthedocs.io/en/latest/filters.html#developing-testing-a-regex ?

I will try to set up the same this evening when I'll have figured out how to do it with a remote proxy server.

Yenthe Van Ginneken (Mainframe Monkey)
编写者

Hey Ermin - did you get around to this? I did two more attempts in the evenings but I still haven't figured out my mistake :-)

Yenthe Van Ginneken (Mainframe Monkey)
编写者

Up untill now I was not able to get it working sadly.

Bill Ennals

Hi Yenthe. I thought I would comment that I tried setting this up according to the instructions from the github link you posted and it seems to work fine. I'm not a coder or sysadmin really so I'm not sure I can help, but if you can think of any info that might help, ask away.

Bill Ennals

...also, I tried the regex test as suggested by Mag. Wolfgang Taferner above and got plenty of hits. Have you tried that?

Yenthe Van Ginneken (Mainframe Monkey)
编写者

I did try the regex from Wolfgang but that didn't work either. So with the message from Olivier Dony (https://github.com/odoo/odoo/commit/86ffb549bf80b054f8bb5131c52d3e7757accb29) you where able to configure it? Did you see a difference with your deployment and my steps?

Bill Ennals

Yes, that's right. In the Odoo section of my jail.local file I have a line pointing to the filter (odoo-server.conf in my case) to use - "filter = odoo-server" - which I don't see in your step 3. above, though that wouldn't explain why the fail2ban-regex test is failing.

Here is a line from my odoo-server log that get's picked up by the fail2ban-regex test:

2019-01-19 03:21:34,708 1618 INFO test odoo.addons.base.res.res_users: Login failed for db:test login:a;sldfkj from 123.175.237.239

...and here is the filter that detects the failed login in the fail2ban-regex test in my installation.

# fail2ban filter configuration for odoo (on nginx)

[Definition]

failregex = ^ \d+ INFO \S+ \S+ Login failed for db:\S+ login:\S+ from <HOST>

ignoreregex =

Bill Ennals

...perhaps if you use those two things and the fail2ban-regex test doesn't register a hit, there is something awry with your fail2ban install?

Yenthe Van Ginneken (Mainframe Monkey)
编写者

Thanks Bill - guess I have to setup a new test environment and test your ideas :)

Bill Ennals

ok, good luck. FYI I used your script (actually the latest big update version from Chris001) to install 11 CE on an AWS t2-micro server with Ubuntu 16.04 and Nginx as reverse proxy.

形象
Mag. Wolfgang Taferner
最佳答案

Possible pitfalls for fail2ban and Odoo.

  • log file is too big

  • regex does not match

Test your regex and logfile with the command underneath and you should get back the proper results

fail2ban-regex -v "your_logfile" "/etc/fail2ban/filter.d/odoo.conf"

0
形象
丢弃
喜欢讨论吗?不要只阅读,加入进来!

立即创建账户,享受专属功能,与我们的精彩社区互动!

注册
相关帖文 回复 查看 活动
Mac Id restriction for Users in Odoo enterprise 已解决
security
形象
形象
1
12月 25
239
what is the differance between access right and record rules in odoo ? 已解决
security
形象
形象
形象
形象
形象
5
9月 25
16034
User Session Bug.
security
形象
0
6月 25
1175
How to resolve the Access Error issue?
security
形象
0
1月 25
2553
Lock/unlock feature in Transfers
security
形象
0
1月 25
2548
社区
  • 教学视频
  • 文档
  • 论坛
开源
  • 下载
  • Github
  • Runbot
  • 翻译
服务
  • Odoo.sh 托管
  • 支持
  • 升级
  • 自定义开发服务
  • 教育
  • 查找会计服务
  • 寻找合作伙伴
  • 成为合作伙伴
关于我们
  • 我们的公司
  • 品牌资产
  • 联系我们
  • 招聘
  • 近期活动
  • 播客
  • 博客
  • 客户
  • 法律 • 隐私
  • 安全
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo致力于为企业管理提供高效智能的开源解决方案,是全球业内高速成长的软件服务商之一,逾七百五十万用户选择Odoo进行数字化升级。通过一系列全业务链覆盖、高度集成、简单易用的商业应用,助力企业实现信息化改革、降本增效并释放公司增长潜力。

Odoo独特的价值在于是一款非常容易使用又完全集成的应用。

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now