Back to blog
PrivacyMarch 20263 min read

PII Redaction in Rust: Why We Strip Sensitive Data Before It Leaves Your Machine

A deep dive into the Serpaix LTM daemon's PII redaction pipeline — Sørensen–Dice deduplication, regex-based stripping, and why doing this in Rust matters for latency and trust.

Why On-Device Redaction?

The Long-Term Memory (LTM) daemon captures your screen and clipboard continuously. That means it will inevitably capture sensitive data: credit card numbers, API keys, passwords, personal emails. The question is not whether sensitive data appears — it's what you do about it.

The Pipeline

The LTM daemon's PII redaction pipeline has four stages:

1. Pattern Detection (15+ Patterns)

We maintain a compiled set of regular expressions covering:

  • Credit card numbers (with Luhn validation to eliminate false positives)
  • Social Security Numbers (with format + range validation)
  • API keys (via entropy analysis — high-entropy strings above a threshold)
  • Email addresses
  • Phone numbers
  • Password fields (form heuristics)
  • Private SSH keys
  • 2. Deduplication via Sørensen–Dice

    The same sensitive information often appears across multiple captures (e.g., you type an API key, it appears in both screen and clipboard captures). Sørensen–Dice coefficient comparison prevents redundant redaction events and reduces CPU overhead.

    3. In-Place Redaction

    Redaction happens in the Rust process's memory before any data is serialized for transmission. The raw buffer is zeroed after processing.

    4. Exclusion Zones

    Password managers (1Password, Bitwarden, Apple Keychain) are excluded at the capture level — their windows are never captured in the first place, using platform-specific window detection APIs.

    Why Rust?

  • Memory safety guarantees prevent buffer overreads that could leak sensitive data
  • Zero-cost abstractions mean the redaction pipeline adds less than 2ms per capture
  • Thread safety is enforced at compile time — no race conditions on shared redaction state
  • FFI to platform APIs (xcap, arboard) is safe and predictable
  • The result: sensitive data is stripped before it ever leaves your machine, and the performance impact is negligible. The full threat model, encryption at rest and key handling are covered on the security page, and the daemon itself on long-term memory.

    Published March 2026