Skip to content

Create private node directories and create private SQLite database files - #1088

Open
tankyleo wants to merge 4 commits into
lightningdevkit:mainfrom
tankyleo:2026-09-private-node-storage
Open

Create private node directories and create private SQLite database files#1088
tankyleo wants to merge 4 commits into
lightningdevkit:mainfrom
tankyleo:2026-09-private-node-storage

Conversation

@tankyleo

@tankyleo tankyleo commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Create new storage, filesystem-store, seed, and log directories with
owner-only permissions on Unix.

With the usual 0022 umask, create_dir_all made directories 0755.
That let other local users list and traverse node storage, inspect
metadata, and reach files with permissive mode bits. Restricting new
directories to the owner adds defense in depth for node data.

Non-Unix platforms retain their existing directory creation behavior.

This commit was created with assistance from Codex.
@ldk-reviews-bot

ldk-reviews-bot commented Sep 3, 2026

Copy link
Copy Markdown

👋 Thanks for assigning @benthecarman as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

Pre-create new SQLite database files with mode 0600 on Unix before
opening them with rusqlite. Existing database files are left unchanged.

This requires database names to resolve to ordinary filesystem paths.
SQLite's :memory: name and file: URI filenames are now rejected.

This keeps persisted node and payment data from being readable by other
local users when the database is created under a permissive umask.

This commit was created with assistance from Codex.
@tankyleo
tankyleo force-pushed the 2026-09-private-node-storage branch from 2618c77 to 27d3e14 Compare September 4, 2026 01:39
Comment thread src/logger.rs
fs::create_dir_all(parent_dir)
create_dir_all_private(parent_dir)
.map_err(|e| eprintln!("ERROR: Failed to create log parent directory: {}", e))?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log file stays world-readable while its directory becomes private. src/logger.rs:270 and src/logger.rs:213 still open the log file with default options, so it is created 0644. The directory is now 0700, so protection depends entirely on nobody copying or rotating the file out. Logs contain peer IDs, channel IDs, payment hashes, and amounts. Either give the file 0600 with the same pattern used for the database, or leave the log directory alone. Right now the PR hardens the wrong half of the pair.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks I added a commit below to address this

@benthecarman benthecarman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small comment otherwise lgtm

Validate the composed SQLite database path for file: URI prefixes before
creating the database directory and file. Database file names continue
to reject SQLite's :memory: and file: pseudo-filenames.

This prevents a data directory such as file:. from redirecting rusqlite
to an unprotected database while a private decoy file is created instead.

This commit was created with assistance from Codex.
Create new log files with mode 0600 on Unix during logger initialization
and when a missing file is recreated during a later write. Existing log
files are left unchanged.

This keeps peer IDs, channel IDs, payment hashes, and payment amounts
from being readable by other local users when log files are created
under a permissive umask.

Non-Unix platforms retain their existing log file creation behavior.

This commit was created with assistance from Codex.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants