public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Petr Khartskhaev <pkhartsk@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/sqlite] rawhide: Fix CVE-2026-119586
Date: Wed, 18 Nov 2026 15:22:06 GMT	[thread overview]
Message-ID: <179501532627.1.138027944915238791.rpms-sqlite-8dbeadd9a182@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/sqlite
            Branch : rawhide
            Commit : 8dbeadd9a182f09db2e6d4f34d0e161724e63c60
            Author : Petr Khartskhaev <pkhartsk@redhat.com>
            Date   : 2026-11-18T13:18:55+01:00
            Stats  : +312/-1 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/sqlite/c/8dbeadd9a182f09db2e6d4f34d0e161724e63c60?branch=rawhide

            Log:
            Fix CVE-2026-119586

Took upstream checkins d684ccc9ec4e41d8 and f2be7c2a98f2dc65.

Resolves: rhbz#2565593

---
diff --git a/sqlite-3.54.1-CVE-2026-119586.patch b/sqlite-3.54.1-CVE-2026-119586.patch
new file mode 100644
index 0000000..568e702
--- /dev/null
+++ b/sqlite-3.54.1-CVE-2026-119586.patch
@@ -0,0 +1,305 @@
+From 18391c1fd162300b712362468d2c3534d99f6752 Mon Sep 17 00:00:00 2001
+From: Petr Khartskhaev <pkhartsk@redhat.com>
+Date: Wed, 18 Nov 2026 12:58:43 +0100
+Subject: [PATCH] CVE-2026-119586
+
+---
+ ext/recover/sqlite3recover.c | 26 ++++++++++++------
+ src/shell.c.in               | 50 +++++++++++++++++++++++++++++++++-
+ test/misc01.sql              | 52 ++++++++++++++++++++++++++++++++++++
+ test/recover.test            |  4 +--
+ test/shellB.test             |  1 +
+ 5 files changed, 122 insertions(+), 11 deletions(-)
+ create mode 100644 test/misc01.sql
+
+diff --git a/ext/recover/sqlite3recover.c b/ext/recover/sqlite3recover.c
+index eedf178..aa5ccc9 100644
+--- a/ext/recover/sqlite3recover.c
++++ b/ext/recover/sqlite3recover.c
+@@ -539,11 +539,11 @@ static void recoverFinalize(sqlite3_recover *p, sqlite3_stmt *pStmt){
+ ** Return the sqlite3_finalizer() or sqlite3_prepare() result code
+ ** from running the zSql statement.
+ */
+-static int recoverOneStmt(sqlite3 *db, const char *zSql){
++static int recoverOneStmt(sqlite3 *db, const char *zSql, const char **pzTail){
+   sqlite3_stmt *pStmt = 0;
+   int rc;
+   if( zSql==0 ) return SQLITE_OK;
+-  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
++  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, pzTail);
+   if( rc ){
+     sqlite3_finalize(pStmt);
+     return rc;
+@@ -564,7 +564,7 @@ static int recoverOneStmt(sqlite3 *db, const char *zSql){
+ */
+ static int recoverExec(sqlite3_recover *p, sqlite3 *db, const char *zSql){
+   if( p->errCode==SQLITE_OK ){
+-    int rc = recoverOneStmt(db, zSql);
++    int rc = recoverOneStmt(db, zSql, 0);
+     if( rc ){
+       recoverDbError(p, db);
+     }
+@@ -1211,6 +1211,7 @@ static int recoverWriteSchema1(sqlite3_recover *p){
+       const char *zSql = (const char*)sqlite3_column_text(pSelect, 4);
+       char *zFree = 0;
+       int rc = SQLITE_OK;
++      const char *zTail = 0;
+ 
+       if( bVirtual ){
+         zSql = (const char*)(zFree = recoverMPrintf(p,
+@@ -1218,8 +1219,16 @@ static int recoverWriteSchema1(sqlite3_recover *p){
+             zName, zName, zSql
+         ));
+       }
+-      rc = recoverOneStmt(p->dbOut, zSql);
++      rc = recoverOneStmt(p->dbOut, zSql, &zTail);
+       if( rc==SQLITE_OK ){
++        char *pToFree = 0;
++        if( zTail && zTail[0] ){
++          int n = (int)(zTail - zSql);
++          while( n>0 && (zSql[n-1]==';' || zSql[n-1]<=' ') ){ n--; }
++          pToFree = sqlite3_mprintf("%.*s", n, zSql);
++          zSql = pToFree;
++         
++        }
+         recoverSqlCallback(p, zSql);
+         if( bTable && !bVirtual ){
+           if( SQLITE_ROW==sqlite3_step(pTblname) ){
+@@ -1228,6 +1237,7 @@ static int recoverWriteSchema1(sqlite3_recover *p){
+           }
+           recoverReset(p, pTblname);
+         }
++        sqlite3_free(pToFree);
+       }else if( rc!=SQLITE_ERROR ){
+         recoverDbError(p, p->dbOut);
+       }
+@@ -1270,7 +1280,7 @@ static int recoverWriteSchema2(sqlite3_recover *p){
+   if( pSelect ){
+     while( sqlite3_step(pSelect)==SQLITE_ROW ){
+       const char *zSql = (const char*)sqlite3_column_text(pSelect, 1);
+-      int rc = recoverOneStmt(p->dbOut, zSql);
++      int rc = recoverOneStmt(p->dbOut, zSql, 0);
+       if( rc==SQLITE_OK ){
+         recoverSqlCallback(p, zSql);
+       }else if( rc!=SQLITE_ERROR ){
+@@ -2648,7 +2658,7 @@ static void recoverStep(sqlite3_recover *p){
+           if( bUseWrapper ) recoverUninstallWrapper(p);
+         }while( p->errCode==SQLITE_NOTADB 
+              && (bUseWrapper--) 
+-             && SQLITE_OK==recoverOneStmt(p->dbIn, "ROLLBACK")
++             && SQLITE_OK==recoverOneStmt(p->dbIn, "ROLLBACK", 0)
+         );
+       }
+ 
+@@ -2713,7 +2723,7 @@ static void recoverStep(sqlite3_recover *p){
+       ** database. Regardless of whether or not an error has occurred, make
+       ** an attempt to end the read transaction on the input database.  */
+       recoverExec(p, p->dbOut, "COMMIT");
+-      rc = recoverOneStmt(p->dbIn, "END");
++      rc = recoverOneStmt(p->dbIn, "END", 0);
+       if( p->errCode==SQLITE_OK ) p->errCode = rc;
+ 
+       recoverSqlCallback(p, "PRAGMA writable_schema = off");
+@@ -2909,7 +2919,7 @@ int sqlite3_recover_finish(sqlite3_recover *p){
+   }else{
+     recoverFinalCleanup(p);
+     if( p->bCloseTransaction && sqlite3_get_autocommit(p->dbIn)==0 ){
+-      rc = recoverOneStmt(p->dbIn, "END");
++      rc = recoverOneStmt(p->dbIn, "END", 0);
+       if( p->errCode==SQLITE_OK ) p->errCode = rc;
+     }
+     rc = p->errCode;
+diff --git a/src/shell.c.in b/src/shell.c.in
+index 365fcb0..d9f81b9 100644
+--- a/src/shell.c.in
++++ b/src/shell.c.in
+@@ -4536,9 +4536,13 @@ static const char *(azHelp[]) = {
+   "   --lost-and-found TABLE   Alternative name for the lost-and-found table",
+   "   --no-rowids              Do not attempt to recover rowid values",
+   "                            that are not also INTEGER PRIMARY KEYs",
++  "   --unsafe                 Do not issue the \".safe\" command in output",
+ #endif
+ #ifndef SQLITE_SHELL_FIDDLE
+   ".restore ?DB? FILE       Restore content of DB (default \"main\") from FILE",
++#endif
++  ".safe                    Put the CLI into \"safe mode\"",
++#ifndef SQLITE_SHELL_FIDDLE
+   ".save ?OPTIONS? FILE     Write database to FILE (an alias for .backup ...)",
+ #endif
+   ".scanstats on|off|est    Turn sqlite3_stmt_scanstatus() metrics on or off",
+@@ -7902,6 +7906,7 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){
+   const char *zLAF = "lost_and_found";
+   int bFreelist = 1;              /* 0 if --ignore-freelist is specified */
+   int bRowids = 1;                /* 0 if --no-rowids */
++  int bUnsafe = 0;                /* 1 if --unsafe */
+   sqlite3_recover *p = 0;
+   int i = 0;
+ 
+@@ -7928,6 +7933,9 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){
+     }else
+     if( n<=10 && memcmp("-no-rowids", z, n)==0 ){
+       bRowids = 0;
++    }else
++    if( n<=7 && memcmp("-unsafe", z, n)==0 ){
++      bUnsafe = 1;
+     }
+     else{
+       cli_printf(stderr,"unexpected option: %s\n", azArg[i]);
+@@ -7948,6 +7956,7 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){
+   sqlite3_recover_config(p, SQLITE_RECOVER_FREELIST_CORRUPT,(void*)&bFreelist);
+ 
+   cli_printf(pState->out, ".dbconfig defensive off\n");
++  if( !bUnsafe ) cli_printf(pState->out, ".safe\n");
+   sqlite3_recover_run(p);
+   if( sqlite3_recover_errcode(p)!=SQLITE_OK ){
+     const char *zErr = sqlite3_recover_errmsg(p);
+@@ -9990,6 +9999,42 @@ static int dotCmdTestcase(ShellState *p){
+   return 0;
+ }
+ 
++
++/*
++** DOT-COMMAND: .safe
++** USAGE: .safe
++**
++** This command puts the CLI into "safe mode".  This command cannot be
++** undone.  The only way to restore full capabilities is to exit and
++** restart the CLI.
++**
++** Safe mode restricts SQL statements and dot-commands so that no
++** changes may be made to the filesystem other than writing to database
++** files that are already open.
++**
++**    *  The .open command is blocked unless the database is ":memory:"
++**       or the --hexdb option is used.
++**    *  The ATTACH command of SQL may not be used
++**    *  SQL functions with side effects (ex: writefile()) are blocked.
++**    *  The ".shell" and ".system" dot-commands are blocked.
++**    *  Dot-command like ".archive", ".backup", ".load", ".log", ".save"
++**       are blocked.
++**    *  Other commands with deleterious side effects are blocked.
++**
++** Unsafe actions might be simply blocked, or the CLI might issue an error
++** and exit immediately.
++**
++** CAUTION: If third-party extensions that have system side effects have
++** been loaded prior to the .safe command, the CLI has no knowledge of
++** those extensions and does not know to block them.  Unsafe actions might
++** still be possible using those third-party extension.
++*/
++static int dotCmdSafe(ShellState *p){
++  p->bSafeMode = 1;
++  p->bSafeModePersist = 1;
++  return 0;
++}
++
+ /*
+ ** Enlarge the space allocated in p->dot so that it can hold more
+ ** than nArg parsed command-line arguments.
+@@ -10004,7 +10049,6 @@ static void parseDotRealloc(ShellState *p, int nArg){
+   shell_check_oom(p->dot.abQuot);
+ }
+ 
+-
+ /*
+ ** Parse input line zLine up into individual arguments.  Retain the
+ ** parse in the p->dot substructure.
+@@ -11774,6 +11818,10 @@ static int do_meta_command(const char *zLine, ShellState *p){
+   }else
+ #endif /* !defined(SQLITE_SHELL_FIDDLE) */
+ 
++  if( c=='s' && cli_strcmp(azArg[0], "safe")==0 ){
++    rc = dotCmdSafe(p);
++  }else
++
+   if( c=='s' &&
+      (cli_strncmp(azArg[0], "scanstats",  n)==0 ||
+       cli_strncmp(azArg[0], "scanstatus", n)==0)
+diff --git a/test/misc01.sql b/test/misc01.sql
+new file mode 100644
+index 0000000..3c78aca
+--- /dev/null
++++ b/test/misc01.sql
+@@ -0,0 +1,52 @@
++# f945de7c4eb73732 2026-11-06T04:16:54Z
++# sqlite3's .recover output can smuggle shell commands into the next
++# sqlite3 run
++#
++.testcase 400
++.open --hexdb
++| size 8192 pagesize 4096 filename unk.db
++| page 1 offset 0
++|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
++|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 02   .....@  ........
++|     32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04   ................
++|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
++|     96: 00 00 00 00 0d 00 00 00 01 0f ca 00 0f ca 00 00   ................
++|   4032: 00 00 00 00 00 00 00 00 00 00 34 01 06 17 11 11   ..........4.....
++|   4048: 01 55 74 61 62 6c 65 74 31 74 31 02 43 52 45 41   .Utablet1t1.CREA
++|   4064: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 2c   TE TABLE t1(a,b,
++|   4080: 63 29 3b 0a 2e 70 72 69 6e 74 20 68 65 6c 6c 6f   c);..print hello
++| page 2 offset 4096
++|      0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00   ................
++| end unk.db
++.recover
++.check <<**END-TEST**
++.dbconfig defensive off
++.safe
++BEGIN;
++PRAGMA writable_schema = on;
++PRAGMA foreign_keys = off;
++PRAGMA encoding = 'UTF-8';
++PRAGMA page_size = '4096';
++PRAGMA auto_vacuum = '0';
++PRAGMA user_version = '0';
++PRAGMA application_id = '0';
++CREATE TABLE t1(a,b,c);
++PRAGMA writable_schema = off;
++COMMIT;
++**END-TEST**
++.testcase 401
++.recover --unsafe
++.check <<**END-TEST**
++.dbconfig defensive off
++BEGIN;
++PRAGMA writable_schema = on;
++PRAGMA foreign_keys = off;
++PRAGMA encoding = 'UTF-8';
++PRAGMA page_size = '4096';
++PRAGMA auto_vacuum = '0';
++PRAGMA user_version = '0';
++PRAGMA application_id = '0';
++CREATE TABLE t1(a,b,c);
++PRAGMA writable_schema = off;
++COMMIT;
++**END-TEST**
+diff --git a/test/recover.test b/test/recover.test
+index 7035e40..5529a52 100644
+--- a/test/recover.test
++++ b/test/recover.test
+@@ -47,8 +47,8 @@ proc recover_with_opts {opts} {
+   set sql [read $fd]
+   close $fd
+ 
+-  # Remove the ".dbconfig defensive off" line
+-  set sql [string map {".dbconfig defensive off" ""} $sql]
++  # Remove the ".dbconfig defensive off" and ".safe" lines
++  set sql [string map {".dbconfig defensive off" "" ".safe" ""} $sql]
+ 
+   forcedelete test.db2
+   sqlite3 db2 test.db2
+diff --git a/test/shellB.test b/test/shellB.test
+index 1481c86..c7d6ad2 100644
+--- a/test/shellB.test
++++ b/test/shellB.test
+@@ -68,6 +68,7 @@ do_clitest imposter1.sql
+ do_clitest sha1.sql
+ do_clitest complete_sql.sql
+ do_clitest clierrors.sql
++do_clitest misc01.sql
+ set probe $testdir/probe.txt
+ forcedelete $probe
+ set f [open $probe wb]
+-- 
+2.56.1
+

diff --git a/sqlite.spec b/sqlite.spec
index 3212bc0..34f7e12 100644
--- a/sqlite.spec
+++ b/sqlite.spec
@@ -13,7 +13,7 @@
 Summary: Library that implements an embeddable SQL database engine
 Name: sqlite
 Version: %{rpmver}
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: blessing
 URL: http://www.sqlite.org/
 
@@ -24,6 +24,8 @@ Patch1: sqlite-3.6.23-lemon-system-template.patch
 Patch2: sqlite-3.49.0-fix-lemon-missing-cflags.patch
 Patch3: sqlite-3.53.3-fix-fts3corrupt4-test.patch
 Patch4: sqlite-3.54.1-fix-ppc64le-waliter-test.patch
+# https://sqlite.org/src/info/d684ccc9ec4e41d8 and https://sqlite.org/src/info/f2be7c2a98f2dc65
+Patch5: sqlite-3.54.1-CVE-2026-119586.patch
 
 BuildRequires: make
 BuildRequires: gcc gcc-c++
@@ -176,6 +178,7 @@ This package contains the analysis program for %{name}.
 %patch -P 2 -p1
 %patch -P 3 -p1
 %patch -P 4 -p1
+%patch -P 5 -p1
 
 # The atof test is failing on the i686 architecture, when binary configured with
 # --enable-rtree option. Failing part is text->real conversion and
@@ -354,6 +357,9 @@ make test || (echo "Tests failed, printing full log..." && cat testrunner.log &&
 %endif
 
 %changelog
+* Wed Nov 18 2026 Petr Khartskhaev <pkhartsk@redhat.com> - 3.54.1-2
+- Fix CVE-2026-119586
+
 * Fri Oct 16 2026 Packit <hello@packit.dev> - 3.54.1-1
 - Update to version 3.54.1
 - Resolves: rhbz#2548711

                 reply	other threads:[~2026-11-18 15:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179501532627.1.138027944915238791.rpms-sqlite-8dbeadd9a182@fedoraproject.org \
    --to=pkhartsk@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox