Netwarden
Back to Blog
Announcements

A Tripwire for Ransomware: Canary Files, Change Bursts and Snapshots That Stop Arriving

Immutable snapshots only save you if you notice the attack before the clean ones expire. How Netwarden's agent uses decoy files, folder walks and snapshot checks to catch ransomware within minutes, without root.

Thiago VinhasNovember 12, 20269 min read
ransomwaresecuritysynologysnapshotscanary filesbackups
Share this article:

A Tripwire for Ransomware: Canary Files, Change Bursts and Snapshots That Stop Arriving

I spent a morning this week hardening my own NAS. Snapshot Replication on every share that matters: hourly for home folders and documents, daily for photos and mail. Retention of 24 hourly and 30 daily snapshots. And every snapshot locked for 14 days, so nothing on the box, ransomware with admin rights included, can delete one early.

That felt solid for about an hour. Then I worked out what actually happens on day 15.

Ransomware doesn't have to delete your snapshots. It just has to stay quiet. Every hour a new snapshot is taken, and it's taken of the encrypted files. The hourly ones roll over in a day, the daily ones in a month, and the locks on the clean ones expire after two weeks whether you've noticed or not. If the first sign of trouble is someone opening a spreadsheet and getting garbage, there's a good chance the newest clean copy is already gone.

So the snapshots aren't really the defence. They're a clock. What you need is to hear about the encryption while the clock is still running, ideally within minutes. That's what the tripwire in the Netwarden agent does.

Canary files

The idea is old and it still works: put files somewhere ransomware will find them and no person ever will. A Passwords.xls in Documents. A tax return PDF in a finance folder. Nobody in my house has a reason to open them. Ransomware has every reason to, because it walks the file system and encrypts everything it can write to.

The agent hashes each canary with SHA-256 about once a minute and compares it with the hash it expects. A canary ends up in one of four states:

  • intact, the hash matches;
  • modified, the contents changed, or the file was replaced by a symlink;
  • missing, it's gone, which also covers a rename (Passwords.xls.lockbit);
  • unreadable, the agent got permission denied.

Anything but intact on a canary raises a critical alert on the first reading. Most of Netwarden's alerts want a few bad readings in a row before they page anyone, because a CPU spike for one sample means nothing. A canary is different. There is no normal reason for it to change, so there's nothing to wait for.

Unreadable gets its own alert with its own wording. On a NAS the usual cause isn't ransomware at all. Someone re-applied share permissions and wiped the access entry the agent relied on. That needs a different fix, and you want to know it's broken either way: a tripwire that can't see its canary isn't watching anything.

You can pin the expected hash in the config. When the agent starts, it checks a pinned canary against that hash, not against whatever it happens to find. Without a pin, the first read becomes the baseline, which the agent keeps in a small state file next to its config. Either way, a canary encrypted while the agent was stopped is still caught when it comes back up.

tripwire_canaries: /volume1/homes/alice/Documents/Passwords.xls@sha256:3f9a41c2…

If you'd rather not build decoys by hand, netwarden -plant-canaries <folder> writes four for you: a password list, a bank export as CSV, a tax return PDF and a signed contract as .docx. They're real files of their type (file calls the PDF a one-page PDF and the contract a Word document), with invented contents that are different on every run. Nobody can recognise a Netwarden canary by its hash. The command prints the config line with each hash pinned.

Doing it without root on a Synology

On Linux, macOS and Windows the agent usually runs with enough rights to read whatever you point it at. DSM 7 is stricter. Third-party packages run as their own unprivileged user, and that user can't read your shares at all. I checked: every share I care about came back with permission denied.

That turns out to be fine for canaries. The agent never needs to list the folder a canary is in. It only needs to open that one file. So the permissions are as narrow as they can be: read on the canary itself, traverse on the folders above it, and nothing else. The agent can hash Passwords.xls and can't see the file next to it.

There's one consequence worth thinking through. Because the agent can't list the folder, it can't tell "renamed to Passwords.xls.akira" apart from "deleted". Both look like missing. For a canary that's the right answer anyway. Both are critical.

Checking the snapshots themselves

Two more things turned out to be readable without privileges on DSM, and both are useful.

The first is the snapshot list. Every share's snapshots live under /volumeN/@sharesnap/<share>/, and each directory's name carries the time it was taken: GMT-06-2026.11.13-10.15.01. Listing those directories needs no rights, so the agent can tell when each share was last snapshotted. It doesn't need to know your schedule, either. It takes the median gap between the newest few snapshots as the share's interval, so an hourly share counts as late after about two hours and a daily one after about a day. A share that has stopped getting snapshots is a critical alert. Snapshots are the clock that gives you time to react, and a clock that has stopped protects nothing.

The second is the canary's copy in the newest snapshot. The access entry on the canary is captured in the snapshot along with the file, so the agent can open the same path inside it and compare hashes. If the live canary is fine and the snapshot copy is too, good. If the snapshot copy has changed, the newest snapshot was taken after the encryption, and the alert says so plainly: roll back to an older one. Snapshots taken before the canary first existed are skipped, since they can't contain it.

Folders: bursts and files that look encrypted

Canaries are cheap and almost impossible to set off by accident. But they only fire when the ransomware reaches them. For machines where the agent can read the data itself, it can also watch whole folders.

Every 15 minutes it walks each watched folder, reading metadata only, and counts the files whose change time is newer than the previous walk. It uses ctime rather than mtime on Linux, macOS and FreeBSD, because a rename updates ctime and leaves mtime alone. It keeps a day of those counts per folder. A walk is flagged as a burst when more than 200 files changed and that's more than ten times the folder's median. It's also flagged when more than a fifth of the folder disappeared. The first eight walks only build the baseline, so a fresh install doesn't alarm on nothing.

A burst on its own isn't proof. Copying a project folder in, restoring a backup or applying permissions to a whole tree looks just like it, and the alert says that too. So the agent also looks at what changed. For each changed file, up to 2,000 per walk, it reads the first 4 KB and asks three questions.

Does the name give it away? Most families append their own extension to the file's original one, so Report.docx.lockbit counts and a lone game.hive doesn't. Ransom notes are counted only when they look like notes: a HOW_TO_DECRYPT.txt or a restore_files.html, not somebody's decrypt.py or a ransomware-report.pdf.

Do the contents still match the type? A JPEG starts with FF D8 FF. A .docx, .xlsx or .zip starts with PK. A PDF has %PDF somewhere near the top, and MP4 and HEIC carry ftyp at byte 4. Encrypted files keep their names and lose their headers, so a .jpg that no longer starts like a JPEG is one of the strongest signals there is.

Has a text file turned into noise? Here I measure Shannon entropy over the first 4 KB. English sits around 4.5 bits per byte and source code under 6. Encrypted data sits at 7.9 or above, and anything over 7.2 counts. I only apply this to text formats: .txt, .md, .csv, code and config files. Photos, video and archives are already compressed, so they look random by nature. Running entropy on a folder of JPEGs would page you every night. Those get judged by their headers alone.

The rule I care most about is the one that says what not to judge. Reviewing the first version, I realised a Mac writing to a network share leaves ._IMG_0001.jpg files next to the real ones. Those are AppleDouble resource forks, not JPEGs, and every one of them would have failed the header check. The same goes for Office lock files (~$Report.docx), Windows thumbnail caches and .DS_Store. A NAS share is full of them. A tripwire that goes off on Finder metadata gets muted within a week, and then it's worse than nothing. Those files are skipped now.

Two smaller failure modes I'd rather name than hide. A walk that hasn't finished after ten minutes, usually a network mount that stopped answering, is thrown away, not reported half done. A partial count would look exactly like a mass deletion. And a folder where a subdirectory becomes unreadable between walks isn't counted as a deletion either: the files didn't go anywhere, the agent just can't see them.

What it doesn't do

It doesn't stop anything. It won't kill a process, pause snapshot rotation or extend a lock. On the NAS it couldn't anyway: it has no admin rights and I'd rather keep it that way. It isn't an EDR, either. It watches what ransomware does to files, not how the ransomware runs.

What it does is cut the time between "the files are being encrypted" and "you know about it" from whenever someone opens the wrong spreadsheet down to a minute or two. With 14-day locks, that's the difference between rolling back an hour and finding out the clean copies are gone.

Setting it up

All of this is off until you configure it. The new keys are in the netwarden.conf template that ships with the agent:

# Canary files: any change, rename, deletion or loss of read access alerts at once
tripwire_canaries: /home/alice/Documents/Finance/Passwords.txt@sha256:<hex>

# Folders walked for bursts of changes and encrypted-looking files
tripwire_folders: /home/alice/Documents,/srv/share
tripwire_walk_minutes: 15

On a Synology NAS, give the agent's user (sc-netwarden) read on each canary file and traverse on the folders above it. Snapshot checks need nothing at all. The alerts are created on the platform the first time the agent reports a canary, a watched folder or a share with snapshots. They're critical, and they go to the account owner by email and push like any other Netwarden alert.

It ships in agent 3.6.0. If you only do one thing, put a single canary in the folder you'd least like to lose, and pin its hash.

Get new posts by email

Subscribe and we email you when we publish something new.

No spam. Unsubscribe anytime.

Share this article

Help others discover simple monitoring

Related Articles

Announcing Netwarden Apps (alpha): error tracking that also tells you when next ships a CVE

We built an error tracker. We also built the part of the error tracker every other vendor decided not to: a daily cross-reference between your installed packages and OSV.dev's advisory feed, fired through the same alert pipeline. Apps is in alpha today, free for the first project, fixed price after that.

Thiago Vinhas-May 8

Self-Hosting Netwarden: The Single-Binary Preview

I'd been telling people self-hosting was 'on the roadmap' for months. The thing that finally made me stop saying that was a Reddit DM from a homelabber running fourteen client sites on a Hetzner box, who told me he'd pay double if it didn't phone home. Here's the binary.

Thiago Vinhas-May 7

How Netwarden's Security Wedge Works

Most monitoring tools don't surface security signals. Most security tools don't surface monitoring signals. We built one tool that does both — because the people we sell to don't want to pay for two. Here's how the security wedge actually works under the hood.

Netwarden Team-May 11

Ready for Simple Monitoring?

Stop wrestling with complex monitoring tools. Get started with Netwarden today.

Get Started FreeView Pricing