CVE-2021-20277

7.5 HIGH

📋 TL;DR

This vulnerability in Samba's libldb allows an attacker to crash the LDAP server process by sending LDAP requests with multiple consecutive leading spaces in attributes. This is an out-of-bounds write vulnerability that primarily affects system availability. Any system running vulnerable versions of Samba with LDAP server functionality is affected.

💻 Affected Systems

Products:
  • Samba
Versions: Samba versions before 4.13.17, 4.14.12, and 4.15.5
Operating Systems: Linux distributions including Red Hat, Fedora, Debian, Ubuntu
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects systems where Samba is configured as an LDAP server or uses libldb for LDAP operations.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete denial of service for LDAP services, potentially affecting authentication, directory lookups, and other services dependent on LDAP.

🟠

Likely Case

LDAP server process crashes, requiring service restart and causing temporary service disruption.

🟢

If Mitigated

Minimal impact with proper network segmentation and monitoring to detect and block malicious LDAP requests.

🌐 Internet-Facing: MEDIUM - Internet-facing LDAP servers are vulnerable to DoS attacks, but exploitation requires LDAP access.
🏢 Internal Only: MEDIUM - Internal LDAP servers can be targeted by authenticated users or attackers who gain internal access.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires ability to send LDAP requests to the vulnerable server, which typically requires authentication or network access to LDAP ports.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Samba 4.13.17, 4.14.12, 4.15.5 or later

Vendor Advisory: https://bugzilla.redhat.com/show_bug.cgi?id=1941402

Restart Required: Yes

Instructions:

1. Update Samba packages using your distribution's package manager. 2. For Red Hat/Fedora: 'sudo dnf update samba'. 3. For Debian/Ubuntu: 'sudo apt update && sudo apt upgrade samba'. 4. Restart Samba services: 'sudo systemctl restart smbd nmbd' (adjust for your specific Samba services).

🔧 Temporary Workarounds

Network Access Control

linux

Restrict access to LDAP ports (389, 636) to trusted networks only

sudo iptables -A INPUT -p tcp --dport 389 -s TRUSTED_NETWORK -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 389 -j DROP

LDAP Request Filtering

all

Use network filtering or WAF to block LDAP requests with excessive leading spaces

🧯 If You Can't Patch

  • Implement strict network segmentation to limit LDAP access to essential systems only
  • Deploy monitoring and alerting for LDAP server crashes or abnormal restart patterns

🔍 How to Verify

Check if Vulnerable:

Check Samba version: 'smbd --version' or 'rpm -q samba' or 'dpkg -l | grep samba'

Check Version:

smbd --version | head -1

Verify Fix Applied:

Verify version is 4.13.17+, 4.14.12+, or 4.15.5+ and test LDAP functionality

📡 Detection & Monitoring

Log Indicators:

  • LDAP server process crashes in system logs
  • Multiple Samba/LDAP service restarts
  • LDAP error logs showing malformed requests

Network Indicators:

  • LDAP requests with unusual spacing patterns
  • Multiple connection attempts to LDAP ports

SIEM Query:

source="samba.log" AND ("crash" OR "segfault" OR "out-of-bounds") OR source="auth.log" AND "ldap" AND ("failed" OR "error")

🔗 References

📤 Share & Export