Quiz 2

Web Tracking Technologies and Privacy

1494 words
7 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Web Tracking Technologies and Privacy ## 🎯 Learning Objectives - Identify different web tracking mechanisms (cookies, fingerprinting, pixels) - Explain how third-party tracking works across sites - Analyze the privacy implications of tracking technologies - Implement privacy-preserving alternatives - Evaluate leg...

Web Tracking Technologies and Privacy

🎯 Learning Objectives

  • Identify different web tracking mechanisms (cookies, fingerprinting, pixels)
  • Explain how third-party tracking works across sites
  • Analyze the privacy implications of tracking technologies
  • Implement privacy-preserving alternatives
  • Evaluate legal frameworks regulating web tracking

1. Introduction to Web Tracking

1.1 Intuition

Every time you visit a website, you leave digital footprints. Web tracking is the practice of collecting these footprints to identify you, follow your behavior across sites, and build profiles about your interests, habits, and identity. It's like a detective following you through a mall, noting every store you enter, how long you stay, and what you look at — except this detective follows you across every mall in the world.

1.2 The Tracking Ecosystem

(Diagram)

2. Cookies: The Original Tracker

2.1 How Cookies Work

Cookie TypeSet ByPersistent?Accessible By
First-partyThe website you're visitingYesOnly that website
Third-partyA different domain (embedded content)YesThat domain across all sites
SessionAny websiteNo (deleted when browser closes)Only during session
python
# Simulating how third-party cookies track across sites
class ThirdPartyTracker:
    def __init__(self, tracker_id):
        self.tracker_id = tracker_id
        self.user_profiles = {}  # user_id → {interests, sites visited}
    def record_visit(self, user_id, site, page_category):
        if user_id not in self.user_profiles:
            self.user_profiles[user_id] = {
                'sites_visited': set(),
                'interests': [],
                'first_seen': None
            }
        profile = self.user_profiles[user_id]
        profile['sites_visited'].add(site)
        profile['interests'].append(page_category)
        return self.get_ads_for_user(user_id)
    def get_ads_for_user(self, user_id):
        profile = self.user_profiles.get(user_id, {})
        interests = profile.get('interests', [])
        # Target ads based on accumulated interests
        if 'shoes' in interests and 'sports' in interests:
            return "Ad: Running shoes - 20% off!"
        elif 'travel' in interests:
            return "Ad: Flight deals to Europe"
        else:
            return "Ad: Generic product"
# Simulate user browsing
tracker = ThirdPartyTracker("ad_network_1")
# User visits different sites
print(tracker.record_visit("user123", "news.com", "sports"))
print(tracker.record_visit("user123", "shop.com", "shoes"))
print(tracker.record_visit("user123", "blog.com", "travel"))
Output:
pseudo
Ad: Generic product
Ad: Running shoes - 20% off!
Ad: Flight deals to Europe
AttributeMeaningExample
SecureOnly sent over HTTPSSet-Cookie: session=abc; Secure
HttpOnlyNot accessible via JavaScriptSet-Cookie: session=abc; HttpOnly
SameSiteControls cross-site sendingSameSite=Lax (default), SameSite=Strict
DomainWhich domains can accessDomain=.example.com
PathWhich paths the cookie is forPath=/
Max-AgeExpiration in secondsMax-Age=3600 (1 hour)

3. Browser Fingerprinting

3.1 Intuition

Cookies can be deleted or blocked. But your browser reveals a wealth of information just through normal operation — screen resolution, installed fonts, timezone, language, browser version, GPU model. The combination of these is often unique enough to identify you. This is browser fingerprinting: no cookies needed.

3.2 Fingerprint Components

AttributeInformation LeakedUniqueness
User-AgentBrowser, OS, deviceLow (20% share)
Screen resolutionMonitor sizeMedium
TimezoneGeographic regionLow
Installed fontsSoftware, OSHigh
GPU rendererGraphics card modelVery high
Canvas fingerprintGPU rendering quirksExtremely high
Audio fingerprintAudio stack detailsVery high
WebGL fingerprint3D rendering capabilitiesExtremely high

3.3 The Panopticlick Study

The EFF's Panopticlick project found:
MetricValue
Browsers with unique fingerprint83.6% (with Flash/Java)
Browsers unique without plugins38.1%
Bits of identifying information18.1 bits on average
Population share per fingerprint1 in 286,777

3.4 Canvas Fingerprinting

javascript
// Simulated canvas fingerprinting
function getCanvasFingerprint() {
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');
    // Draw text with specific font
    ctx.textBaseline = 'top';
    ctx.font = '14px Arial';
    ctx.fillStyle = '#f60';
    ctx.fillRect(0, 0, 100, 50);
    ctx.fillStyle = '#069';
    ctx.fillText('Browser fingerprint!', 2, 2);
    // The exact rendering depends on GPU, fonts, OS
    const dataURL = canvas.toDataURL();
    // Hash the rendering differences
    return hashCode(dataURL);
}
Tracing Table — Fingerprint Uniqueness:
UserScreenFontsGPUCanvas HashUnique?
A1920×1080234 fontsNVIDIA GTX 3080a1b2c3Yes
B1920×1080234 fontsNVIDIA GTX 3080a1b2c3No (same as A)
C2560×1440189 fontsAMD Radeon 6800d4e5f6Yes
D1366×768112 fontsIntel Integratedg7h8i9Yes

4. Tracking Pixels and Beacons

4.1 How Pixels Work

A tracking pixel is a 1×1 transparent image embedded in a page or email. When your browser loads it, it sends information to the tracker.
html
<!-- Tracking pixel in email -->
<img src="https://tracker.com/pixel?user=abc&email_id=123&action=open"
     width="1" height="1" style="display:none;" />
Information a pixel can capture:
  • Email opened (loads pixel from server)
  • IP address (geographic location)
  • Timestamp (when you read the email)
  • Device info (via User-Agent header)
  • Referrer (which page/site you came from)

5. Privacy-Preserving Alternatives

5.1 Defense Mechanisms

(Diagram)

5.2 ITP (Intelligent Tracking Prevention)

Apple's Safari introduced ITP, which limits what third-party cookies can do:
ITP VersionWhat It Blocks
ITP 1.0 (2017)Third-party cookies after 24h without direct interaction
ITP 2.0 (2018)All third-party cookies partitioned by domain
ITP 2.3 (2019)Script-writable storage (localStorage) also partitioned
ITP 3.0 (2021)Bounce tracking, link decoration tracking blocked

6. Common Pitfalls

Pitfall 1: Assuming Incognito = Private

The mistake: Thinking incognito/private browsing prevents all tracking. Why students make it: The word "private" implies privacy. How to catch it: Incognito only prevents local history storage. Third-party cookies, fingerprinting, and network-level tracking still work. Correct approach: Use dedicated anti-tracking tools (Privacy Badger, uBlock Origin) and consider Tor for sensitive browsing.

Pitfall 2: Forgetting About Fingerprinting

The mistake: Thinking blocking cookies solves the tracking problem. Why students make it: Cookies are the most discussed tracking mechanism. How to catch it: Modern trackers use fingerprinting as a cookie replacement. When you block cookies, the tracker fingerprints you instead. Correct approach: Use browsers/plugins that also block fingerprinting (Firefox with resistFingerprinting, Brave).

Pitfall 3: Misunderstanding SameSite Attributes

The mistake: Setting SameSite=Strict and wondering why legitimate cross-site flows break. Why students make it: Strict sounds safest. How to catch it: SameSite=Strict blocks all cross-site cookie sending, including legitimate OAuth flows and payment redirects. Correct approach: Use SameSite=Lax as default (allows top-level navigation), and only use Strict when cross-site access is never needed (e.g., CSRF tokens).

7. Key Concepts Reference

ConceptDefinitionPrivacy Impact
First-party cookieSet by visited domainLow (limited to one site)
Third-party cookieSet by embedded domainHigh (cross-site tracking)
Canvas fingerprintingDrawing-based device identificationVery high (hard to block)
Tracking pixel1×1 image for data collectionMedium
ITPSafari's tracking preventionReduces cross-site tracking
SameSiteCookie attribute for cross-site controlPrevents CSRF, limits tracking
GDPR consentLegal requirement for trackingUser control over tracking

8. 📝 Practice Questions

Q1: How does a third-party cookie track you across different websites?
Answer: When you visit Site A, it loads content from Tracker X (ad, analytics script). Tracker X sets a cookie in your browser. When you visit Site B, which also loads content from Tracker X, your browser sends the same cookie. Tracker X sees the cookie and knows it's the same user, recording both visits. Over time, Tracker X builds a profile of all the sites you visit that use its services. Q2: Why is canvas fingerprinting harder to block than cookies?
Answer: Canvas fingerprinting doesn't use storage — it's a normal browser function (drawing on a canvas). Blocking it would break legitimate canvas use (games, data visualization, photo editing). It's indistinguishable from legitimate canvas operations. Detecting canvas fingerprinting requires heuristic analysis (e.g., drawing in a hidden canvas), which can have false positives. Q3: A browser has a 1 in 100,000 unique fingerprint. How many bits of entropy does this represent?
Answer: Entropy = log₂(100,000) = 16.6 bits. This means the fingerprint carries 16.6 bits of identifying information. Combined with IP address (~16 bits), the pair is almost certainly unique — sufficient to identify a specific device among all internet users. Q4: What's the difference between SameSite=Lax and SameSite=Strict?
Answer: SameSite=Strict: Cookie is never sent for cross-site requests (including when clicking a link from Site A to Site B). SameSite=Lax: Cookie is sent for top-level navigation GET requests from other sites (clicking a link), but not for embedded requests (images, iframes, scripts). Lax is the default since Chrome 80 — it prevents CSRF attacks while allowing most legitimate navigation flows. Q5: How does ITP in Safari differ from third-party cookie blocking in Chrome?
Answer: Safari's ITP uses a more nuanced approach: it blocks third-party cookies by default but allows them if the user directly interacted with the domain recently. Chrome's approach is more binary: third-party cookies are either fully blocked (in Incognito) or fully allowed. Both are moving toward phasing out third-party cookies entirely (Chrome's Privacy Sandbox), but with different timelines and replacement mechanisms. Q6: What information does a tracking pixel in an email reveal?
Answer: (1) That the email was opened (and when), (2) the IP address (approximate location), (3) device/browser info from headers, (4) whether images were loaded (vs. text-only view), (5) engagement time (how long before the pixel loaded). This is why privacy-conscious email clients block images by default. Q7: Why is the combination of browser fingerprint and IP address usually unique?
Answer: An average browser fingerprint has ~18 bits of entropy (unique among ~286,000), and an IP address/User-Agent combination also carries ~16 bits. The combined entropy is ~34 bits, meaning the pair is unique among ~17 billion devices — far more than the ~5 billion internet users. Even a moderately unique fingerprint combined with a common IP is enough to identify a specific device.

9. 🔗 Cross-References

Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.