Source deletion cascades or anonymizes contacts
Why it matters
GDPR Art. 17 (right to erasure) and Art. 5(1)(e) (storage limitation) require that personal data be erased when the basis for holding it no longer applies. If a purchased list is invalidated — the vendor is found to have collected it unlawfully, or the list exceeds its contractual retention period — you need a reliable mechanism to remove or anonymize all contacts derived from that source. CWE-459 (Incomplete Cleanup) applies when deletion of a parent record leaves orphaned child records with dangling foreign keys and no defined disposition.
Severity rationale
Medium because orphaned contacts after a source deletion leave the system in a GDPR Art. 17 non-compliant state — records exist with no valid processing basis and no mechanism to find or remove them.
Remediation
Define explicit cleanup behavior for source deletion via a database trigger. Anonymization (replacing source_id with a tombstone) is preferred over cascade deletion when you need to retain aggregate analytics.
-- Option 1: Anonymize on source delete (preferred)
CREATE OR REPLACE FUNCTION anonymize_contacts_on_source_delete()
RETURNS TRIGGER LANGUAGE plpgsql AS $$
BEGIN
UPDATE contacts
SET source_id = 'deleted:' || OLD.id
WHERE source_id = OLD.id;
RETURN OLD;
END;
$$;
CREATE TRIGGER on_source_delete
BEFORE DELETE ON data_sources
FOR EACH ROW EXECUTE FUNCTION anonymize_contacts_on_source_delete();
-- Option 2: Cascade delete (use when retention is not needed)
ALTER TABLE contacts
ADD CONSTRAINT fk_contacts_source
FOREIGN KEY (source_id) REFERENCES data_sources(id)
ON DELETE CASCADE;
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Data Sourcing & Provenance Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- gdpr · Art. 17 — Right to erasure — source deletion must propagate to derived contact records
- gdpr · Art. 5(1)(e) — Storage limitation — orphaned records without valid source lack lawful basis
- cwe · CWE-459 — Incomplete Cleanup
Taxons
History
- 2026-04-18·v1.0.0·Initial import from data-sourcing-provenance·automated