Bug 1791313 (CVE-2019-20218)

Summary: CVE-2019-20218 sqlite: selectExpander in select.c proceeds with WITH stack unwinding even after a parsing error
Product: [Other] Security Response Reporter: Guilherme de Almeida Suckevicz <gsuckevi>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: databases-maint, drizt72, erik-fedora, fedora, itamar, jstanek, mschorm, odubaj, pkubat, praiskup, rh-spice-bugs, rjones, wilmer5
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 02:24:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1791315, 1791316, 1791317, 1791591, 1791592    
Bug Blocks: 1791314    

Description Guilherme de Almeida Suckevicz 2020-01-15 14:04:29 UTC
selectExpander in select.c in SQLite 3.30.1 proceeds with WITH stack unwinding even after a parsing error.

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

Comment 1 Guilherme de Almeida Suckevicz 2020-01-15 14:06:36 UTC
Created mingw-sqlite tracking bugs for this issue:

Affects: epel-7 [bug 1791315]
Affects: fedora-all [bug 1791316]


Created sqlite tracking bugs for this issue:

Affects: fedora-all [bug 1791317]

Comment 2 Huzaifa S. Sidhpurwala 2020-01-16 08:29:08 UTC
There seems to be a reproducer in the upstream commit:

[huzaifas@babylon ~]$ cat a.sql 
CREATE TABLE v0 (a);
CREATE VIEW v2 (v3) AS WITH x1 AS (SELECT * FROM v2) SELECT v3 AS x, v3 AS y FROM v2; 
SELECT * FROM v2;
[huzaifas@babylon ~]$ sqlite3 < a.sql 
Segmentation fault (core dumped)
[huzaifas@babylon ~]$ 


Valgrind suggests that the problem is conditional jump based on uninitialized value and corresponding OOB read.

Comment 4 errata-xmlrpc 2020-11-04 00:59:37 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2020:4442 https://access.redhat.com/errata/RHSA-2020:4442

Comment 5 Product Security DevOps Team 2020-11-04 02:24:02 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-20218