ENع
→Privacy
الدرس 21 · العمليات الأمنية

Privacy and compliance

لم يُترجم بعد؛ يُعرض باللغة الإنجليزية

14 دقيقة11 خطوة5 أسئلةAdvanced
عن هذا الدرس

Privacy is more than keeping data safe: it asks whether personal data should be collected and used at all, and only in the ways people expect. Follow one sign-up as an eight-line Python function keeps only the two fields analytics needs and swaps the email for a keyed HMAC tag, then watch the record get deleted on schedule, a later leak of the analytics table expose almost nothing, and the response that follows. Finish with the five functions of the NIST Privacy Framework and what compliance really means.

ستتعلّم

حدّد ما تشعر بأنك أتقنته. هذا التقييم الذاتي لا يؤثر في درجة الدرس.

شكل 21 · تفاعلي
01 / 11

Personal data

Personal data is information about a person who can be identified. NIST calls it PII: data that can identify someone alone, like an email, or combined, like a birth date plus a town. Lina signs up to a shop with five fields.

PII   information that can be used to distinguish
      or trace a person's identity (NIST, OMB A-130)
alone       name, email address
combined    birth date + country + plan ...

rec["name"]       "Lina"
rec["email"]      "lina@x.test"
rec["born"]       "1990-04-12"
rec["plan"]       "pro"
rec["country"]    "KW"
جارٍ تحميل الرسم…
أو ← →
اقرأ الدرس خطوة بخطوة
  1. Personal data

    Personal data is information about a person who can be identified. NIST calls it PII: data that can identify someone alone, like an email, or combined, like a birth date plus a town. Lina signs up to a shop with five fields.

    PII   information that can be used to distinguish
          or trace a person's identity (NIST, OMB A-130)
    alone       name, email address
    combined    birth date + country + plan ...
    
    rec["name"]       "Lina"
    rec["email"]      "lina@x.test"
    rec["born"]       "1990-04-12"
    rec["plan"]       "pro"
    rec["country"]    "KW"
  2. Privacy is not only security

    Security keeps data safe from attackers. Privacy asks more: should we collect this data at all, and do we use it only in ways the person expects? NIST notes that harm can come from processing that works exactly as designed.

    security   protect data: confidentiality, integrity,
               availability
    privacy    collect only what a purpose needs,
               use it the way people were told,
               keep it no longer than needed
    NIST PF    problems can arise even when systems
               work as intended (e.g. smart meters)
  3. Start from the purpose

    The analytics team only wants to count sign-ups per plan and country. So line 2 lists the fields that purpose needs: plan and country. Name, email and birth date are not needed. This is data minimisation.

    purpose     count sign-ups per plan and country
    KEEP = ("plan", "country")
    
    needed      plan, country
    not needed  name, email, born
    data minimisation   collect and keep only
                        what the purpose needs
  4. Copy only what is needed

    Line 4 builds a new dictionary from the KEEP fields only. Plan and country are copied across; name, email and birth date never are. Data that is never copied cannot leak from analytics, be misused there, or need deleting later.

    out = {f: rec[f] for f in KEEP}
    # a dict comprehension: one entry per field in KEEP
    
    >>> out
    {'plan': 'pro', 'country': 'KW'}
  5. Swap the email for a tag

    Analytics still needs to tell sign-ups apart. Lines 5 to 7 replace the email with a pseudonym: an HMAC, a hash mixed with a secret key from the vault. The same email always gives the same tag; without the key, nobody can recompute it.

    e = rec["email"].encode()       # text -> bytes
    h = hmac.new(key, e, "sha256")  # keyed hash
    out["uid"] = h.hexdigest()[:12]
    
    >>> out["uid"]          # key = b"vault-demo-key"
    '846845aeba59'
    pseudonym   still personal data (GDPR Recital 26)
                but useless without the key
  6. Analytics gets the small record

    Line 8 returns the small record and it is saved in analytics: plan, country and a tag. The analytics system never holds a name, an email address or a birth date, so there is far less to protect there.

    >>> for_stats(rec, key)
    {'plan': 'pro', 'country': 'KW', 'uid': '846845aeba59'}
    
    in analytics      plan, country, uid
    never in it       name, email, born
    stays separate    the key, in the vault
  7. Delete it when done

    Personal data should be kept only as long as its purpose needs. This shop's rule: when an account closes, a scheduled job deletes the sign-up record and logs that it did. Lina closes her account, and her record is erased.

    storage limitation   keep no longer than needed
    the shop's rule      account closed -> delete record
    how                  a scheduled job, not memory
    proof                log "record deleted" (no PII
                         in the log line itself)
    OWASP privacy risk   P6 Insufficient Deletion
                         of User Data
  8. Detect: a table walks out

    Months later, an alert fires: the analytics table is being copied out to the internet. This is the Detect part of incident response. The attacker gets plans, countries and tags, but no names, emails or birth dates.

    alert       large export from analytics
                to an unknown address
    taken       plan, country, uid
    not there   name, email, born (minimised)
    the tags    cannot be turned back into emails
                without the key in the vault
  9. Respond: contain, assess, notify

    Respond: stop the leak, then check your data map (your list of what data you hold, and where) to see whose data left. Is the vault key safe? Laws may require notice: the EU GDPR wants the regulator told within 72 hours where feasible.

    contain    block the export, reset the access used
    assess     data map: which fields, whose data
               key still safe? if not, rotate it
    notify     follow the plan and the law
               GDPR Art. 33: regulator, without undue
               delay, within 72 h where feasible
               (not needed if unlikely to put
                people at risk)
    CISA       include breach notification in
               the incident response plan
  10. Compliance: the Privacy Framework

    Compliance means showing you meet the rules that apply to you. NIST's Privacy Framework organises the work in five functions. Identify-P: map what data you hold and why. Govern-P: set policies, roles and legal duties. Control-P: manage data, like minimising and deleting it.

    NIST Privacy Framework 1.0 (2020-01-16)
      ID-P  Develop the organizational understanding to manage privacy risk for individuals arising from data processing.
      GV-P  Develop and implement the organizational governance structure to enable an ongoing understanding of the organization's risk management priorities that are informed by privacy risk.
      CT-P  Develop and implement appropriate activities to enable organizations or individuals to manage data with sufficient granularity to manage privacy risks.
  11. Communicate and protect

    Communicate-P: tell people in plain words how their data is used, and listen. Protect-P: safeguard the data, like the keyed tags and the separate vault. Passing an audit is not the goal; keeping people from harm is.

      CM-P  Develop and implement appropriate activities to enable organizations and individuals to have a reliable understanding and engage in a dialogue about how data are processed and associated privacy risks.
      PR-P  Develop and implement appropriate data processing safeguards.
    
    compliance   show the rules are met (records,
                 data map, policies, audits)
    privacy      the people behind the data
                 come to no harm

اختبار يتاح بعد الخطوة الأخيرة.