In development
Sard Cocoon
Protected restic backup storage. Saved backups cannot be destroyed before their protection term ends, even if the control server, the agents on the hosts, the prune account and the storage’s own network front end are compromised. From the outside it is an ordinary restic REST server, so Cocoon plugs into Sard and into any restic as it is.
A backup that outlives ransomware
Ransomware or an attacker who gets into the infrastructure deletes the backups first. The usual protections are weak:
- rest-server --append-only forbids deletion, but then nothing can be cleaned up either: space grows forever and retention is done by hand;
- filesystem snapshots and Object Lock protect only if their settings and rights are kept apart from whoever was compromised;
- a retention policy in the control server is useless once the control server itself is compromised.
Ordinary restic pruning, and nothing is lost
The protection sits below restic and needs no understanding of the backups’ contents. restic files are never rewritten: a file’s name is the SHA-256 of its content, only the set of files changes. Cocoon regularly commits a checkpoint, an immutable set of all the repository’s files, including those deleted since the last one. A checkpoint is hard links to the same files; no data is copied.
restic deletes and prunes in the live repository as usual, and a deleted file stays in the checkpoint until that checkpoint expires. The Linux kernel (fs-verity) keeps the files immutable, and one small trusted process keeps the terms and the checkpoints. Cocoon knows neither restic keys nor the contents of the backups.
Works with plain restic
Any unmodified restic runs init, backup, forget, prune, restore and check. The data format and the protocol are standard: Cocoon works without the rest of Sard too, and your backups stay ordinary restic repositories. The code is based on restic rest-server.
A restore reads the live repository or any checkpoint as a separate read-only repository.
Its place in Sard
In Sard, Cocoon stands next to S3, SFTP and the local disk: the agent writes to it as to any restic REST server, and restore verification proves the backup is right. The Sard control server still holds no keys, and with Cocoon it cannot delete what is saved either.
Four processes, one trusted
One cocoon binary, separate processes under separate Linux users, run by systemd:
- Front, the network entry: the restic protocol, TLS, accounts, limits. Assumed captured: the storage is mounted read-only for it, writes go to Guard and deletions to Sealer.
- Guard, the intake: writes an incoming file into a descriptor handed out by Sealer. It has no write paths of its own, and the file size is limited by the kernel. Also assumed captured.
- Sealer, the only trusted one: no network, no special privileges. It publishes a file only after enabling fs-verity and checking the hash, moves deleted files to pending, commits checkpoints and removes them when their term is over, keeps a hash-chained journal and a space reserve.
- Provisioner, a one-time setup: users, rights, read-only mounts, filesystem checks.
Three accounts per repository
- backup writes new files and reads, and deletes only locks;
- prune deletes and writes indexes and locks but no data, so prune runs only in “remove what is unneeded whole” mode;
- restore reads the live repository and any checkpoint.
Who can do what when compromised
| Compromised | Can | Cannot |
|---|---|---|
| Control server or agent | write garbage, fill the quota | delete or change what is saved |
| The prune account with the restic key | delete everything in the live repository | touch a checkpoint |
| Front | whatever the accounts allow | write around Guard and Sealer |
| Guard | stop writes, lose what is not yet published | change what is published, skip a checkpoint |
| Sealer | delete checkpoints on this host | change the contents of files |
| root on the host | anything on this host | a replica on another machine, Object Lock |
Guarantees
- Every repository state published by Sealer lands in a checkpoint.
- A file in a checkpoint exists, does not change and stays readable until the checkpoint expires.
- A checkpoint expires only by time and policy, and the last one never does. Time is Sealer’s monotonic counter: moving the system clock forward frees nothing.
- The next needed checkpoint can always be created: short of space, Cocoon refuses writes instead of deleting what is protected.
- All of this with Front, Guard, the prune account, the agents and the control server compromised, and after a power loss at any moment.
Where the guarantees end
We say plainly what Cocoon does not protect from:
- root on the Cocoon host: that needs an outer boundary, a replica on another machine or S3 with Object Lock;
- a dead disk without a replica;
- a wrong backup: restic checks that with the key, and in Sard, restore verification does;
- a compromise of the source that goes unnoticed for long: data is kept within the protection term;
- writes may stop under attack: they are traded away on purpose for preservation.
Retention
A checkpoint is made after a completed backup and on a schedule, if there are new files. Retention is by time, not by count: “the last N” would be pushed out by N garbage backups from a compromised agent. Every checkpoint of the last day, hourly ones for a week, then daily, weekly and monthly.
How reliability is checked
Every property of Cocoon is backed by a test with its output kept: immutability and rights at the kernel level (fs-verity on ext4 and btrfs), unmodified restic, a TLA+ model of the trusted process, attacks on every component, power loss at every flush point. The order of priorities does not change: security, then fault tolerance, then performance; guarantees are never weakened for speed.
Next in the product
- Alarms with delivery and a heartbeat: Cocoon going silent is an alarm too.
- Witness, an outside witness of Sealer’s journal: no answer or a rewritten history raises an alarm.
- A replica on another machine on a pull model: a boundary that even root on the Cocoon host cannot cross.
- Administrator commands signed with an offline key, with a delay, to weaken the policy.
- Signed Cocoon updates and migrations of the journal format.
- Integration with the Sard agent and console.
- Installation and operation for the pilot, checks on a matrix of kernels and distributions, a long run and a load test of node capacity.
- An external audit of Sealer and the process boundaries.
Requirements and license
Linux, an ext4 filesystem with fs-verity or btrfs. One node is meant for about 100–200 repositories of small and mid-sized businesses; more means more nodes. The license is AGPL-3.0, the rest-server code is BSD-2-Clause.
When
Sard Cocoon is in development and is not part of a Sard release yet.