CVE-2021-20227
SQLite vulnerability analysis and mitigation

Overview

A flaw was found in SQLite's SELECT query functionality (src/select.c) identified as CVE-2021-20227. The vulnerability was discovered in December 2020 and fixed in SQLite version 3.34.1 released on January 20, 2021. This vulnerability affects SQLite database installations prior to version 3.34.1 (SQLite Release, Red Hat CVE).

Technical details

The vulnerability occurs when processing a subquery with both a correlated WHERE clause and a 'HAVING 0' clause where the parent query is an aggregate. The issue arises when the WHERE clause uses an aggregate column from the outer query. If the HAVING term (0) is moved into the WHERE clause, SQLite would optimize (a=2 AND 0) to simply (0), which is logically correct but caused problems in aggregate processing for the outer query, potentially leading to a use-after-free condition (Red Hat CVE). The vulnerability has been assigned a CVSS v3.1 base score of 5.5 (Medium) with vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H (Ubuntu CVE).

Impact

A successful exploitation of this vulnerability could allow an attacker who has permission to run SQL queries on the SQLite database to cause a denial of service condition, or possibly achieve code execution if they are able to control the re-used memory. The highest threat from this vulnerability is to system availability (Red Hat CVE).

Mitigation and workarounds

The primary mitigation is to upgrade to SQLite version 3.34.1 or later. The upstream patch adds the ExprAlwaysFalse(pExpr)==0 check to the if statement before the business logic in havingToWhereExprCb() in file src/select.c (Red Hat CVE). For systems that cannot be immediately updated, there are no known workarounds that meet security criteria for ease of use and deployment (Red Hat CVE).

Additional resources


SourceThis report was generated using AI

Related SQLite vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2025-6965HIGH7.2
  • SQLiteSQLite
  • rust-analyzer
NoYesJul 15, 2025
CVE-2025-7709MEDIUM6.9
  • SQLiteSQLite
  • sqlite-libs
NoYesSep 08, 2025
CVE-2025-7458MEDIUM6.9
  • SQLiteSQLite
  • nodejs:22::v8-12.4-devel
NoYesJul 29, 2025
ELSA-2025-20936HIGHN/A
  • SQLiteSQLite
  • sqlite
NoYesNov 25, 2025
CVE-2025-52099N/AN/A
  • SQLiteSQLite
  • mingw32-sqlite-static
NoYesOct 24, 2025

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management