Hello,
After upgrading from Dovecot 2.4.1 to 2.4.5, we noticed that for certain IMAP 
sessions, auth-policy sends two additional JSON payloads reusing the exact same 
session_id of an already authenticated session,  but with empty remote, tls: 
false, a different pwhash, and contradictory fail_type: "credentials" + 
success: true.

Here is the exact JSON captured via tcpdump for a single user ([email protected] 
from 192.0.2.10):

{"device_id":"","fail_type":"","login":"[email protected]","protocol":"imap","pwhash":"0920","remote":"192.0.2.10","session_id":"wQQK4xZhEe5ZKTkO","tls":true}
{"device_id":"","fail_type":"","login":"[email protected]","protocol":"imap","pwhash":"0920","remote":"192.0.2.10","session_id":"wQQK4xZhEe5ZKTkO","tls":true}
{"device_id":"","fail_type":"","login":"[email protected]","protocol":"imap","pwhash":"0920","remote":"192.0.2.10","session_id":"wQQK4xZhEe5ZKTkO","success":true,"policy_reject":false,"tls":true}

{"device_id":"","fail_type":"","login":"[email protected]","protocol":"imap","pwhash":"0708","remote":"","session_id":"wQQK4xZhEe5ZKTkO","tls":false}
{"device_id":"","fail_type":"credentials","login":"[email protected]","protocol":"imap","pwhash":"0708","remote":"","session_id":"wQQK4xZhEe5ZKTkO","success":true,"policy_reject":false,"tls":false}


Session wQQK4xZhEe5ZKTkO already succeeded with remote: "192.0.2.10" and tls: 
true, yet later triggers these two extra requests with remote: "" and tls: 
false. 
This worked cleanly in 2.4.1.

What could be triggering these extra requests without a remote IP, and how can 
we prevent them or ensure the remote IP is always included?


#doveconf -n

# 2.4.5-2+debian13 (0cbb641e3e): /etc/dovecot/dovecot.conf
# Pigeonhole version 2.4.5-2+debian13 (742bb892)
# OS: Linux 6.12.118+deb13-amd64 x86_64 Debian 13.8 
# Hostname: 
# 37 default setting changes since version 2.4.0
dovecot_config_version = 2.4.0
auth_allow_cleartext = yes
auth_allow_weak_schemes = yes
auth_cache_verify_password_with_worker = yes
auth_failure_delay = 2s
auth_mechanisms = plain login
auth_verbose = yes
default_client_limit = 10000
default_process_limit = 10000
default_vsz_limit = 8G
dovecot_storage_version = 2.4.0
first_valid_uid = 100
imap_capability {
  QUOTA = yes
}
imap_hibernate_timeout = 10s
import_environment {
  CORE_ERROR = %{env:CORE_ERROR}
  CORE_OUTOFMEM = %{env:CORE_OUTOFMEM}
  LISTEN_FDS = %{env:LISTEN_FDS}
  LISTEN_PID = %{env:LISTEN_PID}
  MALLOC_MMAP_THRESHOLD_ = 131072
  NOTIFY_SOCKET = %{env:NOTIFY_SOCKET}
  PATH = %{env:PATH}
  TZ = :/etc/localtime
}
log_timestamp = %Y-%m-%d %H:%M:%S
login_log_format_elements = user=<%{user}> method=%{mechanism} rip=%{remote_ip} 
lip=%{local_ip} rrip=%{real_remote_ip} lport=%{local_port} pid=%{mail_pid} 
%{secured} %{ssl_security}
login_trusted_networks = 
mail_compress_write_method = gz
mail_driver = maildir
mail_fsync = always
mail_gid = 8
mail_home = /home/virtual0/%{user | domain}/%{user | username}
mail_nfs_index = yes
mail_nfs_storage = yes
mail_path = ~/Maildir
mail_plugins {
  notify = yes
  quota = yes
  trash = yes
  mail_log = yes
  mail_compress = yes
  quota_clone = yes
}
mail_privileged_group = mail
mail_uid = 150
mmap_disable = yes
passdb_default_password_scheme = MD5-CRYPT
protocols {
  imap = yes
  lmtp = yes
  sieve = yes
  pop3 = yes
}
quota_status_nouser = DUNNO
quota_status_overquota = 552 5.2.2 The email account that you tried to reach is 
over quota
quota_status_success = DUNNO
sieve_global_extensions {
  vnd.dovecot.report = yes
  vnd.dovecot.environment = yes
}
sieve_plugins {
  sieve_imapsieve = yes
  sieve_extprograms = yes
}
sql_driver = mysql
ssl_min_protocol = TLSv1
verbose_proctitle = yes
service auth-worker {
  process_limit = 256
}
mysql sql.test.com {
  dbname = postfix
  password = # hidden, use -P to show it
  user = postfix
}
passdb sql {
  query = SELECT username as user, password FROM mailbox m INNER JOIN domain d 
ON m.domain = d.domain WHERE m.username = '%{user}' AND m.active = '1' AND 
d.active = '1'
}
userdb sql {
  iterate_query = SELECT username FROM mailbox WHERE active = '1'
  query = SELECT concat(quota, 'B') AS quota_storage_size  FROM mailbox WHERE 
username = '%{user}' AND active = '1'
}
ssl_server {
  cert_file = # hidden
  dh_file = /etc/dovecot/dh.pem
  key_file = # hidden, use -P to show it
}
maildir {
  stat_dirs = yes
}
auth_policy {
  check_after_auth = yes
  hash_nonce = # hidden, use -P to show it
  reject_on_fail = no
  server_url = http://srv.com:8000
  http_client_request_absolute_timeout = 2s
  http_client_request_timeout = 2s
}
last_login {
  key = # hidden, use -P to show it
  precision = s
  dict proxy {
    name = mysql_dict
  }
}
dict_server {
  dict mysql_dict {
    driver = sql
    sql_driver = mysql
    dict_map "shared/last-login/$service/$user/$remote_ip" {
      sql_table = last_login
      dict_map_value_field last_access {
        type = uint
      }
      dict_map_key_field userid {
        value = $user
      }
      dict_map_key_field service {
        value = $service
      }
      dict_map_key_field last_ip {
        value = $remote_ip
      }
    }
    dict_map priv/quota/messages {
      sql_table = quota2
      username_field = username
      dict_map_value_field messages {
      }
    }
    dict_map priv/quota/storage {
      sql_table = quota2
      username_field = username
      dict_map_value_field bytes {
      }
    }
  }
}
protocol lmtp {
  auth_username_format = %{user}
  mail_plugins {
    sieve = yes
  }
}
service lmtp {
  process_min_avail = %{system:cpu_count}
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0600
    user = postfix
  }
}
service dict {
  unix_listener dict {
    mode = 0600
    user = vmail
  }
}
mailbox Spam {
  sieve_script report-spam {
    cause = copy
    path = /etc/dovecot/sieve/report-spam.sieve
    type = before
  }
}
imapsieve_from Spam {
  sieve_script report-ham {
    cause = copy
    path = /etc/dovecot/sieve/report-ham.sieve
    type = before
  }
}
sieve_script personal {
  active_path = ~/.dovecot.sieve
  driver = file
  path = ~/sieve
}
sieve_script default {
  driver = file
  name = default
  path = /etc/dovecot/sieve/default.sieve
  type = default
}
quota_clone {
  dict proxy {
    name = mysql_dict
  }
}
quota user {
  mail_log_events = delete undelete expunge copy mailbox_delete mailbox_rename
  mail_log_fields = uid box msgid size
  driver = count
  mailbox_message_count = 100000
  message_count = 300000
  quota_warning warn-95 {
    quota_storage_percentage = 95
    execute quota-warning {
      args = 95 %{user}
    }
  }
  quota_warning warn-80 {
    quota_storage_percentage = 80
    execute quota-warning {
      args = 80 %{user}
    }
  }
}
service quota-warning {
  executable = script /usr/local/bin/quota-warning.sh
  user = vmail
  unix_listener quota-warning {
    mode = 0660
    user = vmail
  }
}
service quota-status {
  executable = /usr/lib/dovecot/quota-status -p postfix
  process_min_avail = %{system:cpu_count}
  unix_listener /var/spool/postfix/private/quota-status {
    group = postfix
    mode = 0666
    user = postfix
  }
}
service anvil {
  client_limit = 55000
  unix_listener anvil-auth-penalty {
    mode = 0
  }
}
service auth {
  client_limit = 60000
  user = root
  unix_listener auth-userdb {
    group = mail
    mode = 0660
    user = vmail
  }
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
  }
  unix_listener auth-master {
    group = mail
    mode = 0660
    user = vmail
  }
}
service imap-login {
  process_min_avail = %{system:cpu_count}
  restart_request_count = unlimited
  vsz_limit = 1G
}
service pop3-login {
  restart_request_count = unlimited
}
service managesieve-login {
  process_min_avail = %{system:cpu_count}
  restart_request_count = 1
}
service imap {
  extra_groups = $SET:default_internal_group
  process_limit = 4096
  process_min_avail = %{system:cpu_count}
  vsz_limit = 2G
  unix_listener imap-master {
    user = $SET:default_internal_user
  }
}
service imap-hibernate {
  unix_listener imap-hibernate {
    group = $SET:default_internal_group
    mode = 0660
  }
}
service pop3 {
  process_min_avail = %{system:cpu_count}
}
service stats {
  unix_listener stats-reader {
    mode = 0660
    user = vmail
  }
  unix_listener stats-writer {
    mode = 0666
    user = vmail
  }
}
protocol imap {
  mail_max_userip_connections = 16
  mail_plugins {
    imap_quota = yes
    imap_sieve = yes
    imap_filter_sieve = yes
    trash = yes
    last_login = yes
  }
}
protocol pop3 {
  mail_plugins {
    last_login = yes
  }
  pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
  pop3_fast_size_lookups = yes
  pop3_no_flag_updates = yes
}
namespace inbox {
  mail_driver = maildir
  mail_inbox_path = ~/Maildir
  mail_path = ~/Maildir
  inbox = yes
  list = yes
  subscriptions = yes
  mailbox Sent {
    auto = subscribe
    special_use = "\\Sent"
    trash_priority = 0
  }
  mailbox "Sent Messages" {
    special_use = "\\Sent"
    trash_priority = 0
  }
  mailbox Drafts {
    auto = subscribe
    special_use = "\\Drafts"
    trash_priority = 0
  }
  mailbox Trash {
    auto = subscribe
    special_use = "\\Trash"
    quota_ignore = yes
    trash_priority = 1
  }
  mailbox Spam {
    auto = subscribe
    special_use = "\\Junk"
    quota_ignore = yes
    trash_priority = 2
  }
  mailbox "Deleted Messages" {
    auto = no
    special_use = "\\Trash"
    trash_priority = 0
  }
  mailbox Junk {
    special_use = "\\Junk"
    trash_priority = 0
  }
  mailbox "Junk E-mail" {
    auto = no
    special_use = "\\Junk"
    trash_priority = 0
  }
  mailbox virtual/All {
    special_use = "\\All"
    trash_priority = 0
  }
}
metric imap_select_no {
  filter = event=imap_command_finished AND cmd_name=SELECT AND 
tagged_reply_state=NO
}
metric imap_select_no_notfound {
  filter = event=imap_command_finished AND cmd_name=SELECT AND 
tagged_reply="NO*Mailbox doesn't exist:*"
}
metric storage_http_gets {
  filter = event=http_request_finished AND category=storage AND method=get
}
metric imap_command {
  filter = event=imap_command_finished AND tagged_reply_state=OK
  metric_group_by cmd_name {
  }
}
_______________________________________________
dovecot mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to