Bug 1777945 (CVE-2019-19244) - CVE-2019-19244 sqlite: allows a crash if a sub-select uses both DISTINCT and window functions and also has certain ORDER BY usage
Summary: CVE-2019-19244 sqlite: allows a crash if a sub-select uses both DISTINCT and ...
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2019-19244
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 1777950 1777951 1777952 1801097 1801098 1801099
Blocks: 1777948
TreeView+ depends on / blocked
 
Reported: 2019-11-28 18:42 UTC by Guilherme de Almeida Suckevicz
Modified: 2023-03-29 18:13 UTC (History)
13 users (show)

Fixed In Version: sqlite 3.31.0
Doc Type: If docs needed, set a value
Doc Text:
A flaw was found in the way SQLite handled certain types of SQL queries using DISTINCT, OVER and ORDER BY clauses. A remote attacker could exploit this flaw by providing a malicious SQL query that, when processed by an application linked to SQLite, would crash the application causing a denial of service.
Clone Of:
Environment:
Last Closed: 2021-10-25 22:13:25 UTC
Embargoed:


Attachments (Terms of Use)

Description Guilherme de Almeida Suckevicz 2019-11-28 18:42:48 UTC
sqlite3Select in select.c in SQLite 3.30.1 allows a crash if a sub-select uses both DISTINCT and window functions, and also has certain ORDER BY usage.

Reference and upstream commit:
https://github.com/sqlite/sqlite/commit/e59c562b3f6894f84c715772c4b116d7b5c01348

Comment 1 Guilherme de Almeida Suckevicz 2019-11-28 18:44:36 UTC
Created mingw-sqlite tracking bugs for this issue:

Affects: epel-7 [bug 1777951]
Affects: fedora-all [bug 1777952]


Created sqlite tracking bugs for this issue:

Affects: fedora-all [bug 1777950]

Comment 3 Mauro Matteo Cascella 2020-02-06 09:31:49 UTC
The crash is due to the assertion statement "assert( memIsValid(pRec) );" in function sqlite3VdbeExec() in vdbe.c.
pRec is a pointer to a "Mem" struct used to represent SQL values that can be stored in a database table (e.g., integers, floating point values, strings, etc).
memIsValid() is a macro defined in vdbeInt.h which checks if a Mem object represents a valid value (i.e., flag "MEM_Undefined" is not set).

It is worth noting that memIsValid() is supposed to be used inside assertion statements only, and those statements are disabled by default: "NDEBUG and SQLITE_DEBUG are opposites [..] Setting NDEBUG makes the code smaller and faster by disabling the assert() statements in the code.  So we want the default action to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG is set".

The versions of sqlite as shipped with Red Hat Enterprise Linux are compiled without SQLITE_DEBUG, so it's not possible to reproduce the crash. The invalid Mem object may still lead to undefined behaviors, though no notable defects have been observed so far.

Comment 5 Product Security DevOps Team 2020-02-06 14:09:34 UTC
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s):

https://access.redhat.com/security/cve/cve-2019-19244

Comment 7 Mauro Matteo Cascella 2020-02-10 09:14:29 UTC
Although it is not possible to reproduce the crash due to the missing assert statement, the assert condition is violated leading to undefined behaviors (e.g., use of uninitialized values). For this reason the bug has been reopened.


Note You need to log in before you can comment on or make changes to this bug.