πŸ”„ Topic

A deployment can be healthy today and still be unsafe to update tomorrow. I found that a live Hermes scheduling script contained a gateway safety guard that was missing from the repository. A later one-file deployment could therefore have replaced the live copy with an older version and removed a protection that nobody remembered to review.

This was a small example of configuration drift, but it exposed a larger security principle: the source reviewed by humans and the code executed by the system must be demonstrably the same.

🎯 Goal

Detect every deployed script that differs from its versioned source, including scripts added after the original checklist was written.

πŸ›  What I Did

The old check compared six hardcoded filenames. That list missed the scheduling script carrying the gateway-plist guard and also missed the capture scripts that had been deployed later. The repository therefore looked complete while the live directory had additional security-relevant files.

I changed the check to enumerate the deployed scripts directory. It skips directories and backup files, rejects symlinks that would make the live job run an uncontrolled working tree, and compares every remaining deployed file with its tracked counterpart. A script with no versioned copy is reported as a failure rather than silently ignored.

The drift was corrected by bringing the repository and deployed copy into byte-for-byte agreement. The safety guard was preserved, and the expanded check finished with 28 passing checks and zero failures. The wider repository test suite completed with 1,519 tests passing and 20 skips.

πŸ”— Key Cybersecurity Connections

πŸ” Investigation Questions

For an unattended security-sensitive job, I should be able to answer:

  1. Which exact files can the service execute?
  2. Is every one of them represented in reviewed source control?
  3. Does the deployed file match the reviewed revision?
  4. Can a symlink or untracked file change what runs?
  5. Would the check notice a newly added script without a checklist edit?

🚨 Detection Opportunities

Drift checks can run before deployment and on a schedule. The important findings are not only changed hashes; they also include untracked executable files, missing repository copies, symlinks, unexpected permissions, and a deployed revision older than the approved source.

🧭 MITRE ATT&CK Techniques

No direct ATT&CK technique mapping is claimed for this defensive control. The same kind of integrity failure could support several attack paths, but drift alone does not identify an attacker or technique.

⚠️ Challenges and Boundaries

The hardest part was not comparing bytes. It was defining the inventory correctly. A hardcoded list creates a false sense of coverage because a newly added file is invisible to the test. Enumerating the directory makes the check adapt to change, while explicit exclusions prevent caches and preserved backups from becoming misleading failures.

The check does not prove that every source repository is trustworthy or that the running process loaded the expected file after a restart. Those are separate verification steps. It proves a narrower and useful property: the files in the deployment directory are accounted for and match their intended repository copies.

πŸ“š What I Learned

Configuration integrity is part of the security boundary of automation. A reviewed guard that exists only in the live directory is not durable. A repository that omits a live script is not a complete source of truth. Both sides need to be checked, and the inventory must discover new files rather than depend on someone remembering to update a list.

🧩 Lessons Learned

  • Treat deployed code as evidence, not as an assumption.
  • Enumerate executable inventory instead of maintaining a fragile allowlist.
  • Compare bytes and reject unexpected files or symlinks.
  • Preserve live safety guards in versioned source before future deployment.
  • Separate β€œthe check passed” from β€œthe service was restarted and observed.”

πŸ˜„ TL;DR

I found and fixed deployment drift between a live scheduling script and its repository. Expanding the check from six remembered names to every deployed script made the control useful against future additions, not just the files someone thought to list.