CVE-2021-29157

7.5 HIGH

📋 TL;DR

This path traversal vulnerability in Dovecot allows attackers with local filesystem access to bypass OAuth2 authentication by tricking the system into using attacker-controlled JWT validation keys. It affects Dovecot installations using local JWT validation with the posix filesystem driver. Systems with local user access are at risk.

💻 Affected Systems

Products:
  • Dovecot
Versions: All versions before 2.3.15
Operating Systems: Linux/Unix systems running Dovecot
Default Config Vulnerable: ✅ No
Notes: Only affects configurations using OAuth2 authentication with local JWT validation and posix filesystem driver.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete authentication bypass leading to unauthorized access to email accounts and potential data exfiltration.

🟠

Likely Case

Local privilege escalation where authenticated users can access other users' email accounts.

🟢

If Mitigated

Limited impact if proper access controls and network segmentation are in place.

🌐 Internet-Facing: LOW - Requires local filesystem access, not directly exploitable over network.
🏢 Internal Only: MEDIUM - Internal attackers with shell access can exploit this vulnerability.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploit requires local filesystem access and knowledge of path traversal techniques.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 2.3.15 and later

Vendor Advisory: https://dovecot.org/security

Restart Required: Yes

Instructions:

1. Backup current configuration. 2. Update Dovecot to version 2.3.15 or later using your distribution's package manager. 3. Restart Dovecot service. 4. Verify the update was successful.

🔧 Temporary Workarounds

Disable local JWT validation

linux

Switch to remote JWT validation or disable OAuth2 authentication if not required.

# Edit dovecot.conf and remove or comment out auth_oauth2_local_jwks_path

🧯 If You Can't Patch

  • Implement strict filesystem permissions to limit access to JWT validation directories.
  • Use network segmentation to restrict access to Dovecot servers from untrusted networks.

🔍 How to Verify

Check if Vulnerable:

Check Dovecot version with 'dovecot --version' and verify it's below 2.3.15, and check if OAuth2 with local JWT validation is configured.

Check Version:

dovecot --version

Verify Fix Applied:

Verify Dovecot version is 2.3.15 or higher with 'dovecot --version' and test OAuth2 authentication functionality.

📡 Detection & Monitoring

Log Indicators:

  • Unusual authentication attempts via OAuth2
  • Failed JWT validation errors
  • Path traversal patterns in log files

Network Indicators:

  • Multiple authentication attempts from single source
  • Unusual OAuth2 token usage patterns

SIEM Query:

source="dovecot.log" AND ("authentication failure" OR "JWT validation" OR "path traversal")

🔗 References

📤 Share & Export