Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

storage: search-index.lock is the one in-store file created without a mode, so it takes the umask (measured 644 beside 700 directories and 600 LMDB files) #1316

Todo

Description

@chappie-daemon

Found by job 045's security lens (row 5 of #868) at 8488bf13.

The chain at crates/nostream-storage/src/lmdb/mod.rs:284-288 is OpenOptions::new().create(true).truncate(false).write(true).open(&lock_path) with no .mode, so the file takes the umask. Measured on a fresh store under umask 022: 644 f /tmp/045-store-fresh/lmdb/search-index.lock beside 700 d directories and 600 f LMDB files. Nothing is readable today (the file holds no data and its parent is 0700) and the file is a lock, not a credential; the defect is that the crate's rule ("the store directory holds the whole dataset, so it is the owner's alone", crates/nostream-storage/src/lmdb/mod.rs:1462-1470) is a create-time comment with no test on any file mode — grep -rn 0o600 crates/nostream-storage/src finds nothing in the crate's src.

Evidence

find /tmp/045-store-fresh -printf '%m %y %p\n' → 644 f /tmp/045-store-fresh/lmdb/search-index.lock (beside 700 d /tmp/045-store-fresh/lmdb and 600 f /tmp/045-store-fresh/lmdb/data.mdb)

What a fix changes

One .mode(0o600) on the chain, plus an assertion in the_store_directory_is_the_owners_alone that every file in a fresh store is 0600.

Acceptance

  • A fresh store's search-index.lock is 0600.
  • A test asserts the mode of every file the store creates.

Record: docs/rewrite/reviews/2026-11-30-relay-storage.md — finding F20, lens security, tree 8488bf13.

Activity

  1. added
    bug
    rewrite
    rust
    factory
    on Nov 30, 2026
  2. tirthraj01 commented on Dec 2, 2026

    @tirthraj01
    Collaborator

    Hey @chappie-daemon @cameri, I've opened PR #1344 to fix #1316 (rewrite/main).

    Summary of changes:

    • Set 0o600 permissions when creating search-index.lock in crates/nostream-storage/src/lmdb/mod.rs (#[cfg(unix)]).
    • Updated the_store_directory_is_the_owners_alone to assert search-index.lock is present and every store file has mode 0o600.
    • Added .changeset/search-index-lock-mode.md.

    All CI checks are green, please review PR #1344 whenever you have a moment!

  3. self-assigned this
    on Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugfactoryrewriterust

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions