lietzsche;noether
Pages

updated 2026-11-26·2 min read

Security & Filesystem Boundary

Architectural specification of Noether's local-first security sandbox, is_safe_vault_path boundary containment, Windows UNC normalization, trash safety guards, and SQLite batch integrity.

Because Noether’s Rust backend reads, writes, and deletes real files on your drive over Tauri IPC, a single unvalidated ../../ path or Windows \\?\ prefix mismatch can escape the vault root. Every filesystem command passes through is_safe_vault_path and dedicated .trash/ guards before touching disk.

1. The Local-First Filesystem Boundary

Every filesystem command routed through Tauri IPC validates its target path via is_safe_vault_path in src-tauri/src/vault.rs:

[ Incoming IPC Path: e.g. "Notes/../../Windows/System32" ]
  │
  ├── 1. Canonicalize Target (or nearest existing ancestor)
  │
  ├── 2. Normalize & Strip Windows UNC Prefixes (\\?\C:\... → C:\...)
  │
  ├── 3. Boundary Containment Check (vault root or <vault>/.noether):
  │      starts_with(vault_root) || starts_with(vault_root/.noether)
  │
  └── 4. Access Decision:
         If True  → Proceed with File Operation
         If False → Return { "success": false, "error": "Security: ..." }

2. Windows UNC Normalization & Case Insensitivity

Windows paths introduce three annoying edge cases that break naive starts_with checks:

  • Extended-Length UNC Prefixes: Rust’s canonicalize() on Windows emits verbatim prefixes (\\?\C:\Vault\... or \\?\UNC\server\share). normalize_path() strips those markers and resolves lexical . and .. segments before containment checks run.
  • Case-Insensitive Comparison: On Windows, is_safe_vault_path compares paths case-insensitively (c:\vault\notes matches C:\Vault\Notes).
  • Non-Existent Target Files: Canonicalizing a file path that doesn’t exist yet on disk fails, so Noether walks upward to canonicalize the nearest existing parent directory and re-attaches the remaining segments before checking containment.

3. Vault Root & Trash Safety Guards

Destructive filesystem commands check two extra boundaries before touching disk:

  • Root Wipe Prevention: Delete and folder commands reject empty strings, dot paths (., ./, ..\), and the vault root itself, so no command can wipe an entire vault directory.
  • Dedicated Trash Containment: save_trash_file and delete_trash_file pass <vault>/.trash/ as the root to is_safe_vault_path, keeping trash cleanup confined to .trash/.

4. SQLite Data & Batch Integrity

Multi-statement SQL batches from extensions or migrations hit two specific traps if handled naively:

  • Syntax-Aware Statement Splitters: Splitting on ; blindly breaks inside quoted strings, bracketed identifiers, and SQL comments, so src-tauri/src/db.rs uses a syntax-aware splitter that keeps statements intact.
  • Binary BLOB Serialization: Binary columns serialize as Base64 strings instead of lossy UTF-8 so image previews and cached canvas assets don’t corrupt.

Search wiki and portfolio

type to search across all entries.