Skip to content

Security: ZengLLQ/ghost-sort

Security

docs/SECURITY.md

GhostSort Security Policy & Threat Model

1. Core Security Invariants

GhostSort is designed under the philosophy that every file on disk is potentially untrusted input. The system enforces strict read-only guarantees during all analysis stages and mandatory user approval prior to any file manipulation.

Invariant 1: Read-Only Analysis Guarantee

Scanning, metadata extraction, hashing, categorization, and duplicate detection never mutate or touch source files.

Invariant 2: Explicit Approval Barrier

No file move, rename, or copy can execute without an existing, validated OperationPlan authorized by the user.

Invariant 3: Zero Remote Transmission (Local-First Privacy)

  • All file contents, metadata, text extracts, SHA-256 hashes, and database logs remain exclusively on the local machine.
  • No remote telemetry, no external AI/LLM API calls, and no cloud uploads.

2. Protected System Locations

GhostSort automatically blocks operations targeting or originating from:

  • C:\Windows, C:\Windows\System32, and all SystemRoot descendants.
  • C:\Program Files and C:\Program Files (x86).
  • C:\ProgramData.
  • Volume roots themselves (C:\, D:\).
  • User profile credential storage (AppData\Local\Microsoft\Credentials, .ssh, .aws, .gnupg).
  • Browser profile directories (Chrome, Firefox, Edge, Brave user data).
  • Critical OS boot and swap files (bootmgr, pagefile.sys, hiberfil.sys, ntuser.dat).

3. Path Validation & Boundary Defense

  • Path Traversal Defense: All source paths are checked against approved root boundaries using component-aware ancestry (pathlib.Path.is_relative_to), preventing string-prefix escape vulnerabilities (e.g., distinguishing C:\Approved from C:\ApprovedMalicious).
  • Reserved Windows Names: Rejects legacy MS-DOS device names (CON, PRN, AUX, NUL, COM1-COM9, LPT1-LPT9).
  • Cycle Prevention: Verifies that a folder cannot be moved into its own subdirectory hierarchy.
  • Time-Of-Check to Time-Of-Use (TOCTOU): Before moving any file, GhostSort re-verifies that the source exists and its modification timestamp matches the time of planning. Any modification invalidates the operation and requests re-scan.

4. Disguised Executable Defense (Signature Mismatch)

Attackers occasionally camouflage executable payloads by appending common document extensions (e.g. invoice.pdf holding Windows MZ PE header). GhostSort inspects file magic bytes:

  • If a signature mismatch is detected, GhostSort applies a heavy negative confidence penalty, flags the file as Signature Mismatch!, and marks it as requiring user review.
  • GhostSort never executes or launches discovered executables.

There aren't any published security advisories