GeezerVison is showing github.com — sqlite: enforce permission model on file access by mcollina · Pull Request #62957 · nodejs/node
Conversation
mcollina
commented
Apr 25, 2026
•
edited by araujogui
Loading
Uh oh!
There was an error while loading. Please reload this page.
Enforce the permission model for node:sqlite file access.
open() checks --allow-fs-read for read-only databases, and read plus write for read-write ones. In-memory databases are exempt.
- When permissions are enabled, connections use a VFS shim that checks every file SQLite opens:
ATTACH targets, backup destinations, and journal, WAL and SHM files. A database grant also covers its own sidecar files.
- URI
vfs= parameters are rejected, so a connection cannot switch to an unchecked VFS.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Review requested:
- @nodejs/security-wg
- @nodejs/sqlite
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
codecov
Bot
commented
Apr 25, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
❌ Patch coverage is 65.64551% with 157 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.67%. Comparing base (55da353) to head (5a9c7a5).
⚠️ Report is 270 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #62957 +/- ##
========================================
Coverage 90.66% 90.67%
========================================
Files 799 803 +4
Lines 280245 281168 +923
Branches 54121 54263 +142
========================================
+ Hits 254097 254942 +845
- Misses 16277 16366 +89
+ Partials 9871 9860 -11
... and 113 files with indirect coverage changes
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
As long as it doesn't open precedence for reports targeting SQLite on permission model, I'm +1.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
louwers
left a comment
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
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.
Hmm, I think this needs to take into account https://sqlite.org/uri.html
- A database can be opened read-only with
mode=ro or immutable=1.
- Another way to create an in-memory database is with
mode=memory.
Doing more string processing on the database path sounds a bit hacky though.
Edit: looks like we have not enabled SQLITE_USE_URI=1, but it would be good to leave a comment here that this needs to be updated when we do at the very least.
As long as it doesn't open precedence for reports targeting SQLite on permission model, I'm +1.
Passing a custom VFS to SQLite that can really prevent reads/writes might be a more comprehensive solution worth considering...
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Passing a custom VFS to SQLite that can really prevent reads/writes might be a more comprehensive solution worth considering...
https://sqlite.org/vfs.html sounds really cool! I will take a look.
|
louwers reacted with heart emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@mcollina This needs a rebase, and the first commit needs to be signed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
araujogui
changed the title
sqlite: add permission model checks to DatabaseSync
sqlite: enforce permission model on file access
Oct 22, 2026
|
@nodejs/sqlite I rebased branch and fixed some edge cases, could you review?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@araujogui Can you rebase to edit the first commit message and body, as that will land on review.
|
araujogui reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Database opened database files without consulting the permission
model, so code running with --permission could read and write any
database regardless of --allow-fs-read and --allow-fs-write.
Check read access, and write access unless the database is read-only,
before opening a file-backed database. In-memory databases are exempt.
SQLite also opens journal, WAL and temporary files, and ATTACH and
backup() open further databases, so route every connection through a
VFS shim that checks each path SQLite opens, deletes or probes.
Reject URI filenames that select a VFS, since that would bypass the
shim, and deny ATTACH when SQLite does not pass the filename to the
authorizer.
Refs: https://hackerone.com/reports/3686625
Co-authored-by: Guilherme Araújo <[email protected]>
Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <[email protected]>
Deny ATTACH under the permission model when SQLite does not pass the
filename to the authorizer. SQLite only does so for string literals,
so a bound or computed filename could select a URI VFS and bypass the
permission VFS.
Resolve VFS paths lexically, as the permission model does, instead of
following symbolic links, and match SQLite's exact super-journal name
format.
Share one permission VFS per Environment, release it when open()
fails, skip the authorizer guards when no JavaScript callback is set,
check each path once, and reuse FSPermission::is_granted() for
side-effect-free checks.
Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <[email protected]>
A URI could select another VFS or access mode, bypassing the
permission VFS. Reject URLs and "file:" paths until URIs are supported.
Drop the URI parsing and ATTACH authorizer check this replaces, and
reuse Permission::is_granted_quiet() in the VFS.
Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <[email protected]>
|
@nodejs/sqlite @nodejs/security-wg I'm taking care of this PR. Could I get a round of reviews?
I dropped support for URI filenames when permissions are enabled. This significantly reduces needed number of workarounds and attack surface, making it easier and safer to land the first iteration. We can add URI filename support in a follow-up ofc
|
mcollina reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Backup and ATTACH denials surfaced as generic SQLite errors and were
invisible to --permission-audit. Throw ERR_ACCESS_DENIED and publish
them to the permission diagnostics channel instead.
Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <[email protected]>
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Commit Queue failed
This pull request has multiple commits, but no landing policy was selected.
Add
commit-queue-squash
PRs the Commit Queue should land as one squashed commit.
to land it as one commit, or
commit-queue-rebase
PRs the Commit Queue should land as multiple self-contained commits.
to land the commits separately.
The pull request was removed from the Commit Queue and labeled
commit-queue-failed
PRs whose Commit Queue landing failed and need manual intervention before retrying.
. After resolving the failure, remove that label and add
commit-queue
PRs queued for automated landing through the Commit Queue.
to retry.
Full Commit Queue output
�[36m⠋�[39m Loading data for nodejs/node/pull/62957
�[36m⠋�[39m Loading data for nodejs/node/pull/62957
�[36m⠋�[39m Getting collaborator contacts from README of nodejs/node
�[36m⠋�[39m Getting PR from nodejs/node/pull/62957
�[36m⠋�[39m Getting reviews from nodejs/node/pull/62957
�[36m⠋�[39m Getting comments from nodejs/node/pull/62957
�[36m⠋�[39m Getting commits from nodejs/node/pull/62957
✔ Done loading data for nodejs/node/pull/62957
----------------------------------- PR info ------------------------------------
Title sqlite: enforce permission model on file access (#62957)
Author Matteo Collina <[email protected]> (@mcollina)
Branch mcollina:sqlite-permission-checks -> nodejs:main
Labels c++, needs-ci, commit-queue, sqlite
Commits 7
- sqlite: enforce permission model in Database
- sqlite: enforce permissions through a VFS shim
- sqlite: fix permission VFS edge cases
- fixup! sqlite: fix permission VFS edge cases
- fixup! sqlite: fix permission VFS edge cases
- sqlite: disable URI filenames under permission
- sqlite: report permission VFS denials
Committers 1
- Guilherme Araújo <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/62957
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: James M Snell <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/62957
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: James M Snell <[email protected]>
--------------------------------------------------------------------------------
ℹ This PR was created on Sat, 25 Apr 2026 17:35:37 GMT
✔ Approvals: 2
✔ - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/62957#pullrequestreview-4177154770
✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/62957#pullrequestreview-5964251803
✔ Last GitHub CI successful
ℹ Last Full PR CI on 2026-11-22T16:15:06Z: https://ci.nodejs.org/job/node-test-pull-request/79405/
�[36m⠙�[39m Querying data for job/node-test-pull-request/79405/
�[36m⠙�[39m Querying data for job/node-test-pull-request/79405/
�[36m⠙�[39m Querying API for job/node-test-pull-request/79405/
✔ Last Jenkins CI successful
--------------------------------------------------------------------------------
�[36m⠹�[39m Querying API for job/node-test-pull-request/79405/
✔ No git cherry-pick in progress
✔ No git am in progress
✔ No git rebase in progress
--------------------------------------------------------------------------------
�[36m⠹�[39m Querying API for job/node-test-pull-request/79405/
�[36m⠹�[39m Bringing origin/main up to date...
From https://github.com/nodejs/node
* branch main -> FETCH_HEAD
45d1554464..1ef44440a9 main -> origin/main
✔ origin/main is now up-to-date
main is out of sync with origin/main. Mismatched commits:
- e1e867c152 src: skip the async id stack when nobody sees it
- 1ef44440a9 src: skip the async id stack when nobody sees it
--------------------------------------------------------------------------------
HEAD is now at 1ef44440a9 src: skip the async id stack when nobody sees it
✔ Reset to origin/main
�[36m⠸�[39m Downloading patch for 62957
�[36m⠸�[39m Downloading patch for 62957
From https://github.com/nodejs/node
* branch refs/pull/62957/merge -> FETCH_HEAD
✔ Fetched commits as a16ff8bb447f..5a9c7a5749a6
--------------------------------------------------------------------------------
Auto-merging src/node_sqlite.cc
[main 6ec0e203e1] sqlite: enforce permission model in Database
Author: Matteo Collina <[email protected]>
Date: Thu Apr 23 20:07:23 2026 +0000
3 files changed, 159 insertions(+)
create mode 100644 test/fixtures/permission/sqlite.db
create mode 100644 test/parallel/test-permission-sqlite.js
Auto-merging node.gyp
Auto-merging src/node_sqlite.cc
Auto-merging src/node_sqlite.h
Auto-merging src/permission/fs_permission.cc
[main 14e50f147f] sqlite: enforce permissions through a VFS shim
Author: Matteo Collina <[email protected]>
Date: Sun Jul 12 14:48:19 2026 +0000
11 files changed, 1206 insertions(+), 108 deletions(-)
create mode 100644 src/node_sqlite_vfs.cc
create mode 100644 src/node_sqlite_vfs.h
Auto-merging src/node_sqlite.cc
[main 06fbbac6ea] sqlite: fix permission VFS edge cases
Author: Matteo Collina <[email protected]>
Date: Sun Jul 12 17:44:09 2026 +0000
4 files changed, 251 insertions(+), 33 deletions(-)
Auto-merging src/node_sqlite.cc
Auto-merging src/node_sqlite.h
Auto-merging src/permission/fs_permission.cc
[main 57f7f0c701] fixup! sqlite: fix permission VFS edge cases
Author: Guilherme Araújo <[email protected]>
Date: Fri Oct 23 14:58:12 2026 -0300
6 files changed, 185 insertions(+), 171 deletions(-)
[main 631cc7b93f] fixup! sqlite: fix permission VFS edge cases
Author: Guilherme Araújo <[email protected]>
Date: Sat Oct 24 14:36:33 2026 -0300
2 files changed, 3 insertions(+), 3 deletions(-)
Auto-merging doc/api/permissions.md
Auto-merging doc/api/sqlite.md
Auto-merging src/node_sqlite.cc
Auto-merging src/permission/fs_permission.cc
[main a0ba56a531] sqlite: disable URI filenames under permission
Author: Guilherme Araújo <[email protected]>
Date: Mon Nov 16 11:39:23 2026 -0300
11 files changed, 204 insertions(+), 660 deletions(-)
Auto-merging src/node_sqlite.cc
Auto-merging src/node_sqlite.h
[main 39d20bbc80] sqlite: report permission VFS denials
Author: Guilherme Araújo <[email protected]>
Date: Mon Nov 16 11:48:55 2026 -0300
5 files changed, 134 insertions(+), 19 deletions(-)
✔ Patches applied
There are 7 commits in the PR. Attempting autorebase.
(node:917) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/12)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
sqlite: enforce permission model in Database
Database opened database files without consulting the permission
model, so code running with --permission could read and write any
database regardless of --allow-fs-read and --allow-fs-write.
Check read access, and write access unless the database is read-only,
before opening a file-backed database. In-memory databases are exempt.
SQLite also opens journal, WAL and temporary files, and ATTACH and
backup() open further databases, so route every connection through a
VFS shim that checks each path SQLite opens, deletes or probes.
Reject URI filenames that select a VFS, since that would bypass the
shim, and deny ATTACH when SQLite does not pass the filename to the
authorizer.
Refs: https://hackerone.com/reports/3686625
Co-authored-by: Guilherme Araújo <[email protected]>
Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/62957
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: James M Snell <[email protected]>
--------------------------------------------------------------------------------
[detached HEAD 5772d5a817] sqlite: enforce permission model in Database
Author: Matteo Collina <[email protected]>
Date: Thu Apr 23 20:07:23 2026 +0000
3 files changed, 159 insertions(+)
create mode 100644 test/fixtures/permission/sqlite.db
create mode 100644 test/parallel/test-permission-sqlite.js
Rebasing (3/12)
Rebasing (4/12)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
sqlite: enforce permissions through a VFS shim
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/62957
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: James M Snell <[email protected]>
--------------------------------------------------------------------------------
[detached HEAD 1738a62b7d] sqlite: enforce permissions through a VFS shim
Author: Matteo Collina <[email protected]>
Date: Sun Jul 12 14:48:19 2026 +0000
11 files changed, 1206 insertions(+), 108 deletions(-)
create mode 100644 src/node_sqlite_vfs.cc
create mode 100644 src/node_sqlite_vfs.h
Rebasing (5/12)
Rebasing (6/12)
Rebasing (7/12)
Rebasing (8/12)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
sqlite: fix permission VFS edge cases
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/62957
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: James M Snell <[email protected]>
--------------------------------------------------------------------------------
[detached HEAD 822a46d154] sqlite: fix permission VFS edge cases
Author: Matteo Collina <[email protected]>
Date: Sun Jul 12 17:44:09 2026 +0000
6 files changed, 425 insertions(+), 193 deletions(-)
Rebasing (9/12)
Rebasing (10/12)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
sqlite: disable URI filenames under permission
A URI could select another VFS or access mode, bypassing the
permission VFS. Reject URLs and "file:" paths until URIs are supported.
Drop the URI parsing and ATTACH authorizer check this replaces, and
reuse Permission::is_granted_quiet() in the VFS.
Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/62957
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: James M Snell <[email protected]>
--------------------------------------------------------------------------------
[detached HEAD c0aca54ec4] sqlite: disable URI filenames under permission
Author: Guilherme Araújo <[email protected]>
Date: Mon Nov 16 11:39:23 2026 -0300
11 files changed, 204 insertions(+), 660 deletions(-)
Rebasing (11/12)
Rebasing (12/12)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
sqlite: report permission VFS denials
Backup and ATTACH denials surfaced as generic SQLite errors and were
invisible to --permission-audit. Throw ERR_ACCESS_DENIED and publish
them to the permission diagnostics channel instead.
Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/62957
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: James M Snell <[email protected]>
--------------------------------------------------------------------------------
[detached HEAD 2646a1f101] sqlite: report permission VFS denials
Author: Guilherme Araújo <[email protected]>
Date: Mon Nov 16 11:48:55 2026 -0300
5 files changed, 134 insertions(+), 19 deletions(-)
Successfully rebased and updated refs/heads/main.
--------------------------------------------------------------------------------
ℹ Add `commit-queue-squash` label to land the PR as one commit, or `commit-queue-rebase` to land as separate commits.
View workflow run
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
gabylb
pushed a commit
to gabylb/node
that referenced
this pull request
Nov 27, 2026
Database opened database files without consulting the permission
model, so code running with --permission could read and write any
database regardless of --allow-fs-read and --allow-fs-write.
Check read access, and write access unless the database is read-only,
before opening a file-backed database. In-memory databases are exempt.
SQLite also opens journal, WAL and temporary files, and ATTACH and
backup() open further databases, so route every connection through a
VFS shim that checks each path SQLite opens, deletes or probes.
Reject URI filenames that select a VFS, since that would bypass the
shim, and deny ATTACH when SQLite does not pass the filename to the
authorizer.
Refs: https://hackerone.com/reports/3686625
Co-authored-by: Guilherme Araújo <[email protected]>
Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <[email protected]>
PR-URL: nodejs#62957
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewers
jasnell
jasnell approved these changes
RafaelGSS
Awaiting requested review from RafaelGSS
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
c++
Issues and PRs that require attention from people who are familiar with C++.
commit-queue-squash
PRs the Commit Queue should land as one squashed commit.
needs-ci
PRs that need a full CI run.
sqlite
Issues and PRs related to the SQLite subsystem.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|