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

未关闭 适合新手
#769 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
70/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
security

调研方向

从 crates/app/src/serve_helpers.rs(约第 77 行)中的 check_config_permissions 开始,它已经会发出警告并将配置设置为 0600;请对 server.tls.key_path 采用相同的做法。init 中的跳过路径是 crates/app/src/init_helpers.rs 中的 generate_tls_cert_if_needed。当一个从 0644 密钥开始的测试显示了警告,并且最终密钥为 0600 时,在 serve 和 init 中都完成。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Rust
星标
517
派生
60
平均合并
4 天 19 小时
30 天内合并 PR
50

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ExtendDB/extenddb 的其他 Issue

查看 ExtendDB/extenddb 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。