-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Leaving the loading of extensions enabled might be a security risk #1558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I open this PR since I'm not sure of the implications: are our users expecting to being able to load extensions through SQL code; and is it a good idea to call sqlite3_enable_load_extension for disabling and enabling instead of only enabling the C-API using the newer sqlite3_db_config? |
src/sqlitedb.cpp
Outdated
if(sqlite3_load_extension(_db, filePath.toUtf8(), nullptr, &error) == SQLITE_OK) | ||
int result = sqlite3_load_extension(_db, filePath.toUtf8(), nullptr, &error); | ||
|
||
// Disable extension loading (we don't want to left the possibility of calling load_extension() from SQL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/left/leave/ :smile:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote that? My eyes hurt 😄
Using sqlite3_enable_load_extension not only allows loading extensions through the C-API but also through the SQL functioon load_extension(). That might be a security risk if the user is unaware that executing an SQL file can lead to native code execution and not only to database file modification. See issue #1551
fae12ba
to
1381a41
Compare
I don't know about That said, I just tried to run this in the Execute SQL tab load_extension('/path/to/extension.so'); and it returned a syntax error. In the SQL log and in the debugger I could see that SQLite splits this line into two statements: |
The correct syntax would be:
Another option could be a preference setting for enabling the load of extensions in SQL. By default it should be disabled (following the design decision of SQLite itself). |
Haha, you're right! I forgot about the |
Ok, I'll add the setting to the branch. |
New setting that authorizes the execution of load_extension() from SQL code. Default value, false, following the design decision of SQLite, that disables this function unless by default. Added notice about the option in the calltips of the two function variants.
When this gets merged (into |
Awesome, this is looking pretty good. Good description in the Preferences dialog too 😄 I'll merge this and cherry-pick it to the v3.11.x branch as @justinclift suggested 😄 |
…1558) * Leaving the loading of extensions enabled might be a security risk Using sqlite3_enable_load_extension not only allows loading extensions through the C-API but also through the SQL functioon load_extension(). That might be a security risk if the user is unaware that executing an SQL file can lead to native code execution and not only to database file modification. See issue #1551 * Preference for allowing loading extensions from SQL code New setting that authorizes the execution of load_extension() from SQL code. Default value, false, following the design decision of SQLite, that disables this function unless by default. Added notice about the option in the calltips of the two function variants.
Excellent. 😄 |
I just noticed that we haven't updated the translation files with the new strings present in this PR. Updating now might raise conflicts with the present or ongoing PR, so I don't know which is the best way to go. |
Update the strings in In theory, it shouldn't happen toooooo many times before release. 😄 |
There are two new strings in Preferences (an option and its tooltip) and two functions call-tips that are updated with this appendix: "Use of this function must be authorized from Preferences." Line number changes have been discarded after lupdate so the amount of changes for merging of translation pull requests are minimised.
There are two new strings in Preferences (an option and its tooltip) and two functions call-tips that are updated with this appendix: "Use of this function must be authorized from Preferences." Line number changes have been discarded after lupdate so the amount of changes for merging of translation pull requests are minimised.
Update German translation for PR #1558
Using
sqlite3_enable_load_extension
not only allows loading extensionsthrough the C-API but also through the SQL function
load_extension()
.That might be a security risk if the user is unaware that executing an
SQL file can lead to native code execution and not only to database file
modification.
See issue #1551