Skip to content

Windows data dir trust check: read owner/DACL from the opened handle and test with a foreign owner #1748

Backlog

Description

@smart-ssh-planner

Goal

On Windows, the trust check for a data directory override reads owner and DACL from the object that was actually opened, so the path cannot be swapped between open and check. The check is covered by a test with a real foreign owner.

Context

Follow-up of #1717 (PR #1734): the pointer file is opened first, then owner and DACL are read by path with GetNamedSecurityInfoW (crates/persistence-sqlite/src/data_dir_trust.rs:333-344). An attacker with create rights in the app folder and the symlink privilege could swap the path between open and check (the data directory check on the target still applies). The ACE walk checks that a modifying ACE's SID fits in AceSize but not the full SID length. The Windows tests are pure-function tests only; none uses a real foreign owner SID. See Spec 0115 §4.1 and THREAT-MODEL.md.

Requirements

  • Open the pointer file with FILE_FLAG_OPEN_REPARSE_POINT, refuse reparse points, and read owner and DACL from that handle (GetSecurityInfo) instead of by path.
  • Check the full SID length (derived from the sub-authority count) against AceSize in the ACE walk before using the SID.
  • Add a #[cfg(windows)] test that creates a pointer file and a directory, sets a foreign owner SID with SetNamedSecurityInfoW, and asserts both are refused.
  • Fail closed on every error.

Acceptance Criteria

  • Owner and DACL of the pointer file are read from the opened handle, not by path
  • A pointer file that is a reparse point is refused
  • An ACE whose SID extends past AceSize is refused (pure-function test)
  • A pointer file and a data directory with a foreign owner SID are refused (Windows test)
  • Unix behaviour is unchanged
  • Relevant automated tests pass

Technical Notes

Security-critical path (crates/persistence-sqlite/, data location trust). Update THREAT-MODEL.md (remove the by-path race note) or state Threat model: no change – <reason>. Windows code runs only in the Windows CI job.

Files: crates/persistence-sqlite/src/data_dir_trust.rs, crates/persistence-sqlite/src/data_dir_trust/tests.rs, THREAT-MODEL.md

Spec impact: none

Open questions

  • Reading the data directory from a handle too: recommended only for the pointer file now; the directory is checked after resolving, and changing it is a larger change. Alternative: do both.

Related Work

Activity

  1. added
    follow-up
    on Dec 5, 2026
  2. smart-ssh-coder commented on Dec 5, 2026

    @smart-ssh-coder
    Contributor

    Needs maintainer: The issue waits for #1733, but "blocked by" could not be set. Set it on the issue (Relationships), then remove needs-maintainer: The code this issue changes (data_dir_trust.rs from #1734) exists only on release/0.8.0; it reaches develop with the open back-merge PR #1733. Nothing to edit on develop until then.

  3. added
    needs-maintainer
    question-triage
    and removed
    question-triage
    needs-maintainer
    on Dec 5, 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

    follow-uppersistencesecurity

    Type

    Fields

    Priority

    P2 - Normal

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions