Harden local secret file handling - #269
Merged
tankyleo merged 8 commits intoSep 3, 2026
Merged
Conversation
Create new log files without group or world access so local users cannot read node activity under the standard process umask. This commit was created with assistance from Codex.
Require existing API key files to contain the same 32-byte key material that the daemon generates. Truncated files must not enable weak HMACs. This commit was created with assistance from Codex.
|
👋 Thanks for assigning @tankyleo as a reviewer! |
Create ldk_server_data.sqlite with mode 0600 and new storage and log directories with mode 0700. 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 any file with permissive mode bits. Restricting new directories to the owner adds defense in depth for node data. Payment history should likewise not be readable by other users. This commit was created with assistance from Codex.
Read at most one byte beyond the expected API key length. This avoids unbounded memory use for oversized or special files while still rejecting contents that are not exactly 32 bytes. This commit was created with assistance from Codex.
tankyleo
reviewed
Sep 3, 2026
tankyleo
left a comment
Contributor
There was a problem hiding this comment.
vibed with codex and came up with a few potential followups to this work here, i pushed it all on this branch grab what you find is good, no need for attribution :)
API keys are exactly 32 bytes. Reading malformed or special files in full can otherwise consume unbounded memory. Read only enough bytes to detect an oversized key. Treat missing files separately from read and format errors. This keeps a malformed configured key from being silently ignored in favor of a default key. Use the same open-first handling in the daemon so only NotFound triggers key generation and all other open failures are reported. This commit was created with assistance from Codex.
Collaborator
Author
|
ack on your commits |
Mnemonic files are small. Limit reads to 1 KiB so an oversized or special file cannot cause unbounded memory use during startup. This commit was created with assistance from Codex.
Limit server certificate and key reads to 1 MiB. Apply the same certificate limit to the CLI and MCP clients so local files cannot cause unbounded memory use during startup. This commit was created with assistance from Codex.
Limit server and client configuration reads to 1 MiB so an oversized or special file cannot cause unbounded memory use during startup. This commit was created with assistance from Codex.
tankyleo
approved these changes
Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
2 small issues found by loupe
0600permissions.