linuxserver / docker-fail2ban

GNU General Public License v3.0
49 stars 7 forks source link

[BUG] cloudflare-token.conf "notes" field default value breaks API call #23

Closed git-n-pissed closed 3 months ago

git-n-pissed commented 7 months ago

Is there an existing issue for this?

Current Behavior

The unban action of the clouldflare-token.conf file fails. This is happening because the initial GET call to the Cloudflare API has notes in its query string, and the default value of notes is Fail2Ban <name>. The space in that value is causing the failure.

I.e. this:

# The message to include in the firewall IP banning rule.
#
notes = Fail2Ban <name>

Should be changed to this (confirmed working):

# The message to include in the firewall IP banning rule.
#
notes = Fail2Ban_<name>

You might also be able to get away with using %20, instead of an _, but I haven't tried that.

Expected Behavior

Unban action shouldn't fail

Steps To Reproduce

1.) Cause a ban 2.) View the Cloudflare dashboard and see the ban was added (Security > WAF > Tools > IP Access Rules) 3.) Wait the required unban time (default is 10 minutes) 4.) View the fail2ban.log and verify that an unban was attempted 5.) View the Cloudflare dashboard and see that the ban still exists

Environment

- OS: Ubuntu Server 22.04
- How docker service was installed: Docker Compose

CPU architecture

x86-64

Docker creation

version: '3.6'
services:
  fail2ban:
    image: linuxserver/fail2ban:1.0.2
    container_name: fail2ban
    restart: always
    network_mode: host
    cap_add:
      - NET_ADMIN
      - NET_RAW
    environment:
      - PUID=0
      - PGID=0
      - TZ=Etc/UTC
      - VERBOSITY=-vv
    volumes:
      # Redacted, inconsequential

Container logs

2024-03-02 08:13:49,476 7F7774227B48 INFO  Starting Fail2ban v1.0.2
 2024-03-02 08:13:49,477 7F7772921B38 INFO  Observer start...
 2024-03-02 08:13:49,479 7F7774227B48 INFO  Connected to fail2ban persistent database '/config/fail2ban/fail2ban.sqlite3'
 2024-03-02 08:13:49,480 7F7774227B48 INFO  Creating new jail 'example_app'
 2024-03-02 08:13:49,483 7F7774227B48 INFO  Jail 'example_app' uses poller {}
 2024-03-02 08:13:49,484 7F7774227B48 INFO  Initiated 'polling' backend
 2024-03-02 08:13:49,485 7F7774227B48 INFO    maxRetry: 5
 2024-03-02 08:13:49,485 7F7774227B48 INFO    findtime: 600
 2024-03-02 08:13:49,485 7F7774227B48 INFO    banTime: 600
 2024-03-02 08:13:49,485 7F7774227B48 INFO    encoding: UTF-8
 2024-03-02 08:13:49,486 7F7774227B48 INFO  Added logfile: '/remotelogs/example_app/example_app.log' (pos = 359928, hash = 22499f352d6720a30ca01927965e88bd737c2848)
 2024-03-02 08:13:49,572 7F7774227B48 INFO  Jail 'example_app' started
 2024-03-02 08:14:33,615 7F77723D4B38 INFO  [example_app] Found 2607:f8b0:4005:0802:0000:0000:0000:200e - 2024-03-02 08:14:33
 2024-03-02 08:14:38,818 7F77723D4B38 INFO  [example_app] Found 2607:f8b0:4005:0802:0000:0000:0000:200e - 2024-03-02 08:14:38
 2024-03-02 08:14:43,420 7F77723D4B38 INFO  [example_app] Found 2607:f8b0:4005:0802:0000:0000:0000:200e - 2024-03-02 08:14:43
 2024-03-02 08:14:47,622 7F77723D4B38 INFO  [example_app] Found 2607:f8b0:4005:0802:0000:0000:0000:200e - 2024-03-02 08:14:47
 2024-03-02 08:14:52,225 7F77723D4B38 INFO  [example_app] Found 2607:f8b0:4005:0802:0000:0000:0000:200e - 2024-03-02 08:14:52
 2024-03-02 08:14:52,778 7F77721CDB38 NOTIC [example_app] Ban 2607:f8b0:4005:0802:0000:0000:0000:200e
 2024-03-02 08:24:52,026 7F77721CDB38 NOTIC [example_app] Unban 2607:f8b0:4005:0802:0000:0000:0000:200e
github-actions[bot] commented 7 months ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

LinuxServer-CI commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 2 months ago

This issue is locked due to inactivity