Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2022-32081

CVE-2022-32081: MariaDB Use-After-Free Vulnerability

CVE-2022-32081 is a use-after-free vulnerability in MariaDB versions 10.4 through 10.7 affecting the InnoDB storage engine. This article covers technical details, affected versions, security impact, and mitigation.

Updated:

CVE-2022-32081 Overview

CVE-2022-32081 is a use-after-poison vulnerability affecting MariaDB versions 10.4 through 10.7. The flaw resides in the prepare_inplace_add_virtual function located at /storage/innobase/handler/handler0alter.cc within the InnoDB storage engine. The issue is classified under CWE-416: Use After Free and can be triggered remotely without authentication. Successful exploitation results in a denial-of-service condition against the database server. The vulnerability impacts MariaDB packages distributed in Fedora 35, 36, and 37.

Critical Impact

A remote attacker can trigger memory corruption inside the InnoDB storage engine, crashing the MariaDB server and disrupting database availability for all dependent applications.

Affected Products

  • MariaDB versions 10.4 through 10.7
  • Fedora 35, 36, and 37 (MariaDB packages)
  • NetApp products bundling affected MariaDB versions (per NTAP-20220818-0005)

Discovery Timeline

  • 2022-07-01 - CVE-2022-32081 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2022-32081

Vulnerability Analysis

The vulnerability is a use-after-poison condition inside MariaDB's InnoDB storage engine. Use-after-poison is a variant of use-after-free [CWE-416] where memory marked as poisoned by sanitizer-aware allocators is subsequently accessed. The defect lives in prepare_inplace_add_virtual, a routine that handles in-place ALTER TABLE operations adding virtual generated columns.

When the function processes column definitions during an online schema change, internal data structures referencing the new virtual columns are released or poisoned while subsequent code paths still dereference them. This leads to memory corruption and an aborted server process.

An attacker with the ability to submit crafted SQL statements can trigger the condition. The impact is limited to availability: confidentiality and integrity are not affected, but the mariadbd process terminates, taking down all hosted databases.

Root Cause

The root cause is improper lifetime management of virtual column metadata in handler0alter.cc. The prepare_inplace_add_virtual routine releases or invalidates the backing memory for a virtual column descriptor before all references to that descriptor are retired. A later access then operates on poisoned or freed memory, producing undefined behavior inside InnoDB.

Attack Vector

Exploitation requires network access to the MariaDB service and the ability to execute Data Definition Language (DDL) statements. An attacker issues a crafted ALTER TABLE ... ADD COLUMN statement with virtual generated columns that triggers the inplace path. The malformed schema change drives the InnoDB handler into the vulnerable code path, crashing the server. No memory disclosure or code execution has been demonstrated. Refer to the MariaDB Jira Issue MDEV-26420 for the technical analysis.

Detection Methods for CVE-2022-32081

Indicators of Compromise

  • Unexpected mariadbd process crashes accompanied by signal 6 (SIGABRT) or signal 11 (SIGSEGV) entries in system logs
  • AddressSanitizer or use-after-poison traces referencing prepare_inplace_add_virtual in core dumps
  • Repeated ALTER TABLE statements adding virtual columns originating from a single client session
  • Sudden Lost connection to MySQL server errors across application tiers tied to a restart of mariadbd

Detection Strategies

  • Enable the MariaDB general query log or audit plugin and alert on ALTER TABLE statements that add virtual generated columns from non-administrative accounts
  • Monitor process supervisors (systemd, Kubernetes) for restart loops of the mariadb.service unit
  • Correlate database crash timestamps with preceding DDL statements in slow query and error logs

Monitoring Recommendations

  • Forward /var/log/mariadb/mariadb.log and journalctl -u mariadb output to a central logging platform
  • Track the Aborted_clients and Uptime status variables to detect unplanned restarts
  • Apply rate limits on DDL operations from application service accounts that should not issue schema changes

How to Mitigate CVE-2022-32081

Immediate Actions Required

Patch Information

MariaDB resolved the issue in versions released after the 10.7 branch and back-ported the fix to maintained 10.4, 10.5, and 10.6 trees. Fedora published updated packages through the three Fedora Package Announcements referenced in the NVD entry. Administrators should validate the installed package version against the upstream advisory before considering the host remediated.

Workarounds

  • Revoke ALTER and CREATE privileges from application accounts that do not require schema modification
  • Place MariaDB behind a network segmentation boundary that limits client access to known application hosts
  • Disable direct internet exposure of the MariaDB TCP port (default 3306)
bash
# Configuration example: restrict ALTER privileges and verify patched version
mysql -uroot -p -e "REVOKE ALTER, CREATE ON *.* FROM 'appuser'@'%';"
mysql -uroot -p -e "SELECT VERSION();"
# Fedora package upgrade
sudo dnf upgrade --refresh mariadb mariadb-server
sudo systemctl restart mariadb

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.