fix(plugin): deny load_extension() in the authorizer; relative vendor include
The authorizer now refuses the load_extension SQL function by name, so a build that does not define SQLITE_OMIT_LOAD_EXTENSION (the marketplace release CLI compiles vendor/sqlite3.c without it) still cannot load native code. The sqlite3.h include is relative so src/ and vendor/ compile in one command with no -I flags.
AuthorPico <picobot@scorpioplayer.com>
Date2026-11-11 11:32:58
Commitd123db68
Parents3a6f010f
Changed files
src/plugin_sqlite.c+8−1■■■■■
1 file+8−1
Diff
src/plugin_sqlite.c+8−1■■■■■
index 01c8ec9..624c641 100644
--- a/src/plugin_sqlite.c
+++ b/src/plugin_sqlite.c
@@ -65,7 +65,9 @@
6565 # define SX_ISDIR(m) S_ISDIR(m)
6666 #endif
6767
68-#include "sqlite3.h"
68+/* Relative include so the tree also builds without -I flags (the marketplace
69+ * release CLI compiles every src and vendor C file in one command). */
70+#include "../vendor/sqlite3.h"
6971
7072 #define PLUGIN_SLUG "sqlite"
7173 #define PLUGIN_ID "plugin_sqlite"
@@ -507,6 +509,11 @@ static int authorizer_cb(void *ud, int action, const char *a1, const char *a2,
507509 case SQLITE_RECURSIVE:
508510 return SQLITE_OK;
509511 case SQLITE_FUNCTION:
512+ /* Extension loading is off by default and we never enable it, but a
513+ * binary built without -DSQLITE_OMIT_LOAD_EXTENSION could still reach
514+ * the function entry point. Name it and refuse it. */
515+ if (a2 && ci_prefix(a2, "load_extension") && !a2[14])
516+ return SQLITE_DENY;
510517 return SQLITE_OK;
511518 case SQLITE_PRAGMA:
512519 return pragma_allowed(a1) ? SQLITE_OK : SQLITE_DENY;
513520
src/plugin_sqlite.c+8−1■■■■■
index 01c8ec9..624c641 100644index 01c8ec9..624c641 100644
--- a/src/plugin_sqlite.c--- a/src/plugin_sqlite.c
+++ b/src/plugin_sqlite.c+++ b/src/plugin_sqlite.c
@@ -65,7 +65,9 @@@@ -65,7 +65,9 @@
65 # define SX_ISDIR(m) S_ISDIR(m)65 # define SX_ISDIR(m) S_ISDIR(m)
66 #endif66 #endif
67 67
68-#include "sqlite3.h"68+/* Relative include so the tree also builds without -I flags (the marketplace
69+ * release CLI compiles every src and vendor C file in one command). */
70+#include "../vendor/sqlite3.h"
69 71
70 #define PLUGIN_SLUG "sqlite"72 #define PLUGIN_SLUG "sqlite"
71 #define PLUGIN_ID "plugin_sqlite"73 #define PLUGIN_ID "plugin_sqlite"
@@ -507,6 +509,11 @@ static int authorizer_cb(void *ud, int action, const char *a1, const char *a2,@@ -507,6 +509,11 @@ static int authorizer_cb(void *ud, int action, const char *a1, const char *a2,
507 case SQLITE_RECURSIVE:509 case SQLITE_RECURSIVE:
508 return SQLITE_OK;510 return SQLITE_OK;
509 case SQLITE_FUNCTION:511 case SQLITE_FUNCTION:
512+ /* Extension loading is off by default and we never enable it, but a
513+ * binary built without -DSQLITE_OMIT_LOAD_EXTENSION could still reach
514+ * the function entry point. Name it and refuse it. */
515+ if (a2 && ci_prefix(a2, "load_extension") && !a2[14])
516+ return SQLITE_DENY;
510 return SQLITE_OK;517 return SQLITE_OK;
511 case SQLITE_PRAGMA:518 case SQLITE_PRAGMA:
512 return pragma_allowed(a1) ? SQLITE_OK : SQLITE_DENY;519 return pragma_allowed(a1) ? SQLITE_OK : SQLITE_DENY;
513520