Slide 1

Slide 1 text

Ronald Bradford Principal Database Reliability Engineer MySQL Data Security Risk Assessment June 2018 Database+Operations Conference Barcelona, Spain 21-22 June 2018 https://dataops.barcelona/

Slide 2

Slide 2 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Table of contents 2 MySQL Data Security Risk Assessment 1 Why? 2 How? 3 Recommendations 4 Implementation Challenge 5 Ongoing Risk

Slide 3

Slide 3 text

About Okta/Speaker

Slide 4

Slide 4 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential About speaker – Ronald Bradford 5 • Principal Database Reliability Engineer (DBRE) at Okta • 29 years of RDBMS experience • 19 years of MySQL experience • Speaker http://ronaldbradford.com/presentations/ • Author http://effectivemysql.com/

Slide 5

Slide 5 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential About Okta 6 • Leading provider of identity for the enterprise • Connects and protects employees of many of the world’s largest enterprises • Securely connects enterprises to their partners, suppliers and customers • Okta helps customers fulfill their missions faster by making it safe and easy to use the technologies they need to do their most significant work

Slide 6

Slide 6 text

Why?

Slide 7

Slide 7 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Why data security risk assessment is important? 8 • Humans seek convenience over complexity • Humans prey on other humans • Humans are better at recognition than programmed solutions

Slide 8

Slide 8 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Reference example (3 years) 9 • Are any of your password 3 years old? • Have any employees left in the past 3 years? • Were any password stored in clear-text?

Slide 9

Slide 9 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential What is happening now on your database? 10 • Hard failures • Invalid access to any data-store (e.g. Invalid password) • How frequent/often? • Soft attacks • SELECT email from customers;

Slide 10

Slide 10 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Open source failures 11 • Generational bad habits (e.g. defaults) • No default administrator password • No password strength • Open ports • Poor ACLs examples • Continued bad habits • NoSQL products • Docker

Slide 11

Slide 11 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential IRL comparison 12 • Physical Security • Badge+Photo+Scan+Security Guard • Pinpad+Timed Access • Metal Detectors • Secondary Scan • Monitoring • Security Cameras+Recording+Image Recognition • Human Intelligence • Random Security Guard Checks • Peers

Slide 12

Slide 12 text

How?

Slide 13

Slide 13 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Password-less authentication 14 • First Access • Computer Login (Password) • VPN (Password+Token/MFA) • Company Systems (Password+MFA/Token) • Other (Firewall, bastion, ssh) • Then • $ ssh • $ mysql -e "ANY COMMAND I LIKE”

Slide 14

Slide 14 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential No MySQL password necessary (sudo) 15 • OS ‘root’ access • $ ssh dba@server • $ sudo su – • Compromises • $ service mysql restart --skip-grant-tables • $ strings /var/lib/mysql/mysql/user.MYD • mysql> create user demo@localhost identified by 'SomeLongP155wd#'; • strings /ebs/var/lib/mysql/mysql/user.MYD | grep demo • demo*294B43D3206B0B0A1670A2E606F1D5B9655906B7

Slide 15

Slide 15 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Password use 16 • Lack of strength • Lack of rotation • Clear-text • my.cnf • master.info • Third party tools • /etc/percona-toolkit/percona-toolkit.conf • Process space • Command line • Weaker encryption methods (e.g. SHA1 v SHA256+SALT)

Slide 16

Slide 16 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential MySQL privileges 17 • The GRANT ALL problem (i.e. SUPER, ALTER and everything else) • The *.* problem (i.e. not schema.table) • The % or 10.% problem (i.e. not host but network) • The DEFINER / INVOKER stored function problem • The mysql.user problem • The read-only problem

Slide 17

Slide 17 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential NoSQL and no security 18 • MongoDB • Cassandra • Redis • Elasticsearch • https://www.slideshare.net/wurbanski/nosql-no-security https://speakerdeck.com/xeraa/nosql-means-no-security

Slide 18

Slide 18 text

Recommendations

Slide 19

Slide 19 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Practical policies and actions 20 1. Purpose driven credentials (*) 2. Least privileged model (*) 3. Segregation of responsibility 4. Environment boundaries (*) 5. No clear-text passwords (*) 6. Longer & stronger passwords 7. Password rotation 8. Sha256 password with salt (*) 9. Remove snowflakes 10. Timeouts 11. Timed access 12. Logging (*) 13. Auditing (*) 14. Human Factor Authentication (HFA) (*) 15. Release cadence (*)

Slide 20

Slide 20 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Accounts with a purpose (1) 21 • Individually Named Accounts • By name • johnsmith • dba_jsmith • By Purpose • zabbix • splunk • pt • collectd • xtrabackup

Slide 21

Slide 21 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Know your privileges (2) 22 • If an account requires SUPER, why? • Evaluate and reevaluate regularly (e.g. each quarter) • e.g. Percona Toolkit • GRANT ALL PRIVILEGES ON *.* to percona@localhost; • You can alter a table with? • pt-heartbeat requires • GRANT REPLICATION CLIENT ON *.* TO percona@localhost • GRANT INSERT, DELETE ON heartbeat.heartbeat TO percona@localhost • pt-slave-delay requires • GRANT SUPER ON *.* TO percona@localhost; • Replaceable with native MySQL 5.6 delayed replication

Slide 22

Slide 22 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Always separate environments (4) 24 • Is an password shared • Across test/stage/prod • Do you have tools to validate passwords across environments? • It’s just a test environment is not an excuse

Slide 23

Slide 23 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Removing clear-text passwords (5) 25 • .my.cnf • Clear-text • Can have any OS permissions • Can reside in any directory • Any MySQL version • .mylogin.cnf • Not clear-text • Restricted file privileges • Locked to a specific OS user • MySQL 5.6+

Slide 24

Slide 24 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential A stronger password plugin (8) 26 • mysql_native_password • SHA1(SHA1()) (20 bytes) • sha256_password plugin (5.6) • sha256 (32 bytes) • + salt • caching_sha2_password (5.7) https://mysqlserverteam.com/protecting-mysql-passwords-with-the-sha256_password-plugin/ https://dev.mysql.com/doc/refman/5.7/en/sha256-pluggable-authentication.html

Slide 25

Slide 25 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Logging (12) / Auditing (13) 28 • Limiting accounts to exact SQL (i.e. Whitelisting) • Allowed • SHOW PROCESSLIST • SHOW SLAVE STATUS • SHOW MASTER STATUS • SHOW ENGINE INNODB STATUS • Allowed via SUPER • KILL • Not Allowed via SUPER • SET GLOBAL

Slide 26

Slide 26 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Human Factor Authentication (HFA) (14) 29 • Requiring a human (or second human) • Very destructive operations • CHANGE MASTER TO • ALTER TABLE DROP PARTITION

Slide 27

Slide 27 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Software releases (15) 30 • New releases provide new functionality • Who is running MySQL 5.0? • Who is running MySQL 5.5? • sha256_password (5.6) • mysql_config_editor (5.6) • SUPER granularity (8.0)

Slide 28

Slide 28 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential New available functionality (15) 31 • Stronger encryption plugins • mysql_config_editor • Password Expiry • Password strength check • Root default password • Mysql client logging removed • Start Slave password • Default SSL connections • Active/Inactive user accounts • Roles • Super granularity • Password history

Slide 29

Slide 29 text

Implementation Challenges

Slide 30

Slide 30 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Convergence is really hard 33 • CREATE USER • user @ host • DROP USER • GRANT privilege • REVOKE privilege • Individual accounts • Environment accounts • Organization accounts

Slide 31

Slide 31 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Changing passwords 34 • Single server – Simple • Complex topology – Hard • To replicate or not to replicate • Configuration management v replication • Are your replicas in read only mode? • Disabled configuration management • Lag slaves

Slide 32

Slide 32 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Example Topologies 35

Slide 33

Slide 33 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential User convergence 36 • User account with multiple @hosts • Different grants per @host • User only on some servers • DROP USER [IF EXISTS] - MySQL 5.7

Slide 34

Slide 34 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential GRANT convergence example 37 • Monitor user (runs something every second) • Has • GRANT SELECT, PROCESS, SHOW DATABASES, SUPER, REPLICATION CLIENT ON *.* • GRANT SELECT, INSERT, UPDATE ON schema1.* • GRANT CREATE, INSERT ON mysql.* • Should have • GRANT PROCESS, REPLICATION CLIENT ON *.*

Slide 35

Slide 35 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Revoking privileges 38 • REVOKE ALL works on a subset, but only per schema • GRANT SELECT ON *.* • REVOKE ALL ON *.* • There is no REVOKE [IF EXISTS] • REVOKE ALL ON *.* does not fail when re-executed • REVOKE ALL ON schema.* does • A user always has the USAGE privilege (can never have no schemas) • REVOKE, GRANT are atomic statements • i.e. the time in-between • All or nothing does not apply (i.e. both work or both fail)

Slide 36

Slide 36 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Tools 39 • External CMDB for users/grants • Yet another language or metadata • Is pt-show-grants a CMDB option? • Password hash’s not clear-text • But unknown • GRANT not CREATE USER

Slide 37

Slide 37 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Guidelines 40 • Center for Information Security • National Vulnerability Database • Common Vulnerabilities and Exposures (CVE) • FedRAMP • PCI • Other compliance bodies https://www.cisecurity.org/benchmark/oracle_mysql/

Slide 38

Slide 38 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential A stronger model example 41 • AWS RDS (not allowing SUPER) • mysql> CALL mysql.rds_skip_repl_error; • mysql> CALL mysql.rds_kill(thread-id); https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.MySQL.CommonDBATasks.html

Slide 39

Slide 39 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential MySQL wish list 42 • A user should be able to have a comment • Similar to CREATE TABLE • Be able to active/inactive an account - MySQL 5.7 • Be able to expire a password – MySQL 5.7 • SUPER granularity – MySQL 8.0 • SQL whitelist • SQL blacklist • REVOKE [ANY] PRIVILEGE

Slide 40

Slide 40 text

Conclusions

Slide 41

Slide 41 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential Data security not discussed 46 • Many other issues to consider in security scope • Encryption • Secure communication, e.g. SSL/ipsec • Backups • Log Files • Data integrity (read_only, sql_mode)

Slide 42

Slide 42 text

© Okta and/or its affiliates. All rights reserved. Okta Confidential What can you do? 47 • Data security is not convenient • Data security is not easy • Data security is not a one off task • Be an advocate at your company

Slide 43

Slide 43 text

Thank You

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content