init writes the TLS private key at the umask mode before setting it to 0600

Đang mở Phù hợp với người mới
#709 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 4 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
security

Hướng nghiên cứu

Khóa được ghi bằng std::fs::write trong crates/app/src/init_helpers.rs quanh dòng 77, sau đó được chmod thành 0600 ở dòng 83. Hãy đọc phần tạo tệp cấu hình ở dòng 328-339, nơi tệp đã được mở bằng OpenOptions với mode 0o600, và sao chép mẫu đó cho key.pem. Công việc hoàn thành khi một bài kiểm tra xác nhận tệp khóa mới có mode 0600 trước khi bất kỳ byte nào được ghi, và init vẫn hoạt động khi khóa đã tồn tại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug security

Problem

init generates the self-signed TLS key with std::fs::write(&key_path, ...) (crates/app/src/init_helpers.rs:77) and only then sets the file to 0600 (:83). Between the two calls key.pem has the mode the process umask gives it, 0644 under umask 022, and ~/.extenddb/tls is 0755. Another local user who opens the file in that window keeps a readable handle to the server's private key after the mode changes. The config file in the same module is created at 0600 from the start (init_helpers.rs:328-339).

init creates the key only when none exists, so the window opens once per deployment.

Reproduction

Running init five times under umask 022 in a fresh HOME while polling the file's mode: key.pem was seen at 0644 during 3 of the 5 runs and was 0600 at the end of each. Build of 1c0523c9; the code is the same on main at f49c5f823.

Expected

key.pem is created at 0600, with OpenOptions and .mode(0o600) as the config file is, so it never has a wider mode. A test checks the mode of the new file before any bytes are written to it.

Ngôn ngữ chính
Rust
Star
517
Fork
60
Merge trung bình
5 ngày 5 giờ
Pull request đã merge (30 ngày)
41

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ExtendDB/extenddb

Tất cả issue của ExtendDB/extenddb

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.