CVE-2022-20792 Overview
A heap buffer overflow vulnerability exists in the regex module used by the signature database load module of ClamAV. This vulnerability affects ClamAV versions 0.104.0 through 0.104.2 and LTS version 0.103.5 and prior versions. The flaw allows an authenticated, local attacker to crash ClamAV at database load time and potentially achieve arbitrary code execution as the clamav user.
Critical Impact
Successful exploitation could allow an attacker to execute arbitrary code with the privileges of the ClamAV service user, potentially compromising system security and antivirus protection capabilities.
Affected Products
- ClamAV versions 0.104.0 through 0.104.2
- ClamAV LTS version 0.103.5 and prior
- Systems with writable ClamAV database directories accessible to attackers
Discovery Timeline
- 2022-08-10 - CVE-2022-20792 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2022-20792
Vulnerability Analysis
This vulnerability stems from improper bounds checking within the regex module that handles ClamAV signature database parsing. When the signature database load module processes a specially crafted CDB (ClamAV Database) file, it fails to properly validate input boundaries before writing data to a heap-allocated buffer.
The vulnerability is classified under CWE-787 (Out-of-bounds Write) and CWE-125 (Out-of-bounds Read), indicating that both read and write operations can occur outside the intended memory boundaries. The local attack vector requires user interaction, typically through placing a malicious database file in the ClamAV database directory where it will be loaded during a signature update or service restart.
Root Cause
The root cause of this vulnerability lies in improper bounds checking within the regex module's buffer handling code. When processing signature patterns from CDB files, the module performs multi-byte write operations without adequately verifying that the destination buffer has sufficient space to accommodate the data. This oversight allows an attacker to trigger a multi-byte heap buffer overflow write condition.
Attack Vector
An attacker with local access to the system can exploit this vulnerability by placing a maliciously crafted CDB ClamAV signature database file in the ClamAV database directory. The attack sequence involves:
- Crafting a malicious CDB file with specially constructed regex patterns designed to trigger the buffer overflow
- Placing the crafted file in the ClamAV database directory (typically /var/lib/clamav/ on Linux systems)
- Waiting for or triggering a database reload operation (either through service restart, scheduled update, or manual refresh)
- Upon database load, the vulnerable regex parsing code processes the malicious patterns, causing a heap buffer overflow
- The overflow can corrupt adjacent heap memory, potentially allowing the attacker to gain code execution as the clamav user
The attack requires either authenticated local access or another vulnerability that allows file write access to the ClamAV database directory. Successful exploitation results in either denial of service (crash) or arbitrary code execution with the privileges of the ClamAV service account.
Detection Methods for CVE-2022-20792
Indicators of Compromise
- Unexpected ClamAV service crashes during database load operations
- Suspicious or unrecognized .cdb files in the ClamAV database directory
- Anomalous memory consumption patterns in the clamd or clamscan processes
- Core dumps or crash reports from ClamAV components indicating heap corruption
Detection Strategies
- Monitor file system activity in ClamAV database directories (/var/lib/clamav/, /var/clamav/, or custom paths) for unauthorized file creation
- Implement file integrity monitoring on ClamAV database directories to detect unauthorized modifications
- Review ClamAV logs for repeated database load failures or crash events
- Deploy endpoint detection rules to identify processes writing to ClamAV database directories outside of normal update operations
Monitoring Recommendations
- Enable enhanced logging for ClamAV database update operations
- Configure alerts for ClamAV service crashes or unexpected restarts
- Implement directory access auditing on ClamAV database paths
- Monitor for privilege escalation attempts from the clamav user account
How to Mitigate CVE-2022-20792
Immediate Actions Required
- Update ClamAV to version 0.105.0 or later immediately
- For LTS deployments, update to version 0.103.6 or later
- Restrict write access to ClamAV database directories to only authorized update processes
- Review recent file changes in ClamAV database directories for suspicious activity
Patch Information
ClamAV has released patched versions that address this vulnerability. According to the ClamAV Release Announcement, the following versions contain the security fix:
- ClamAV 0.105.0 and later (current stable branch)
- ClamAV 0.104.3 and later (0.104.x branch)
- ClamAV 0.103.6 and later (LTS branch)
Linux distributions have also released updates. For Gentoo users, refer to the Gentoo GLSA 202310-01 Advisory for distribution-specific guidance.
Workarounds
- Restrict file system permissions on ClamAV database directories to prevent unauthorized write access
- Configure SELinux or AppArmor policies to limit which processes can write to database directories
- Implement network segmentation to limit local access to systems running ClamAV
- Monitor and audit all file operations in ClamAV database directories until patching is complete
# Configuration example
# Restrict permissions on ClamAV database directory
chmod 755 /var/lib/clamav
chown clamav:clamav /var/lib/clamav
# Ensure only root and clamav user can modify database files
find /var/lib/clamav -type f -exec chmod 644 {} \;
find /var/lib/clamav -type f -exec chown clamav:clamav {} \;
# Verify ClamAV version after update
clamscan --version
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


