You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
data: opencode.db is created world-readable (0644), bypassing service API auth for local users #50673
~/.local/share/opencode/opencode.db is created mode 0644 (world-readable)
under a 0755 directory on a default umask 0022 system, while the background
service API correctly requires authentication (401). Any local user or process
can read session/message/credential data directly from the SQLite file,
bypassing service authentication entirely.
Environment
opencode version: 2.0.14
OS: Linux 6.18.33.2-microsoft-standard-WSL2 (applies to any Unix host with umask 0022)
Terminal: TERM=xterm-256color
Shell: /bin/bash
Install/channel: latest
Active plugins: none found in config
Reproduction
Run opencode so the background service creates the database.
The database (and any credential storage) should be created 0600, consistent
with ~/.local/state/opencode/service.json and ~/.config/opencode/service.json, which are correctly created 0600. Service
auth should not be the only barrier protecting session content.
Actual Behavior
The db file is 0644 and its parent directory 0755, so any local account can
read it with a plain file read — no 401, no password. Table structure confirms
message/session/credential-class content. (I did not dump row contents; the
finding is permission-level.)
Additional Context
Registration/password files verified 0600 — good; the db was likely just
missed because SQLite creates files with the process umask.
OPENCODE_DB can relocate the database; the same restrictive default should
apply there.
Likely fix: chmod 0600 after create (and tighten on startup for existing
files), or set a restrictive umask around db creation.
Frequency: consistent — it follows from umask 0022, the default on most
distros.
Thanks for the detailed report. I reproduced this on 2.0.14: under umask 0022, opencode.db is created 0644. That also happens with a custom OPENCODE_DB path, and an existing 0644 database stays that way after a restart.
On the latest dev (fa1260d) it no longer happens. #52150 changed this: a new database and its -wal/-shm files are created 0600, and an existing database is tightened to 0600 each time OpenCode opens it, including at an OPENCODE_DB path. That fix first shipped in v2.1.3, so upgrading (opencode upgrade) should fix your existing file the next time OpenCode starts. The script below shows the permissions before and after.
This looks already fixed, so the bot will close this issue in 1 day unless you reply that it still happens on v2.1.3 or newer.
Closing this as completed, since there's been no reply in the past day. To recap: on 2.0.14, opencode.db was created 0644 under umask 0022. On the latest dev (fa1260d), the database and its -wal/-shm files are 0600, and an existing 0644 file is tightened to 0600 on startup, including at an OPENCODE_DB path. The fix from #52150 is in releases since v2.1.3, so upgrading should take care of your existing file.
If it still happens on v2.1.3 or newer, please comment here or open a new issue with your version and the ls -l output. Thanks again for the clear report!
Activity
opencodejr commentedon Oct 28, 2026
Thanks for the detailed report. I reproduced this on 2.0.14: under
umask 0022,opencode.dbis created0644. That also happens with a customOPENCODE_DBpath, and an existing0644database stays that way after a restart.On the latest
dev(fa1260d) it no longer happens. #52150 changed this: a new database and its-wal/-shmfiles are created0600, and an existing database is tightened to0600each time OpenCode opens it, including at anOPENCODE_DBpath. That fix first shipped in v2.1.3, so upgrading (opencode upgrade) should fix your existing file the next time OpenCode starts. The script below shows the permissions before and after.This looks already fixed, so the bot will close this issue in 1 day unless you reply that it still happens on v2.1.3 or newer.
opencodejr commentedon Oct 29, 2026
Closing this as completed, since there's been no reply in the past day. To recap: on 2.0.14,
opencode.dbwas created0644underumask 0022. On the latestdev(fa1260d), the database and its-wal/-shmfiles are0600, and an existing0644file is tightened to0600on startup, including at anOPENCODE_DBpath. The fix from #52150 is in releases since v2.1.3, so upgrading should take care of your existing file.If it still happens on v2.1.3 or newer, please comment here or open a new issue with your version and the
ls -loutput. Thanks again for the clear report!