SSD Quiz Prep

SSD Quiz Prep

Everything from your four slide decks, cut down to what a 10-minute quiz can ask. Read, flip cards, then take the timed mock quiz.

0 – 30 minLearn: read the four courses, about 7 min each
30 – 42 minCards: flip until every card is "Got it"
42 – 52 minQuiz: 15 questions against a 10:00 clock
52 – 60 minReview your misses, reread the yellow boxes

Access control in databases

Deck: ESIR-SR-PM-V2_3 (Contrôle d'accès dans les bases de données)

Access control policy

A policy is a set of rules stating who may do what on which data, under which conditions. Every rule links a Subject, an Action and an Object, and is a permission, a prohibition (interdiction) or an obligation.

Rule typeAccess depends onCourse example
Content-independentNothing but the object itselfThe secretary manages every patient's Dossier_Admin
Content-dependentThe data inside the objectA doctor reads the files of his own patients
Context-dependentExecution context (time, place, emergency)Only during working hours; only from an internal machine; anyone in an emergency (checked afterwards)
Delegation / transferAdministration of the policyA doctor authorises the secretary to update a prescription

DAC: Discretionary Access Control

  • The creator of an object sets the policy on it.
  • Subjects receive permissions and can transfer some of them to others.
  • Decentralised: very flexible, hard to administer.
  • SQL's model is closed: only authorisations exist, anything not granted is denied.
GRANT <privileges> ON <table or view> TO <users> [WITH GRANT OPTION];
REVOKE [GRANT OPTION FOR] <privileges> ON <table or view> FROM <users> [RESTRICT | CASCADE];
  • Privileges: SELECT, INSERT, UPDATE, UPDATE(col), DELETE, plus admin ones (CREATE/ALTER/DROP, EXECUTE, REFERENCE, INDEX).
  • WITH GRANT OPTION: the receiver may pass the privilege on.
  • GRANT OPTION FOR: revoke only the right to transfer, not the privilege.
  • A gave p to B, B gave p to C, A revokes from B. CASCADE: C loses p too. RESTRICT: the revocation fails.

Views for confidentiality

A view is a stored SQL query: the DBMS keeps the definition, not the result, and rewrites queries on views into queries on base tables. Grant rights on the view instead of the table to expose only some rows or columns.

CREATE VIEW dossier_patient_du_medecin AS
  SELECT * FROM dossier_patient
  WHERE medecin_traitant = CURRENT_USER;        -- content-dependent
GRANT SELECT ON dossier_patient_du_medecin TO Jean, Jeanne;

... WHERE TO_CHAR(SYSDATE,'HH') BETWEEN '08' AND '18'            -- context: time
... WHERE sys_context('USERENV','IP_ADDRESS') IN ('T1','T2')    -- context: terminal

High expressive power, but the definitions become complex.

RBAC: Role-Based Access Control

  • Role = set of privileges. Users get roles, roles get permissions. Goal: easier administration.
  • Roles arrived in SQL3: CREATE ROLE, DROP ROLE, SET ROLE (activate roles for the session).
  • GRANT privs ON t TO role, GRANT role TO user, and GRANT role1 TO role2: role2 receives all privileges of role1.
  • Hierarchies: specialisation (Cardiologue is a Spécialiste is a Médecin) or organisational (director above head of service). The most specialised or senior role accumulates the most privileges.
LevelContains
RBAC0Core: user-role assignment (URA) + permission-role assignment (PRA)
RBAC1RBAC0 + role hierarchies
RBAC2RBAC0 + constraints
RBAC3Hierarchies + constraints

Limits and synthesis

  • A program run by a user inherits that user's rights (DAC) or the session's active roles (RBAC). A Trojan horse (visible function + hidden function) can therefore leak data.
  • DAC structures objects, RBAC structures subjects, MAC fights malicious programs but leaves little flexibility.
  • All of it assumes the user comes "through the front door". SQL injection does not.
Know cold: CASCADE vs RESTRICT, what WITH GRANT OPTION does, the three rule types with one example each, RBAC0 to RBAC3, "DAC = objects, RBAC = subjects, MAC = Trojans".

Web vulnerabilities

Deck: 21-01-11-esir3-ssd-webvulns (Introduction to Web Vulnerabilities)

Background

  • HTTP is stateless (the server application manages sessions) and textual (requests can be modified).
  • Sessions use cookies: the client stores an identifier, the server stores the session data and finds it again from the cookie sent back.
  • OWASP publishes the Top 10 web security flaws (2017 edition in the course).
  • Threats: bypass authentication, run server-side code (PHP), run client-side code (JavaScript), reach sensitive data.
  • French penal code: 323-1 fraudulent access, 2 years and 60 000 €; 323-2 hindering a system, 5 years and 150 000 €; 323-3 introducing, extracting or modifying data, 5 years and 150 000 €.

SQL injection: authentication bypass

Goal: make the WHERE clause always true so the query returns rows. [cond] OR True is always true; [cond] AND False is always false.

SELECT * FROM Users WHERE username="$Username" AND password="$Password";

$Password ← " OR "a"="a          → ... AND password="" OR "a"="a";
$Password ← " OR True;-- -       → ... AND password="" OR True;-- -";   (rest is commented out)

SQL injection: arbitrary SELECT with UNION

Two steps: empty the first query with AND False, then inject yours with UNION. UNION needs the same number, type and order of columns.

SELECT username FROM Users WHERE id=$userid;
$userid ← 0 AND False UNION SELECT attributes FROM Tab

Mitigation: never trust the user; sanitize inputs (escape special characters); use parameterized queries (PHP PDO prepare then execute). Attack surface: GET and POST parameters and HTTP headers, cookies included.

File upload injection

  • The attacker uploads a PHP script through the form, then requests it: the server executes it.
  • Checking the declared file type is not enough: it is part of the POST request and can be edited with a proxy.
  • Mitigation: allow only the necessary types, check the file thoroughly (not just extension or MIME type), use magic numbers (file signatures).

Cross-Site Scripting (XSS)

  • User-submitted data (a forum message) is embedded in a page that other users view. A <script> in the message runs in the victims' browsers.
  • With document.cookie and XMLHttpRequest the script can send the victim's cookies away: session theft.
  • Mitigation: sanitize inputs before displaying them, set a Content Security Policy (CSP).
  • Real case: the Samy worm on MySpace.

Broken authentication

  • Passwords are the most used factor and the weakest: common ones (123456789, password, qwerty), 86% already leaked in other breaches.
  • Credential stuffing: replaying credentials leaked from another site. Also brute force, dictionary, phishing. Example: TV5 Monde's password visible on air.
  • Mitigation: multi-factor authentication, password policy with a blacklist, limit attempts and warn the user, teach safe habits (password manager).

Sensitive data exposure: storing passwords

  • Store only hashes. At login, hash the input and compare with the stored hash.
  • Dictionary attack: precompute hashes of common passwords and look a leaked hash up.
  • Mitigation: a unique salt per user, hashed together with the password (hash(salt + password)), so a precomputed dictionary is useless and identical passwords give different hashes.
Know cold: be able to write the two injection payloads, the UNION column constraint, where XSS code runs (the victim's browser, unlike SQL injection or file upload which hit the server), and one mitigation per flaw.

Differential privacy

Deck: ESIR3-SI-SSD-CM-3_DiffPriv (Differential Privacy in a Nutshell)

The problem: privacy-preserving data publishing (PPDP)

  • Publish personal data so that aggregate queries stay accurate while point queries about one person stay uncertain. Also called sanitization.
  • GDPR protects personal data: any information on an identified or identifiable person, directly or indirectly (Art. 4). It does not apply to data "made anonymous" (Recital 26), a notion left fuzzy.
  • Pseudonymized data is still personal data under GDPR.

Why pseudonymity fails

  • Pseudonymity: replace identifying data by a pseudonym independent of it (random number, hash).
  • Governor Weld (Sweeney): the "anonymous" GIC health data was joined with the Cambridge voter list (bought for 20 $) on {zip code, birth date, sex}. Most of the US population is unique on those three.
  • AOL 2006: 20 million search queries from 658 000 pseudonymous users; user 4417749 was identified as Thelma Arnold from her queries.
  • Access control and cryptography would not have helped: the data was meant to be released.

A PPDP solution has three components: a privacy model (what "private" means), a privacy mechanism (how to produce the release), a utility metric (how useful it is). Pseudonymity is only a mechanism: it has no privacy model behind it.

Settings: interactive (answer queries) vs non-interactive (release a sanitized dataset); centralized publishing (a trusted publisher sees raw data) vs local perturbation (each individual perturbs their own data before sending).

k-anonymity and l-diversity

  • k-anonymous release: no identifying attribute, and every quasi-identifier (QI) combination is indistinguishable from at least k−1 others. A group sharing the same QI is an equivalence class. Obtained by generalizing the QI (zip and age become ranges).
  • Weaknesses: homogeneity (everyone in the class has the same disease) and background knowledge.
  • l-diversity: each equivalence class holds at least l well-represented sensitive values (l distinct values, or entropy ≥ log l, or recursive (c,l)-diversity). Handles homogeneity and negation-type background knowledge only.
  • Paradigm 1, the uninformative principle: a breach occurs when the adversary's posterior belief differs significantly from the prior.

Differential privacy (DP)

Paradigm 2: global trends are not private and must be learnt. Privacy concerns each individual's contribution. A function is DP if the impact of any single individual on its output is limited.

Pr[ f(D) = S ] ≤ eε × Pr[ f(D′) = S ]
  • For all datasets D, D′ that are neighbours (differ in at most one record) and any output S. f is a random function.
  • ε is the privacy parameter. It is public. Common values: 0.01, 0.1, ln 2, ln 3. Smaller ε = more privacy = more noise.
  • If one side is zero the other must be zero too.

Sensitivity and the Laplace mechanism

  • Sensitivity Sg: worst-case impact of one individual on query g. Sg = max over neighbours of ‖g(D) − g(D′)‖1.
  • COUNT: 1. SUM: max(|domainmin|, |domainmax|).
  • Laplace mechanism (real-valued interactive queries): add noise drawn from Laplace with mean 0 and scale b = Sg / ε. Density: e−|x|/b / 2b.
  • Example: COUNT with ε = 0.1 gives scale 1/0.1 = 10. SUM of ages in [0, 100] with ε = 0.5 gives 100/0.5 = 200.

Randomized response (local perturbation)

Each person holds a bit x. With probability Prflip they answer 0 or 1 uniformly at random; otherwise they answer truthfully.

Prflip = 2 / (1 + eε)

Example: ε = ln 3 gives Prflip = 2/4 = 0.5.

Properties and limits

  • Composability: combining DP releases is still DP. εfinal = Σ εi if the inputs are not disjoint, max εi if they are disjoint.
  • Post-processing: a function applied to a DP output gives a DP output, as long as it does not touch the raw data again.
  • Noise is centred on 0, so averaging many answers cancels it: no unlimited number of queries. ε is a budget to split across queries.
  • DP is the de facto standard thanks to sound guarantees and composability.
Know cold: the DP inequality and what "neighbouring" means, scale = Sg/ε, sensitivity of COUNT and SUM, sum-vs-max composition, Prflip, and which attack breaks k-anonymity (homogeneity).

Browser fingerprinting

Deck: ESIR3-SI-SSD-CM-4 BFP (Browser Fingerprinting)

Web tracking with cookies

  • HTTP is stateless, so cookies carry state: text set by the server, stored by the browser, sent back on each request.
  • Cookies follow the Same-Origin Policy, but third-party content embedded on many sites can track a user across them with an ID cookie.
  • Evercookies: the ID is stored in several places (standard cookies, Flash cookies, web history, cache). If one copy is deleted it is restored from another.

What a fingerprint is

The set of attributes a browser exposes, combined to recognise it without storing anything on the device. Two properties matter: distinctiveness and stability.

PassiveActive
SourceHTTP headersScripts (JavaScript, Flash, Java)
Detectable?NoYes
AttributesFewer, yet already identifyingMany more, more diverse
  • Attribute kinds: single strings (User-Agent, Accept-Language); lists (plugins, where the order also distinguishes); probing for things not directly readable (render text in a font and measure the box; detect extensions); canvas rendering.
  • A lack of response is still a response: undefined, empty string, or the error message itself.

Use cases

In the crowd (identify one device)Of the type (identify properties)
ConstructiveAuthentication, blocking account sharingAnomaly and intrusion detection, bot detection, user advising
IntrusiveWeb trackingTargeted attacks, price discrimination, limiting access to a service

Studies and numbers

StudyAttributesFingerprintsUnique
Mayer, 200941 32896.23%
Eckersley, 2010 (Panopticlick)8470 16183.6%
Hiding in the Crowd, 2018172 million, 6 months, top-15 French site33.6% (35.7% desktop, 18.5% mobile)
Guess Who?, 2020216Same population81.8%; over 90% of attributes identical after 170 days
  • Anonymity set: group of fingerprints identical on all collected attributes. Mobiles hide better: about 59% sit in sets larger than 50, against about 8% of desktops.
  • Shannon entropy measures how identifying an attribute is: H(X) = −Σ Pr(xi) log2 Pr(xi). Normalized entropy = H(X) / log2(N), N being the number of fingerprints.
  • Most discriminating: plugins list and fonts on desktops; the User-Agent on mobiles (it carries phone model and firmware). Plugins are nearly useless on mobile. Yes/no attributes (ad blocker, local storage) have very low entropy.
  • Fingerprints change over time (updates, user choices), and one change can make a fingerprint more unique.
  • It is used in the wild (2021 study: 982 volunteers, 419 824 JavaScript files). Standards and browsers react: W3C privacy questionnaire, Firefox canvas warning, Battery API removed, Flash ended.

Countermeasures

  • Detect fingerprinting.
  • Modify the fingerprint: simple attribute spoofing; randomization (1→N), one browser shows many fingerprints; standardization (N→1), many browsers show the same one.
  • Block the transfer: black lists, script blocking.
Know cold: passive vs active, distinctiveness and stability, the 2×2 use-case table, 33.6% with 17 attributes vs 81.8% with 216, entropy as the measure, randomization vs standardization.

Space flips the card. "Again" sends it to the back of the deck; "Got it" removes it.