Lesson 7 of 13 · 15m
Consent Is a State Machine, Not a Banner
Article 7 makes consent demonstrable, granular, and symmetric — engineer records, edge gating, and an audited reject-all path.
The banner is the view
When the French CNIL fined Google €150 million and Facebook €60 million on January 6, 2022, the violation wasn't that consent was missing. Both sites had banners. The violation was asymmetric friction: accepting cookies took one click, refusing took several. Article 7(3) of the GDPR requires withdrawal to be as easy as giving. The CNIL measured the click counts.
That is the correct mental model for consent: it is a state machine with an audit trail, not a UI element. The banner renders the state; the state gates what your infrastructure does.
The record you must be able to produce
Article 7(1) says the controller "shall be able to demonstrate" consent. A boolean consented=true on the user row demonstrates nothing. The record is:
CREATE TABLE consents (
subject_id uuid NOT NULL,
purpose_id text NOT NULL, -- 'analytics', 'ads', 'personalization'
notice_version text NOT NULL, -- which notice text they saw
action text NOT NULL, -- 'granted' | 'withdrawn'
method text NOT NULL, -- 'banner', 'settings', 'api'
created_at timestamptz NOT NULL DEFAULT now()
);
-- state = latest action per (subject_id, purpose_id)Three properties matter. Granularity: consent is per-purpose, not bundled — GDPR requires "specific" consent, and the CJEU's Planet49 ruling (C-673/17, October 2019) confirmed a pre-ticked checkbox is no consent at all; consent must be an active act. Versioning: when your notice text changes materially, previously granted consent doesn't cover the new purposes — re-ask. Symmetry: withdrawal takes the same number of steps as grant, and it must work — a withdraw button that flips a flag the trackers ignore is a decoration.
Enforcement is downstream of the banner
The consent state has to reach the code that moves data. Concretely:
- Client side. Tag managers and CMP hooks gate script injection on
consents[purpose]. If the analytics tag fires before the user answers, you collected without basis — the answer came after the collection. - Server side. Ingestion endpoints re-check purpose state. Google Consent Mode v2 (required for EEA traffic since March 2024) passes
ad_storage,analytics_storage,ad_user_data, andad_personalizationsignals — read them at the edge and drop non-consented categories rather than collecting-and-filtering. - Vendor side. ePrivacy Directive Article 5(3) requires consent for non-essential storage — the legal trigger is the cookie/SDK writing or reading, not your banner's existence.
Withdrawal has to propagate, too. A user revoking analytics consent must stop events flowing to the vendor's existing session — flush queues, kill the tag, expire the identifiers — and the record of that revocation lives in the same audit table as the grant.
Audit the unconsented path
The only consent test that matters is what fires when the user says no. Crawl your own site with Playwright, reject everything, and enumerate the outbound requests: any analytics, ad, or third-party call on the unconsented path is a violation in production. Researchers at KU Leuven ran this at scale (USENIX Security 2022) and found over 1,800 EU sites leaking emails to trackers before users even submitted the form — the leaky-forms problem lives in your tag configuration, not your code review.
"Consent or pay" — the model Meta adopted in late 2023 — got its own EDPB opinion in April 2024: for large platforms, a binary pay-or-track choice generally fails the "freely given" test. Don't build your revenue model on a basis regulators are actively dismantling.
The practice
Consent engineering = records + gating + audit. Store versioned per-purpose records with withdrawal symmetry. Gate every tracker at the edge, not the banner. Regression-test the reject-all path quarterly. A consent system nobody can demonstrate is, under Article 7(1), a consent system you don't have.
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.