CVE-2021-28041

7.1 HIGH

📋 TL;DR

This CVE describes a double-free vulnerability in ssh-agent component of OpenSSH versions before 8.5. It could allow attackers to potentially execute arbitrary code or cause denial of service in specific scenarios where they have access to the agent socket or can forward an agent to a compromised host. Systems running OpenSSH with ssh-agent enabled on affected versions are vulnerable.

💻 Affected Systems

Products:
  • OpenSSH
Versions: All versions before 8.5
Operating Systems: All operating systems running vulnerable OpenSSH versions
Default Config Vulnerable: ⚠️ Yes
Notes: Requires ssh-agent to be running and accessible. More relevant in legacy OS environments with less restrictive socket permissions.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise if attacker gains access to agent socket or forwards agent to controlled host

🟠

Likely Case

Denial of service (ssh-agent crash) or limited memory corruption in constrained environments

🟢

If Mitigated

Minimal impact if agent socket access is properly restricted and agent forwarding is disabled

🌐 Internet-Facing: LOW - Requires specific agent socket access or agent forwarding scenarios not typical for internet-facing systems
🏢 Internal Only: MEDIUM - Internal attackers with access to agent sockets or ability to forward agents could exploit this vulnerability

🎯 Exploit Status

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

Exploitation requires specific conditions: access to agent socket or ability to forward agent to attacker-controlled host. No public exploit code has been documented.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: OpenSSH 8.5 and later

Vendor Advisory: https://www.openssh.com/txt/release-8.5

Restart Required: Yes

Instructions:

1. Update OpenSSH to version 8.5 or later using your package manager. 2. For Red Hat/Fedora: 'sudo dnf update openssh'. 3. For Debian/Ubuntu: 'sudo apt update && sudo apt upgrade openssh-client openssh-server'. 4. Restart ssh-agent and sshd services.

🔧 Temporary Workarounds

Restrict ssh-agent socket permissions

linux

Limit access to ssh-agent socket to prevent unauthorized access

chmod 600 ~/.ssh/agent_socket
chown $USER:$USER ~/.ssh/agent_socket

Disable agent forwarding

all

Prevent ssh-agent from being forwarded to remote hosts

Add 'ForwardAgent no' to /etc/ssh/ssh_config and ~/.ssh/config

🧯 If You Can't Patch

  • Restrict ssh-agent socket permissions to owner-only access
  • Disable ssh-agent forwarding in SSH client configurations

🔍 How to Verify

Check if Vulnerable:

Check OpenSSH version with 'ssh -V' or 'sshd -V' and verify it's below 8.5

Check Version:

ssh -V 2>&1 | grep -o 'OpenSSH_[0-9.]*' | cut -d_ -f2

Verify Fix Applied:

Confirm OpenSSH version is 8.5 or higher using 'ssh -V' command

📡 Detection & Monitoring

Log Indicators:

  • Unexpected ssh-agent crashes
  • Memory corruption errors in system logs
  • Failed authentication attempts with agent forwarding

Network Indicators:

  • Unusual SSH connections with agent forwarding enabled
  • Multiple connection attempts to ssh-agent sockets

SIEM Query:

source="auth.log" AND ("ssh-agent" AND ("crash" OR "segfault" OR "double free"))

🔗 References

📤 Share & Export