In SQLite through 3.31.1, the ALTER TABLE implementation has a use-after-free, as demonstrated by an ORDER BY clause that belongs to a compound SELECT statement.
https://www3.sqlite.org/cgi/src/info/b64674919f673602
https://www.sqlite.org/src/info/d09f8c3621d5f7f8
https://security.netapp.com/advisory/ntap-20200416-0001/
https://www.oracle.com/security-alerts/cpujul2020.html
https://security.gentoo.org/glsa/202007-26
https://security.FreeBSD.org/advisories/FreeBSD-SA-20:22.sqlite.asc
https://www.oracle.com/security-alerts/cpuoct2020.html
https://www.oracle.com/security-alerts/cpujan2021.html
https://www.oracle.com/security-alerts/cpuApr2021.html
https://www.tenable.com/security/tns-2021-14
https://cert-portal.siemens.com/productcert/pdf/ssa-389290.pdf
Source: MITRE
Published: 2020-04-09
Updated: 2022-04-08
Type: CWE-416
Base Score: 7.5
Vector: AV:N/AC:L/Au:N/C:P/I:P/A:P
Impact Score: 6.4
Exploitability Score: 10
Severity: HIGH
Base Score: 9.8
Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Impact Score: 5.9
Exploitability Score: 3.9
Severity: CRITICAL