Slide 1

Slide 1 text

Privacy on Rails Pragmatically complying to data protection laws

Slide 2

Slide 2 text

Talysson Oliveira Software architect & Chief Learning Officer at Codeminer42 @talyssonoc beacons.ai/talyssonoc

Slide 3

Slide 3 text

codeminer42.com ai.codeminer42.com @codeminer42

Slide 4

Slide 4 text

⚠ I'm not a lawyer This is an engineering perspective talk

Slide 5

Slide 5 text

On calm and peaceful day…

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Would you know what to do?

Slide 8

Slide 8 text

Or would you freak out thinking… - What tables store user private information? - Are we able to remove them from the logs too? - Oh no, what about ActiveJob payloads? - How much time do we have to respond to that email?! - Are we breaking any law? Are we going to be fined?

Slide 9

Slide 9 text

What are data protection laws?

Slide 10

Slide 10 text

Data protection laws - Exist to enforce data protection and user privacy - Present in more than 140 countries - Most don't apply only if you are based in the country, but also if you have users there - They are about consent, data minimization, access rights, breach notification, and purpose limitation

Slide 11

Slide 11 text

What private data are we talking about?

Slide 12

Slide 12 text

Name Email Phone Government ID Date of birth Race Religion Prescriptions Tax records IP address Browsing history Chat messages Salary Behavior profile AI generated predictions Gender identity Location history

Slide 13

Slide 13 text

Name Email Phone Government ID Date of birth Race Religion Prescriptions Tax records IP address Browsing history Chat messages Salary Behavior profile AI generated predictions Gender identity Location history AND MORE!

Slide 14

Slide 14 text

Thinking about it made you sweat? Then this talk's for you

Slide 15

Slide 15 text

Privacy used to be a competitive advantage Now, it's the baseline for a product

Slide 16

Slide 16 text

Why do companies fail to comply?

Slide 17

Slide 17 text

They treat privacy as just a legal concern They put innovation above user privacy

Slide 18

Slide 18 text

Privacy by design Privacy as an engineering quality attribute

Slide 19

Slide 19 text

Privacy by design - Don't implement privacy as an afterthought - Implement it as any other normal engineering constraint - Like we do for security, for performance, for responsiveness - Think about your user's privacy first - Don't gamble with user data to pay for innovation - Start with a set of principles

Slide 20

Slide 20 text

Privacy by design principles 1. Data minimization - Don't collect what you can't protect (or don't need) - Less data = less to concern about 2. Private by default - Every data exposure requires an explicit reason - Data must be protected with appropriate technical measures 3. Transparency - Users should know and control what you store from them

Slide 21

Slide 21 text

Privacy on Rails "I'm not a lawyer either, show me the code!"

Slide 22

Slide 22 text

Data minimization Less data = less to concern about

Slide 23

Slide 23 text

Minimize data that enters your app

Slide 24

Slide 24 text

Use strong parameters - Create an explicitly permitted list of parameters - Be intentional about what you permit - Filtering at the entry point covers the whole application

Slide 25

Slide 25 text

Anonymize user's IPs - Doing it at the entry point covers the whole application - If geocoding is important for your app, it'll still work - Use the ip_anonymizer gem

Slide 26

Slide 26 text

Minimize data that leaves your app

Slide 27

Slide 27 text

Explicit serialization - Create an explicitly permitted list of what data will be exposed

Slide 28

Slide 28 text

Safeguard error tracking strategies - Error tracking services capture full request context (PII, params, …) - Filter request params and use the logstop gem

Slide 29

Slide 29 text

Anonymize analytics data - Innovation should not be at the expense of your user's privacy - Use a privacy-first analytics service + consent-gated scripts - Anonymize any personal information sent do analytics - We'll see consent modeling and anonymization techniques soon

Slide 30

Slide 30 text

No personal data in emails - Data can leak in email logs and bounced email handling - Enforce minimal PII in emails and filter email logs - Use signed URLs with auto-expiry and authenticated downloads

Slide 31

Slide 31 text

Data retention and TTL policies

Slide 32

Slide 32 text

Implement data retention and TTL policies - Don't keep older unused data - Delete (or anonymize) inactive users - Delete inactive sessions - Clear SolidQueue completed job records - Make it automatic

Slide 33

Slide 33 text

Deleting/anonymizing inactive users

Slide 34

Slide 34 text

Private data by default Protected data without extra effort

Slide 35

Slide 35 text

Logs

Slide 36

Slide 36 text

Log with care - Logs are the #1 silent leak - Always check everything that is explicitly logged - Filter request params and use the logstop gem

Slide 37

Slide 37 text

Security

Slide 38

Slide 38 text

Encryption at rest for models Decrypt Search Use ✅ ✅ ✅ ❌ ❌ ❌ (just verify) - Rails supports three levels of data protection - Choose based on the field's usage pattern

Slide 39

Slide 39 text

Protect cookies properly - Be intentional about cookies usage - Define proper same_site policy

Slide 40

Slide 40 text

Make your backups secure - Always encrypt the database backups - Adopt a retention policy for backups as well

Slide 41

Slide 41 text

Protect direct console access in production - Track who, why and how console was accessed in production - Use console1984 and audits1984 gems for that

Slide 42

Slide 42 text

Transparency and data rights Users should know and control their data

Slide 43

Slide 43 text

Consent

Slide 44

Slide 44 text

Creating a consent model - It's not just about using a cookie banner - Marketing, analytics tracking, 3rd party sharing, features, … - Each consent should be per-purpose, versioned and with proof - Consents should be explicit - No user consent = no action

Slide 45

Slide 45 text

Creating a consent model

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Data subject access rights

Slide 48

Slide 48 text

Data subject access rights - Users have access, rectification and erasure rights over their data - LGPD requires a response in 15 days to respond - GDPR requires a response in 30 days (extendable until 90 days) - Make it as automatic as possible

Slide 49

Slide 49 text

Creating a data subject request model

Slide 50

Slide 50 text

Implementing access request (aka DSAR) handling

Slide 51

Slide 51 text

Implementing access request (aka DSAR) handling

Slide 52

Slide 52 text

Implementing erasure request handling

Slide 53

Slide 53 text

Implementing anonymization

Slide 54

Slide 54 text

Implementing anonymization

Slide 55

Slide 55 text

Ok, this is a lot of things to remember

Slide 56

Slide 56 text

And we are in the age of AI…

Slide 57

Slide 57 text

Automate it with agent skills!

Slide 58

Slide 58 text

Privacy by design Rails agent skills, by Codeminer42 - Bring privacy-by-design into your Rails workflow - Two modes: - Complete codebase assessment - Review your recent changes - Generates a thorough report + offer fixes - Fully open source and ship with Ruby scripts for easy auditing

Slide 59

Slide 59 text

Privacy by design Rails agent skills, by Codeminer42 or https://github.com/codeminer42/skills

Slide 60

Slide 60 text

Privacy by design Rails agent skills, by Codeminer42

Slide 61

Slide 61 text

Privacy by design Rails agent skills, by Codeminer42

Slide 62

Slide 62 text

Privacy by design Rails agent skills, by Codeminer42

Slide 63

Slide 63 text

Privacy by design Rails agent skills, by Codeminer42

Slide 64

Slide 64 text

Data privacy laws don't kill innovation Not complying is a skill issue Respect your users privacy Rails is privacy friendly

Slide 65

Slide 65 text

Thank you! @talyssonoc beacons.ai/talyssonoc codeminer42.com ai.codeminer42.com @codeminer42