dotfiles

Threat Model

Security analysis of the dotfiles distribution. Covers trust boundaries, threat actors, attack surfaces, and mitigations.

Trust Boundary

The primary trust boundary is the local machine. Dotfiles are deployed to and executed on the user’s own system. All configuration files, scripts, and templates run with the user’s privileges.

┌─────────────────────────────────────────────────┐
│ Local Machine (trusted zone)                    │
│  ┌─────────────────┐  ┌──────────────────────┐  │
│  │ ~/.dotfiles/     │  │ ~/.config/ (deployed)│  │
│  │ (source repo)    │──│ Shell configs, nvim  │  │
│  └─────────────────┘  └──────────────────────┘  │
│                                                  │
│  ┌─────────────────┐  ┌──────────────────────┐  │
│  │ ~/.local/bin/    │  │ ~/.cache/shell/      │  │
│  │ (user scripts)   │  │ (cached eval output) │  │
│  └─────────────────┘  └──────────────────────┘  │
└─────────────────────────────────────────────────┘
         │
    ─────┼──────── Trust boundary ────────
         │
┌─────────────────────────────────────────────────┐
│ External (untrusted zone)                        │
│  GitHub (repo hosting), Homebrew, Nix,           │
│  Zinit plugins, Neovim plugins, npm, pip         │
└─────────────────────────────────────────────────┘

Threat Actors

Actor Motivation Capability
Supply chain attacker Inject malicious code via dependency Compromise upstream packages (Homebrew, npm, Zinit plugins)
Secrets harvester Steal API keys, SSH keys, tokens Scrape git history, shell history, env vars
Privilege escalation Gain root access Exploit sudo aliases, writable scripts in PATH
Network attacker Intercept credentials MITM on install scripts, curl-pipe-bash

Attack Surfaces

1. Shell Startup Scripts

Risk: Malicious code in sourced files executes with user privileges on every shell start.

Mitigations:

2. Secrets Exposure

Risk: API keys, tokens, and SSH keys leaked via git history, shell history, or environment.

Mitigations:

3. Supply Chain Dependencies

Risk: Compromised upstream packages injected into the toolchain.

Mitigations:

4. Path Manipulation

Risk: Attacker places malicious binary in a PATH directory that shadows legitimate tools.

Mitigations:

5. Template Injection

Risk: Chezmoi template variables could inject shell code if not properly quoted.

Mitigations:

6. Cached Eval Files

Risk: Stale or tampered cache files in ~/.cache/shell/ sourced at startup.

Mitigations:

Residual Risks

Risk Likelihood Impact Status
Zinit plugin compromise Low High Mitigated by version pinning
Shell history leak Medium Medium Mitigated by Atuin filter
Stale Nix closure Low Low Accepted (manual nix flake update)
macOS Keychain access Low Medium Accepted (OS-level protection)

Recommendations

  1. Run gitleaks detect before every push (pre-commit hook enforced)
  2. Rotate secrets on a 90-day schedule
  3. Audit lazy-lock.json diffs when updating Neovim plugins
  4. Pin Homebrew versions for security-critical tools
  5. Use DOTFILES_ULTRA_FAST=1 in CI to minimize attack surface