Privacy in social networks
Privacy in social networks covers how personal and relationship data can be protected from re-identification and inference; engineers design anonymisation, access control and differentially-private mechanisms while understanding their limits.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Social networks hold personal attributes and links (who connects to whom). Engineers use privacy techniques when publishing network data, building analytics, or offering APIs so users' identities and sensitive attributes cannot be re-discovered or misused.
Key ideas
Start from first principles and simple definitions.
Privacy: protection of an individual's personal information and relationships from unwanted disclosure or inference. (Used here to mean privacy of individuals represented in social-network data.)
Data publisher model: a party publishes a dataset derived from a social network (node attributes, edges, or aggregates). The publisher must assume adversaries may have auxiliary information (external data) and try to re-identify nodes or infer attributes.
Anonymisation: removal or replacement of direct identifiers (names, IDs). Definition: Anonymisation is any process that removes or modifies explicit identifiers so that an individual is not directly named in the published data. Assumption: adversary can still use structural and attribute patterns to re-identify.
De-anonymization (re-identification): recovering the identity of a node in an anonymised dataset by matching patterns to external data. Exact statement: given an anonymised graph G' and an auxiliary graph H, a de-anonymization attack is a mapping f from nodes of G' to nodes of H such that structural similarity is high; if f(u)=v then u is re-identified as v. Common exam derivation: show how subgraph matching or seed-based propagation leads to full mapping.
k-anonymity (for tabular attributes): A released table satisfies k-anonymity if every combination of quasi-identifier values appears at least k times. Exact statement: for every record r in the released table T, there exist at least k−1 other records in T with identical values on the quasi-identifier attributes. Assumption: attacker uses quasi-identifiers only; fails if attacker has extra attribute distribution knowledge.
l-diversity: An enhancement of k-anonymity addressing attribute homogeneity. Definition: a k-anonymous equivalence class has l-diversity if it contains at least l ``well-represented'' values for the sensitive attribute. One formal variant: distinct l-diversity requires at least l distinct sensitive values per class.
t-closeness: Further improvement: an equivalence class has t-closeness if the distance (e.g., Earth Mover's Distance) between the class's sensitive-attribute distribution and the global distribution is ≤ t.
Differential privacy (DP): a mathematical privacy guarantee for randomized algorithms. Exact formal definition: A randomized mechanism M gives ε-differential privacy if for any two datasets D and D' that differ in one individual's data (a single row), and for any subset S of outputs, Pr[M(D) ∈ S] ≤ exp(ε) · Pr[M(D') ∈ S]. Assumptions: the data universe and notion of neighbouring datasets (row-level or user-level) must be specified.
Global sensitivity (Δf) of a function f on datasets: Δf = max_{D,D' differing in one record} |f(D) − f(D')|. This is the maximum change in output caused by adding/removing one record.
Laplace mechanism: to release a numeric query f(D), release f(D) + noise where noise is drawn from Laplace(0, b) with b = Δf/ε. This achieves ε-DP. Composition principles (exam-relevant): applying k mechanisms with parameters ε1,…,εk on the same individuals yields total ε = ε1+…+εk (sequential composition); post-processing invariance: any function of the DP output preserves DP; and parallel composition: queries on disjoint subsets do not accumulate privacy loss.
Node privacy vs edge privacy in networks: For network data, define neighbouring datasets in two ways: edge privacy: D and D' differ in one edge; node privacy: D and D' differ in one node and all incident edges. Node privacy is stronger (harder to achieve) because changing one node can change many edges.
Structural attacks on networks: two main styles – (1) matching a published anonymised graph to an auxiliary graph by aligning high-degree nodes and neighborhoods; (2) seed-and-propagate: if a few nodes are identified (seeds), use neighbor overlap to identify more nodes. Exams often ask to describe a propagation algorithm step-by-step and justify correctness by counting common neighbours.
Access control and differential access: besides releasing datasets, engineers use rate limits, query auditing, and tiered access to reduce risk. These are operational controls, not mathematical privacy guarantees.
If you study other topics: these methods are applied after or instead of Graph concepts, Node centrality measures, Link analysis and community detection, and when mining Twitter/Facebook or visualising social networks.
Diagrams to draw in answers (describe exactly):
- For k-anonymity: draw a table of 6 rows with columns {ZIP, Age, Disease} labelled. Show original with unique ZIP+Age combos, then show generalised table where ZIPs are masked to 3-digit and Ages are intervaled so each quasi-identifier combination appears at least k times; label groups as equivalence classes.
- For de-anonymisation: draw two graphs side-by-side (published anonymised graph G' and auxiliary graph H). Mark 2–3 seed nodes with letters, draw matching edges showing their neighbourhood overlap, then show propagation arrows to other nodes being matched.
Formulas
Pr[M(D) ∈ S] ≤ e^{ε} · Pr[M(D') ∈ S] — For differential privacy. ε is the privacy parameter (dimensionless). Applies when D and D' differ in one individual by definition used (row/node/edge).
Δf = max_{D,D' neighbours} |f(D) − f(D')| — Global sensitivity. Δf has same units as f(D) (e.g., count → dimensionless integer).
b = Δf / ε — Laplace noise scale. b has same units as f(D). Applies when using Laplace(0,b) to achieve ε-DP.
Noise ~ Laplace(0, b) — Noise distribution added to numeric query; Laplace PDF: (1/(2b)) · exp(−|x|/b).
No SI unit needed for probabilities or ε (dimensionless). For counts use unit "count".
Worked examples
Model answer 1 — Explain k-anonymity, show failure under background knowledge Question: Define k-anonymity and explain with a short example how an adversary can still infer a sensitive attribute using background knowledge. Model answer:
- Definition: A table satisfies k-anonymity if each combination of quasi-identifier values appears at least k times.
- Example table (before anonymisation): columns {ZIP, Age, Disease}. Rows:
- (13053, 28, Flu)
- (13053, 29, Cancer)
- (13054, 28, Flu)
- (13055, 27, HIV)
- (13055, 27, HIV)
- (13056, 28, Flu)
- To achieve 2-anonymity (k=2) we generalise Age to 2x while keeping ZIP at 5 digits, so rows become groups where quasi-identifiers repeat at least twice; for example, (ZIP=13053, Age=2x) groups rows 1–2.
- Attack: suppose adversary knows target lives in ZIP 13053 and age 28 (background knowledge). After anonymisation the target falls into an equivalence class where Disease values are {Flu, Cancer}. If additional background knowledge (e.g., the target visited an oncology clinic yesterday) exists, the adversary narrows to Cancer. This shows k-anonymity did not prevent sensitive-attribute inference.
- Conclusion: k-anonymity protects against direct re-identification using quasi-identifiers alone but not against attribute disclosure when sensitive values are homogeneous or adversary has extra knowledge.
Model answer 2 — Differential privacy and Laplace mechanism (numeric) Question: Describe ε-differential privacy and show how to release the count of edges with ε=0.5 using Laplace mechanism. Use a simple sensitivity calculation. Model answer:
- Definition: ε-differential privacy requires Pr[M(D) ∈ S] ≤ exp(ε)·Pr[M(D') ∈ S] for all neighbour datasets D,D' and outputs S.
- We choose edge-level privacy: neighbouring graphs differ by one edge. Consider query f(D) = number of edges. Then Δf = 1 because adding/removing one edge changes the count by at most 1.
- With ε = 0.5, Laplace scale b = Δf/ε = 1/0.5 = 2. So add noise drawn from Laplace(0,2).
- Example numeric release: Suppose actual edge count f(D) = 12. Sample noise n from Laplace(0,2). If n = −1.3 (example), released value = 12 − 1.3 = 10.7. We may round to nearest integer if integer output required, noting post-processing preserves DP.
- Interpretation: ε=0.5 gives moderate privacy; smaller ε gives stronger privacy but larger noise.
Model answer 3 — Sketch of seed-and-propagate de-anonymisation algorithm and why it works Question: Describe seed-and-propagate attack and reason about when it succeeds. Model answer:
- Input: anonymised graph G' and auxiliary graph H; attacker has mapping for a small set of nodes (seeds).
- For each unmapped node u in G': find candidate nodes v in H whose neighbours include mapped images of u's mapped neighbours. Measure overlap score = |N_{G'}(u) mapped ∩ N_H(v)|.
- If overlap score exceeds threshold T and is significantly larger than others, map u→v and add to seed set.
- Repeat until no new mappings.
- Success conditions: works when neighbourhoods are distinctive (high degree nodes, low automorphism), auxiliary graph is similar to G', and seeds are correct. Failures when graphs differ, or many symmetrical nodes exist.
Common mistakes
- Assuming k-anonymity prevents attribute inference; it prevents identity linkage only over the chosen quasi-identifiers.
- Forgetting that post-processing (any deterministic or randomized function applied to the DP output) cannot break differential privacy; however, post-processing may reduce utility.
- Using global sensitivity incorrectly for composite queries (must compute sensitivity for the whole query function).
For your exam
Question types you will see: definitions (e.g., define differential privacy, k-anonymity), short notes (compare k-anonymity and DP), derivations (compute sensitivity and noise scale), numericals (apply Laplace mechanism with given ε), diagrams (draw anonymised table before/after), and algorithm descriptions (seed-and-propagate). A full-marks answer includes:
- Precise definition with symbols where appropriate (for ε-DP give the inequality),
- Clear statement of assumptions (edge vs node privacy, attacker model),
- For derivations: show sensitivity calculation step-by-step, compute b = Δf/ε, and plug numbers,
- For algorithm questions: list input, output, steps, stopping condition, and discuss success/failure conditions.
Quick check
- What is the global sensitivity of a function that returns the number of triangles in a graph under edge-level privacy? (Give your reasoning.)
- State the inequality that defines ε-differential privacy.
- Why can k-anonymity fail to prevent attribute disclosure? Answers: (1) Δf equals the number of common neighbors of the endpoints of the differing edge; in the worst case a single edge is in up to (n−2) triangles, so Δf ≤ n−2 for a graph with n nodes. (2) Pr[M(D) ∈ S] ≤ e^{ε} · Pr[M(D') ∈ S]. (3) Because equivalence classes may be homogeneous or the adversary may have background knowledge that narrows sensitive values.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?