CVE-2021-46659 Overview
CVE-2021-46659 is a Denial of Service vulnerability affecting MariaDB database server versions prior to 10.7.2. The vulnerability exists because the database server does not properly recognize that SELECT_LEX::nest_level is local to each VIEW, leading to an application crash condition. This flaw allows a local authenticated attacker to cause the MariaDB server to crash, resulting in service disruption.
Critical Impact
Local authenticated attackers can crash the MariaDB database server, causing denial of service and potential data integrity issues for applications dependent on database availability.
Affected Products
- MariaDB versions prior to 10.7.2
- Fedora 34
- Fedora 35
- Fedora 36
Discovery Timeline
- 2022-01-29 - CVE-2021-46659 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2021-46659
Vulnerability Analysis
This vulnerability is rooted in improper handling of the SELECT_LEX::nest_level variable within MariaDB's query processing engine. When processing complex queries involving VIEWs, the database server fails to properly scope the nest_level variable to each individual VIEW context. This architectural flaw leads to incorrect state management during query execution.
The vulnerability requires local access and authenticated privileges to exploit. While it does not result in data disclosure or unauthorized modifications, the high availability impact makes it a significant concern for production database environments where uptime is critical. Organizations running MariaDB as a backend for web applications or critical business services face particular risk from this vulnerability.
Root Cause
The root cause stems from improper scope management of the SELECT_LEX::nest_level variable in the MariaDB source code. The nest_level variable is intended to track the nesting depth of SELECT statements, particularly important when processing nested queries within VIEWs. However, the implementation fails to properly isolate this variable to each VIEW's context, causing incorrect tracking of query nesting levels. When multiple VIEWs are processed or when specific query patterns are executed, this scope confusion leads to an unhandled exception and subsequent application crash.
Attack Vector
The attack vector is local in nature, requiring an authenticated user with database access privileges. An attacker with the ability to execute queries against the MariaDB server can craft specific SQL statements involving VIEWs that trigger the improper nest_level handling. The exploitation does not require special administrative privileges—standard database user permissions are sufficient to trigger the crash condition.
The vulnerability is triggered through query execution rather than connection handling, meaning the attacker must have valid credentials to interact with the database. Once exploited, the entire database server process crashes, affecting all connected clients and pending transactions.
Detection Methods for CVE-2021-46659
Indicators of Compromise
- Unexpected MariaDB server crashes or restarts without apparent system resource issues
- Core dump files or crash logs referencing SELECT_LEX or nest_level in stack traces
- Sudden termination of all database connections with "server has gone away" errors
- Unusual patterns of complex VIEW queries preceding server crashes
Detection Strategies
- Monitor MariaDB error logs for crash signatures related to query processing failures
- Implement database monitoring to detect unexpected service restarts or process terminations
- Review slow query logs for unusual VIEW-related query patterns that may indicate exploitation attempts
- Deploy SentinelOne Singularity to detect process crashes and anomalous database server behavior
Monitoring Recommendations
- Enable MariaDB's general query log temporarily to identify suspicious query patterns during investigation periods
- Configure alerting on MariaDB process state changes and automatic restart events
- Monitor system logs for segmentation faults or other crash indicators from the MariaDB process
- Track database connection metrics to identify sudden mass disconnections indicative of a crash
How to Mitigate CVE-2021-46659
Immediate Actions Required
- Upgrade MariaDB to version 10.7.2 or later to remediate the vulnerability
- Review database user accounts and remove unnecessary privileges to limit potential attack surface
- Implement query monitoring to detect potentially malicious VIEW-related queries
- Consider deploying database connection pooling to facilitate faster recovery from crash events
Patch Information
MariaDB has addressed this vulnerability in version 10.7.2. Organizations should upgrade to this version or later to fully remediate the issue. For detailed information about the fix, refer to the MariaDB Issue MDEV-25631 in the MariaDB issue tracker. Additional security guidance is available at the MariaDB Security Knowledge Base.
Fedora users should apply the latest package updates as announced through the Fedora package announcements. NetApp customers should review the NetApp Security Advisory NTAP-20220311-0003 for guidance on affected NetApp products.
Workarounds
- Restrict database access to trusted users only until patching can be completed
- Implement network segmentation to limit which systems can connect to the database server
- Consider temporarily disabling or restricting access to complex VIEWs if operationally feasible
- Deploy database activity monitoring to detect and block suspicious query patterns
# Configuration example - Restrict database user privileges
# Review and limit user permissions to minimize attack surface
mysql -u root -p -e "SELECT User, Host, Select_priv, Create_view_priv FROM mysql.user;"
# Consider revoking VIEW creation privileges from non-essential users
# REVOKE CREATE VIEW ON *.* FROM 'username'@'host';
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


