Skip to content

admin: the audit log is created 0644, so a local user can read the relay's admin history #1187

Open

Description

@chappie-daemon

Found by: the security lens in review round 4 of job 032-admin-console-parity (round-4/review-security.md, note 3). Non-blocking there; filed so the fix is tracked rather than left in a review note.

crates/nostream-admin/src/state.rs:611 creates <config>/admin-audit.jsonl with fs::write, which yields mode 0644 in a 0755 directory. Every other file this change writes — the settings document and settings-audit.jsonl — is created 0600 (crates/nostream-config/src/store.rs:153).

Measured: the lens's probe read the audit file back as mode = 644, dir = 755 on a real config directory.

Why it matters: the audit log records admin actions with {id, at, action, remoteAddress?, detail?}. On a multi-user host, any local account can read the relay's administrative history, including the source addresses of admin logins.

Fix: create the file with OpenOptions and set_permissions(0o600) the way store.rs:153 already does, and assert the mode in the existing audit test. The directory's mode is the deployment's (it is the same config directory the settings file lives in), so the file is the part this change owns.

Oracle it inherits: a case in crates/nostream-admin/tests/ that creates the audit file through the append path and asserts mode & 0o777 == 0o600 — the shape the settings-store test already uses.

Closing: this repository's default branch is main, so Closes #N is inert on a PR targeting rewrite/main; close by hand with the merge sha.

Activity

  1. added
    bug
    rewrite
    rust
    factory
    on Nov 19, 2026
  2. chappie-daemon commented on Nov 19, 2026

    @chappie-daemon
    CollaboratorAuthor

    Measured addition (round 6 of job 032-admin-console-parity, round-6/review-security.md): the remedy this issue names is necessary but not sufficient.

    • state.rs:522 opens admin-audit.jsonl with create+append and no set_permissions, so a fresh file is 0644 in a 0755 directory (re-measured at c2b38613 under umask 0022).
    • The new compaction path is a second way in: write_audit_lines (state.rs:709-725) creates the staging file with fs::write and renames it over the old one (:703), so a log hardened to 0600 reads back 0644 after one compaction — the rename replaces a hardened file with an unhardened one.

    So the fix has to set the mode on both paths: the append file's first creation and the staging file before the rename (as crates/nostream-config/src/store.rs:153 already does for the settings files), with the existing audit test asserting mode & 0o777 == 0o600 after an append and after a compaction that crosses the cap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfactoryrewriterust

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions