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

Aperta Adatta ai principianti
#769 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
security

Direzione di ricerca

Inizia da check_config_permissions in crates/app/src/serve_helpers.rs (intorno alla riga 77), che già emette un avviso e imposta la configurazione a 0600; replica questo comportamento per server.tls.key_path. Il percorso di salto in init è generate_tls_cert_if_needed in crates/app/src/init_helpers.rs. È completato quando un test che parte da una chiave 0644 mostra l'avviso e termina con la chiave a 0600, sia in serve sia in init.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Rust
Stelle
517
Fork
60
Merge medio
5g 1h
PR unite (30g)
67

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ExtendDB/extenddb

Tutte le issue di ExtendDB/extenddb

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.