CVE-2021-3695 Overview
CVE-2021-3695 is an out-of-bounds write vulnerability affecting GNU GRUB2, the widely used bootloader for Linux systems. A crafted 16-bit grayscale PNG image can trigger heap memory corruption, potentially allowing attackers to achieve arbitrary code execution and bypass secure boot protections. This vulnerability poses a significant risk to enterprise environments where secure boot is a critical security control.
Critical Impact
This vulnerability can be exploited to corrupt heap data, potentially leading to arbitrary code execution and secure boot bypass, though exploitation requires high complexity due to heap layout constraints.
Affected Products
- GNU GRUB2 (versions prior to grub-2.12)
- Fedora 36
- Red Hat Enterprise Linux 8.0, 8.1, 8.2, 8.4, 8.6, 9.0
- Red Hat Enterprise Linux EUS 8.2, 8.4, 8.6, 9.0
- Red Hat OpenShift Container Platform 4.6, 4.9, 4.10
- Red Hat Developer Tools 1.0
- Red Hat CodeReady Linux Builder
- NetApp ONTAP Select Deploy Administration Utility
Discovery Timeline
- 2022-07-06 - CVE-2021-3695 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2021-3695
Vulnerability Analysis
This vulnerability exists in GRUB2's PNG image processing code, specifically when handling 16-bit grayscale PNG images. When a specially crafted PNG image is processed, the bootloader fails to properly validate image dimensions or pixel data, leading to an out-of-bounds write condition in the heap memory area.
The vulnerability is classified as CWE-787 (Out-of-bounds Write). Exploitation requires local access and has high complexity because the attacker must carefully manipulate the heap layout to achieve meaningful results. Additionally, the values written to memory are repeated three times consecutively, making it challenging to construct valid exploit payloads. Despite these constraints, successful exploitation can lead to heap data corruption, arbitrary code execution, and circumvention of secure boot protections—a critical security mechanism for system integrity.
Root Cause
The root cause lies in improper bounds checking within GRUB2's PNG decoder when processing 16-bit grayscale images. The code fails to validate that pixel data remains within allocated buffer boundaries, allowing write operations to overflow into adjacent heap memory. This memory safety issue is typical of vulnerabilities in low-level C code that handles complex file format parsing without adequate input validation.
Attack Vector
Exploitation of this vulnerability requires local access to the target system. An attacker must be able to place a malicious PNG image in a location where GRUB2 will process it during boot, such as the boot partition's theme or background image directories. The attack scenario involves:
- The attacker crafts a malicious 16-bit grayscale PNG image with specific dimensions and pixel data designed to trigger the overflow
- The malicious image is placed in a GRUB2 theme directory or configured as a boot background
- During system boot, GRUB2 processes the PNG image, triggering the heap overflow
- Through heap manipulation, the attacker can potentially corrupt critical data structures or achieve code execution
The vulnerability mechanism involves the PNG decoder allocating a buffer based on image header dimensions, then writing decompressed pixel data that exceeds the allocated buffer size. This overflow can overwrite adjacent heap metadata or application data. See the Red Hat Bug Report for additional technical details on the vulnerability.
Detection Methods for CVE-2021-3695
Indicators of Compromise
- Presence of unusual or modified PNG files in GRUB2 theme directories (/boot/grub2/themes/)
- Modified GRUB configuration files pointing to suspicious image files
- Unexpected changes to the EFI System Partition or boot partition
- Boot failures or anomalous behavior during GRUB2 image rendering
Detection Strategies
- Monitor file integrity of GRUB2 configuration and theme directories using host-based intrusion detection
- Implement Secure Boot with properly configured UEFI signature databases to detect unauthorized bootloader modifications
- Use endpoint detection solutions to monitor for changes to boot-critical files and partitions
- Audit access to the EFI System Partition and /boot directories for unauthorized modifications
Monitoring Recommendations
- Enable logging for file system changes in boot-related directories
- Implement automated integrity verification of bootloader components during system startup
- Configure alerts for any modifications to GRUB2 theme files or configuration
- Deploy SentinelOne agents to monitor for suspicious boot-time activity and file modifications
How to Mitigate CVE-2021-3695
Immediate Actions Required
- Update GRUB2 to version 2.12 or later where the vulnerability is patched
- Apply vendor-specific patches from Red Hat, Fedora, Gentoo, or NetApp as applicable to your environment
- Review and restrict write access to GRUB2 theme and configuration directories
- Verify Secure Boot is enabled and properly configured with updated signature databases
Patch Information
The vulnerability is fixed in GRUB2 version 2.12 and later. Multiple Linux distributions have released patches addressing this issue:
- Red Hat: Patches available for RHEL 8.x and 9.x series - see Red Hat Bug Report
- Gentoo: Security advisory GLSA 2022-09-12 provides patched packages
- NetApp: Security advisory NTAP-20220930-0001 addresses ONTAP Select deployments
- Fedora: Updated packages available for Fedora 36
Organizations should update their Secure Boot DBX (forbidden signatures) database after applying patches to revoke trust in vulnerable bootloader versions.
Workarounds
- Disable GRUB2 graphical themes and background images by setting GRUB_TERMINAL=console in /etc/default/grub
- Remove or restrict access to PNG files in GRUB2 theme directories
- Implement strict file system permissions on boot partitions to prevent unauthorized image placement
- Consider enabling UEFI Secure Boot with up-to-date revocation lists to block unsigned or vulnerable bootloaders
# Disable GRUB2 graphical mode as a workaround
# Edit /etc/default/grub and add:
GRUB_TERMINAL=console
# Then regenerate GRUB configuration:
grub2-mkconfig -o /boot/grub2/grub.cfg
# Verify Secure Boot status:
mokutil --sb-state
# Check current GRUB2 version:
grub2-install --version
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

