Lesson 11 of 13 · 13m
Retention Is a Deadline, Not a Folder
Storage limitation engineered as TTL columns, monitored sweepers, and per-sink expiries — Marriott's four-year dwell priced it.
Four years of dwell time
The Starwood reservation system was breached starting in 2014. Marriott bought Starwood in 2016, inherited the intrusion, and disclosed it in November 2018: roughly 339 million guest records, including 5.25 million unencrypted passport numbers. Attackers had four years inside because the data kept rewarding them — reservations stretching back years, all reachable, all still hot. The ICO's £18.4 million fine noted the failures plainly. What made it catastrophic wasn't the perimeter; it was that nothing ever expired.
GDPR Article 5(1)(e) states the rule as architecture: keep personal data "no longer than is necessary." Not "as short as you feel like." Necessary is a function of purpose, and purposes have ends.
Retention is a schema property
A retention schedule isn't a policy PDF. It's columns and jobs:
ALTER TABLE events ADD COLUMN purge_after timestamptz
NOT NULL DEFAULT now() + interval '30 days';
CREATE INDEX events_purge ON events (purge_after);
-- nightly sweeper
DELETE FROM events WHERE purge_after < now();Every table carrying personal data gets a TTL at creation time, and the TTL is set by the purpose: session tokens live hours, access logs live days-to-weeks, invoices live the statutory tax years, analytics rollups live as aggregates with the rows dropped. S3 lifecycle rules expire object versions; logrotate/journald bound log retention; the same discipline covers backups, warehouses, and staging dumps.
Statutory conflicts resolve by isolation, not blanket keeping: tax records that must survive seven years go to an access-locked archive store, not the operational cluster. The legal hold doesn't mean the data stays online and queryable — it means it stays recoverable for exactly the obligated reader.
A retention matrix for a typical SaaS, stated in the schedule, not implied:
- session tokens: hours-to-days, rotated
- access logs: 30 days, truncated IPs
- application logs: 14-30 days, no bodies
- error events: 90 days, scrubbed
- analytics: row TTL 90 days, rollups kept as aggregates
- backups: 30-day window, purge on restore
- invoices/tax records: statutory years, in the locked archive
- support tickets: 12-24 months
Each entry has an owner and a clock. "Keep forever" is only allowed where a statute names the years — and even then, the data moves to the archive, not the hot path.
The sweeper must be monitored
A retention job that silently fails is a hoard. Run the deletion count as a metric: deleted_rows_per_day for each sweeper, alert on zero. If the cron dies, the TTL column keeps filling and nothing purges; you'll discover it during the incident, when the dump is bigger than the policy said.
The "future ML" argument deserves its standard answer: unspecified future purposes are not purposes. If you can't name the feature and the fields, you're storing liability. Vastaamo's 33,000 patients sat indefinitely in a live system because nothing expired them.
The copies follow their own clocks
Retention on the primary table doesn't govern the copies. Each sink has its own retention to set:
- Backups — bounded windows (30 days is a defensible common choice) with restore-time purge.
- Warehouses/lakes — row TTLs or rollup-then-drop.
- Analytics vendors — their retention settings, not your schema.
- Support desks — ticket archival settings.
- Error trackers — event retention config.
The practice
Default TTL at schema time: no column or table ships without purge_after or a named statutory exception. Sweepers run and are monitored. Retention is stated per sink in the ROPA. The blast radius of your next breach is the number of records still stored when it happens — and that number is a configuration, not fate.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Healthcare Ransomware: Why Hospitals Can't Patch Fast Enough
The criminals behind the attack claim to have shared 400GB of patient data. The NHS stated it is working swiftly to confirm the validity of these files. The ransomware attack on the UK's National Health Service (NHS) continues to disrupt health services in London, with a significant amount of…
RSA Is Simple. Deploying RSA Correctly Almost Never Is.
The capstone to our RSA series. The math checks out. Shipping it as written gets you breached. This is the nineteen-year-old attack that proves it, and what belongs in production instead.
RSA in JavaScript Part 2: The JWT Is Where You'll Actually Meet It
Most JavaScript developers never call an RSA function directly. They verify an RS256 token, and two classic attacks turn that into an authentication bypass — both demonstrated here, both fixed by one line.