Skip to content

config: a rejected settings document silently swaps an LMDB deployment onto the default Postgres backend #1305

Done

Description

@chappie-daemon

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

A settings document the loader rejects silently swaps an LMDB deployment onto the default Postgres backend.

nostream_config::load merges, validates and fits, and on any issue returns the shipped defaults with used_defaults: true (crates/nostream-config/src/load.rs:417-424; the unreadable-file arm at :395-406 does the same). The relay does not refuse those defaults — settings_gate logs the issues and continues unless --check (crates/nostreamd/src/settings_gate.rs:41-45).

The shipped eventStore.backend is postgres (resources/default-settings.yaml:232), and resolved_backend(&settings, false) takes it (crates/nostreamd/src/main.rs:238) into stores::open, which dials the DB_* family (crates/nostreamd/src/stores.rs:56-62). So one bad field anywhere in settings.yaml makes an LMDB deployment serve and accept writes into the old Postgres store while the data directory it was pointed at sits unused.

The store path and map size are not the hazard — --data-dir and the fixed 64 GiB LMDB_MAP_SIZE (crates/nostream-storage/src/lmdb/mod.rs:51) do not come from settings — the backend selection is.

Acceptance

  • A rejected settings document either refuses to start (naming the field) or substitutes defaults only for fields that cannot select a store; the backend selection never falls back silently.
  • A case where settings.yaml contains a rejected field and an LMDB deployment is configured fails on today's shape.
  • The ADR that owns the defaults-on-failure rule says which fields are safe to default and why.

Record: docs/rewrite/reviews/2026-11-30-relay-storage.md — finding F16, lens security, tree 8488bf13. Site: crates/nostream-config/src/load.rs:417-424.

Activity

  1. added
    bug
    security
    rewrite
    rust
    factory
    on Nov 30, 2026
  2. chappie-daemon commented on Dec 4, 2026

    @chappie-daemon
    CollaboratorAuthor

    Factory job started (row from the 2026-12-04 plan): recon in progress, branch factory/048-*' from rewrite/mainat7019957`.

  3. chappie-daemon commented on Dec 4, 2026

    @chappie-daemon
    CollaboratorAuthor

    Closed by db0be6a4a1f51bd618c0f25df9d8a03ced4f7c34 (#1383).

    A rejected settings document no longer swaps an LMDB deployment onto the Postgres default: LoadOutcome records the user document's own eventStore.backend when a rejection discarded it, and apply_settings_gate refuses to start (exit 2, InvalidSettings) when that selection differs from the backend the defaults would serve, naming the field, the discarded value and the backend that would have been served. Verified end to end: base exits 1 and dials Postgres; head exits 2 with the refusal line, no event store backend resolved, no store directory created.

    Limits recorded in ADR 0022 D5 and restated here: a document with no readable store selection (unreadable, unparseable, absent config) still continues on the shipped defaults; --check output is byte-identical; a document that never named a store keeps today's continue-on-defaults behaviour.

    Follow-up filed: #1384 (the refusal echoes the value verbatim, so a newline in it forges a log line).

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

Metadata

Metadata

Labels

bugfactoryrewriterustsecurity

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions