Skip to content

Crash recovery restores a shared config with a journal copy's unverified permissions #5111

Done

Description

Problem

Crash recovery for shared config files (#5009, #5016) authenticates the journal copy's bytes: its digest must equal the owner-backed prior digest in this machine's config file records. Replay then restores the copy with shutil.copystat, which also restores the copy's permission bits. Those bits are not bound to any owner-backed evidence.

If the journal copy's mode is changed (for example from 0600 to 0666) while its bytes stay the same, both digests still match. A restored MCP config can then be world-readable, which can expose credentials. Changing the copy needs write access to the user's ~/.apm/install-snapshots.

Done when

  • The records (or the journal's sealed state) bind the pre-write mode of a shared config file, and replay checks it before restoring. A mismatch is kept and reported, or restored with the recorded mode.
  • A permission-only tampering cell: the copy's mode is widened and its bytes are unchanged; the restored file never gets the widened mode.

Out of scope

Content verification (already owner-backed) and the deletion decision.

Found in Copilot review of #5016.

Activity

  1. added
    bug
    on Nov 23, 2026
  2. danielmeppiel commented on Nov 23, 2026

    @danielmeppiel
    CollaboratorAuthor

    Decision: approve
    Area: project
    Scope: Shared-config crash recovery (#5009/#5016; #5105 class) binds and checks permission bits. The owner-backed config file records (or the journal's sealed state) carry the pre-write mode of a shared config file, and replay checks it before restoring. On a mismatch, or when the mode cannot be verified, replay restores with the recorded mode if it verifies, and otherwise keeps the current file and reports (fail closed). A restore never applies the journal copy's own unverified mode bits and never widens a file's permissions. The #5009 content rule is unchanged (journal hash AND record verify). The only new persisted field is the mode, inside the existing record.
    Done when: A red-first permission-only tampering cell widens the copy's mode (0600 to 0666) with unchanged bytes and asserts that the restored file never gets the widened mode. A cell with a matching mode restores as today. Downgrade safety: an older apm reading a record with the mode field fails closed or ignores it, and never widens permissions. W3d, then QL H8. A CHANGELOG fragment and CI green.
    Out of scope: Content verification (already owner-backed) and the deletion decision.
    Review contact: Daniel Meppiel (@danielmeppiel)

  3. added
    status/accepted
    and removed on Nov 23, 2026
  4. moved this from Todo to In Progress in APM Roadmapon Nov 23, 2026
  5. moved this from In Progress to Done in APM Roadmapon Nov 23, 2026
  6. added a commit that references this issue on Nov 23, 2026
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

    bugstatus/acceptedtype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions