Lesson 2 of 13 · 14m
Where PII Hides
Personal data leaks through access logs, error trackers, session replay, and support tools — scrub at the boundary and prove it with a canary.
The request line
Here is what happens when a user requests a password reset on a badly designed flow: GET /account/reset?email=alice@example.com HTTP/1.1 lands in the nginx access.log on disk, in every CDN edge log the request traversed, in the browser's history, and — if the response links anywhere external — in the Referer header that next site receives. The email address you meant to keep in a users table just replicated to four systems you don't control.
The PII in your stack isn't concentrated in the tables you designed. It's distributed across the pipelines you didn't.
The sinks
Access and application logs. Dynamic IP addresses are personal data to the website operator when the operator has legal means to identify the subscriber — the CJEU ruled exactly that in Breyer v. Germany (C-582/14, October 2016). Your logs don't stop being personal data because they're flat files. logrotate is a retention policy whether you wrote one or not.
Error trackers. Sentry's defaults changed direction and most write-ups haven't caught up. On sentry-python 2.x, send_default_pii defaults to False — request headers, cookies, bodies, and user identity stay home unless you opt in. SDK 3.0 removed the flag for a data_collection dict whose per-category defaults are more permissive: request headers, cookies, user identity (user.id, user.email), IP, and JSON/form request bodies (up to max_request_body_size) are collected unless you opt each out. Either way the blast radius is the same — every exception ships whatever the user just submitted, which for a checkout crash is card-adjacent form data.
Session replay. Princeton's Center for Information Technology Policy published "No Boundaries" in November 2017: session replay scripts from FullStory, Hotjar, and similar vendors were recording every keystroke and field on thousands of sites, including medical search terms on pharmacy pages at Walgreens. Everything the user types — including into fields they never submit — goes to the vendor.
Analytics payloads. Event schemas drift. An event named signup_completed grows email, plan, ref properties because they're convenient, and now your product analytics hold an identity map.
Support tools. Every ticket opened through Intercom or Zendesk copies message bodies into a second datastore with its own retention and its own breach surface.
The fix is scrubbing at the boundary
You cannot audit what leaves the building once it leaves. Scrub before egress:
# Sentry SDK 3.x: keep request context, strip the PII inside it
def before_send(event, hint):
request = event.get("request", {})
request.pop("data", None) # form post bodies
request.pop("cookies", None)
request.pop("headers", None)
for b in event.get("breadcrumbs", {}).get("values", []):
b.pop("data", None)
return event
sentry_sdk.init(
dsn=...,
data_collection={"user_info": False, "http_bodies": []},
before_send=before_send,
)
# sentry-python 2.x: send_default_pii=False instead of data_collection# Rails — filter_parameters scrubs params from logs
config.filter_parameters += [:email, :password, :token, :ssn, :dob]# Django
@sensitive_post_parameters("email", "phone")
@sensitive_variables("card_number")For nginx, keep IPs out of long-lived logs or truncate them:
log_format noip '$remote_user [$time_local] "$uri" $status';
# or anonymize: log_format anon '$remote_addr_anon ...' via map on first 3 octets
map $remote_addr $remote_addr_anon { ~(?P<a>\d+\.\d+\.\d+)\. $a.0; }Prove it with a canary
Auditing sinks by reading configs doesn't work — the leak is what actually flows, not what you meant. Send a fixture through the real pipeline: sign up as zzz-canary-7f3a@example.com, use the app for ten minutes, then grep every sink — access logs, app logs, Sentry, the analytics console, the support desk — for zzz-canary. Every hit is a leak to fix or a documented, purposeful copy. Run it in CI quarterly; pipelines drift.
The tradeoff for scrubbed logs is harder debugging. Debug with IDs, not payloads: a user ID resolves through one keyed lookup under access control; an email in a log resolves for anyone who can read the log — which includes your CDN's ops team.
The practice
Put a sink inventory next to your data inventory: logs, error tracking, replay scripts, analytics, support desks. Each gets scrub rules and a retention. The field that is justified in the users table is not thereby justified in access.log.
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.