Dovecot auth_cache behavior during password expiration
0 reputation · 04 Jul 2021, 08:10 UTC
0 reputation · 04 Jul 2021, 08:10 UTC
Dovecot utilizes auth_cache to store successful authentication results, reducing the load on backend password databases (passdb). This mechanism caches credentials based on the username and IP address for a duration defined by auth_cache_ttl.
In environments implementing strict least-privilege access or frequent credential rotations, there is a potential conflict between the cache TTL and the actual expiration status of a password within the underlying passdb. If a password is marked as expired or revoked in the database, the cache may continue to permit access until the entry expires naturally.
Given the current architecture of the authentication pipeline in Dovecot 2.3+, it is unclear how the system handles the intersection of cached entries and explicit expiration flags returned by a passdb plugin.
auth_cache bypass the passdb expiration check entirely for the duration of the TTL?In Dovecot 2.3 and newer, the auth_cache stores a successful authentication result keyed by the user’s mailbox name (and optionally the client IP). While an entry is still within its auth_cache_ttl, the authentication pipeline skips the pass‑database entirely. Consequently, any expiration flag returned by the passdb is ignored until the cached entry expires.
There is no built‑in option that automatically flushes the cache when a password is marked expired or revoked by the passdb. The only automatic control is the TTL you set in auth_cache_ttl. If you need immediate revocation, you must clear the cache yourself.
Dovecot provides the doveadm utility for this purpose. The command to flush the cache for a specific user is:
# Flush the cache for a single user
sudo doveadm auth cache flush [contact removed]
# Flush the cache for all users (use with caution)
sudo doveadm auth cache flush
After executing the command, the next authentication attempt for that user will hit the passdb and honor the expiration flag.
dovecot -v
Make sure you are running 2.3.x or later.
passdb_sql, passdb_ldap, passdb_file) by inspecting /etc/dovecot/dovecot.conf or running:
doveadm -n | grep -i passdb
doveadm auth cache flush command for that user.Some passdb plugins (e.g., LDAP) can notify Dovecot of attribute changes via a change‑notification mechanism, but this feature is not used to trigger an automatic auth‑cache flush. Therefore, even with change notifications, you still need to clear the cache manually if you want the expiration to take effect immediately.
Cached credentials bypass password‑expiration checks until the TTL lapses. Dovecot does not provide an automatic cache flush on expiration; the reliable method is to run doveadm auth cache flush for the affected user(s). After that, the next authentication will consult the passdb and enforce the expiration flag.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.