Dev.to Security 🔐 Cybersecurity 👁 0 📖 3 min read

How SwordCheck audits your Mac's security with Rust: FileVault, SIP, Gatekeeper and friends

Cross-posted from the SwordCheck project (AGPL-3.0) by SwordSec. The binary is read-only: it never changes a setting on your machine. We built SwordCheck — a small Rust CLI that gives your Mac a security check-up and sc

Cross-posted from the SwordCheck project (AGPL-3.0) by SwordSec. The binary is read-only: it never changes a setting on your machine.

We built SwordCheck — a small Rust CLI that gives your Mac a security check-up and scores the results out of 100. It is free and open source: github.com/SwordSec/SwordCheck.

This post is about the parts we think are interesting beyond the tool itself: how the checks work, how we keep them testable, and what the supply-chain scans look at.

The audit: 17 checks, one score

Each check inspects one security setting on macOS — FileVault, SIP, Gatekeeper, the firewall and its stealth mode, Remote Login, sharing services, AirDrop visibility, automatic login, the guest account, screen lock, passwordless sudo, launch items, XProtect signatures, pending updates, and more.

Every check has a weight (FileVault is 25, Gatekeeper 15, ...) and maps to a section of the CIS Apple macOS benchmark. A Pass earns the full weight, Warn half, Fail nothing; the sum becomes a score out of 100 with A–F grades.

Two rules we kept from the start:

  1. A check never passes on a guess. If the command it runs fails, times out or prints something we did not expect, the result is Unknown with the raw output attached — Unknown results are excluded from the denominator instead of being counted as good.
  2. The tool never changes a setting. Where a fix is a single correct command, the report prints that command for you to run yourself. For things like FileVault or SIP the advice names the exact place in System Settings or Recovery.

Testability: CommandRunner and MockRunner

Checks shell out a lot (fdesetup, csrutil, spctl, defaults, ...). To keep that honest, every check talks to the system through one trait:

// src/checks/mod.rs (simplified)
pub trait Check {
    fn id(&self) -> &'static str;
    fn weight(&self) -> u32;
    fn run(&self, r: &dyn CommandRunner) -> CheckResult;
}

In tests the runner is a MockRunner with canned stdout, so csrutil status returning "Disabled" produces the same CheckResult in CI as it does on a machine. Adding a new check is: implement Check, register it. The end-to-end tests in tests/cli.rs run the real binary against a temporary home directory.

The supply-chain scans

  • npm malware: a built-in incident list (event-stream, ua-parser-js, chalk/debug, Nx, Shai-Hulud, ...) plus OSV.dev malicious-package records with --online. It reads package.json files and never executes package code; suspicious preinstall/postinstall scripts (download-and-execute, reverse shells, credential reads) are flagged heuristically.
  • Vulnerabilities: lockfiles (Cargo.lock, package-lock.json, yarn.lock, pnpm-lock.yaml, requirements*.txt, poetry.lock, uv.lock, ...) are matched against OSV.dev; macOS, common apps and Homebrew formulae against NVD, filtered to known-exploited CVEs and ranked with CISA KEV and EPSS — so the top of the report is what is being exploited in the wild, not what merely exists.
  • Secrets: API keys in .env, .tfvars, ~/.aws/credentials, ~/.npmrc, ~/.docker/config.json, shell history, Claude/Cursor/VS Code settings and more. Values are always masked — at most the provider's public prefix and the last 2–4 characters are shown.

Everything is offline by default; --online sends only package names and versions, never paths or file contents.

The dashboard

Run without arguments, SwordCheck opens a ratatui dashboard: pick a module, watch the progress bar, browse findings with details on the right. The TUI and the CLI both consume the same progress events, so --vulns --online phases print to stderr exactly what the dashboard shows. --report report.html writes a single self-contained HTML page (styles inline, nothing loaded from the network) with a "Fix these first" list ordered by risk.

Try it

curl -fsSL https://raw.githubusercontent.com/SwordSec/SwordCheck/main/install.sh | sh

or build from source with cargo install --path .. The installer verifies a SHA-256 and never uses sudo.

Honest limits: the release binary is not notarized yet (a browser download needs one-time approval in Privacy & Security; the curl script avoids that), it covers baseline configuration rather than a full security assessment, and it is macOS-only for now — Linux and Windows are planned.

Feedback, bug reports and PRs are very welcome. If you try it and something looks wrong or a check behaves oddly on your machine, that is exactly the kind of issue we want.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.