init and serve leave an existing TLS private key readable by other users

Open Beginner friendly
#769 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
security

Research direction

Start with check_config_permissions in crates/app/src/serve_helpers.rs (around line 77), which already warns and sets the config to 0600; mirror that for server.tls.key_path. The init skip path is generate_tls_cert_if_needed in crates/app/src/init_helpers.rs. Done when a test starting from a 0644 key shows the warning and ends with the key at 0600 in both serve and init.

Written by the indexing model from the issue text.

Description

bug security

Problem

Neither init nor serve checks the mode of an existing TLS private key, so a key.pem that other users can read stays readable.

  • init skips certificate generation when both cert.pem and key.pem exist (generate_tls_cert_if_needed, crates/app/src/init_helpers.rs). It checks that the certificate covers the requested names and does not look at the key's mode.
  • serve checks only the config file's mode: check_config_permissions (crates/app/src/serve_helpers.rs line 77) warns and sets the config to 0600 when group or other bits are set. Read from the code, nothing does the same for server.tls.key_path (default ~/.extenddb/tls/key.pem).

A key ends up wider than 0600 when an older init stopped between writing the key and setting its mode (#709, fixed in #766 for new keys), or when an operator copies a key in with the umask mode.

Measured

2 November 2026, a build of #766 (7cb517498), a fresh HOME, umask 022. init created key.pem at 0600. After chmod 0644 key.pem, a second init with a new config path and a new SQLite path printed --- TLS certificate already exists, skipping generation., exited 0, and left key.pem at 0644.

Expected

Treat the key file as check_config_permissions treats the config: when server.tls.key_path has group or other bits set, serve warns and sets it to 0600, and the init skip path does the same for ~/.extenddb/tls/key.pem. A test starts from a 0644 key and checks the warning and the 0600 result.

Dominant language
Rust
Stars
517
Forks
60
Avg merge
4d 19h
Merged PRs (30d)
50

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ExtendDB/extenddb

All issues in ExtendDB/extenddb

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.