Repository navigation
Description
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 withSetNamedSecurityInfoW, 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
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
smart-ssh-coder commentedon Dec 5, 2026
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.