SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
www.fromdual.com
1 / 39
MySQL sicher
aufsetzen und betreiben
SLAC 2015, Berlin
Oli Sennhauser
Senior MySQL Consultant, FromDual GmbH
oli.sennhauser@fromdual.com
www.fromdual.com
2 / 39
FromDual GmbH
Support
remote-DBA
Schulung
Beratung
www.fromdual.com
3 / 39
Inhalt
MySQL sicher aufsetzen und betreiben
➢
Vorbereitungen
➢
Installation
➢
Härten
➢
Upgrade
➢
Konfiguration
➢
User Management
➢
Verschlüsselung
➢
Backup / Restore
➢
Hochverfügbarkeit
➢
Monitoring
➢
Wo lauert das Böse?
➢
Angriffsvektoren
www.fromdual.com
4 / 39
Vorbereitung Installation
● Welches O/S, welche Distro?
● Windows kann heute auch sicher sein...
● Was könnt Ihr am besten?
● Welcher Branch/Fork?
● MySQL, MariaDB, Percona, Galera
● Packet, Binary Tarball, oder Source
● DEB/RPM von Distribution oder Hersteller
● Distribution oft veraltet
● und wie gut gepatched?
● und wenn gepachted, wie gut getestet?
● Version
● MySQL: 5.5, 5.6, (5.7), MariaDB 5.5, 10.0, (10.1)
www.fromdual.com
5 / 39
Installation
● Durch wen?
● Pakete
● selber (mysql_install_db)
● Wohin?
● /var/lib/mysql
● /mount/mysql/data
● Advanced Security macht ärger!
● AppArmor
● SElinux
● weitere potentielle Problemchen
● /etc/mysql/conf.d/debian.cnf (root äquivalent)
● Syslog auf Debian/Ubuntu: die Log-Informationen sind auf nimmer
wiedersehen weg, nicht theoretisch sonder praktisch!
www.fromdual.com
6 / 39
Was passiert bei Installation?
● InnoDB Tablespace und Log Files
● MySQL Data Dictionary (mysql Schema)
● Kreiert User (root, anonymous)
● Kreiert test Schema
slac1
● Was ist das Problem?
● Härtet jemand von Euch nach Installation?
www.fromdual.com
7 / 39
Härten von MySQL
● Wie:
● mysql_secure_installation
● leider „kaputt“
● Was:
● root Passwort
● root von remote
● test Schema
● anonymous User (''@localhost)
slac1
www.fromdual.com
8 / 39
Warum härten?
● Root Passwort setzen ist klar?
● Nein mir nicht!
● Wenn niemand lokal zugriff hat ausser root braucht es dort auch
kein Passwort.
● Root von remote ist klar?
● Sogar mir!
● Warum ist der anonymous User (''@server) böse?
slac2
● Warum ist das test Schema böse?
● Insbesondere Hoster/SaaS und Ähnliche aufpassen!!!
www.fromdual.com
9 / 39
Neues Mätzchen mit 5.6
● Seit MySQL 5.6 gilt:
● Passwort auf Kommandozeile ist böse, warum?
● Kann mir jemand sagen warum?
slac2
● Früher ~/.my.cnf (chmod 0600)
● Scheint heute immer noch sicher!
shell> mysql --user=sicher --password=secret
Warning: Using a password on the command line
Interface can be insecure.
www.fromdual.com
10 / 39
Heute: MySQL Config Editor
● Seit MySQL 5.6 gilt:
● Wieso geht das jetzt???
slac2
● Fortsetzung folgt...
shell> mysql_config_editor set
-–login-path=slac2
--host=localhost --user=sicher –-password
shell> mysql --login-path=slac2
www.fromdual.com
11 / 39
Und wie cracken?
● Security by Obscurity???
● Sicherheitsgewinn?
● Und jetzt wie cracken? :-)
The encryption used by mysql_config_editor prevents passwords from
appearing in .mylogin.cnf as cleartext and provides a measure of
security by preventing inadvertent password exposure. For example,
if you display a regular unencrypted my.cnf option file on the screen, any
passwords it contains are visible for anyone to see. With .mylogin.cnf, that
is not true.
But the encryption used will not deter a determined attacker and you
should not consider it unbreakable. A user who can gain system
administration privileges on your machine to access your files could
decrypt the .mylogin.cnf file with some effort.
www.fromdual.com
12 / 39
Weitere Sicherheitsfeatures
● MySQL CLI: Filter auf password in History
● OK. Seh ich ja ein, ist aber mühsam:
● grep password ~/.mysql_history
● Installation in 5.7 automatisch sicher
● Kein test Schema mehr
● Kein anonymous User mehr
● Kein root von Remote mehr
● UND: root@localhost hat default Passwort,
welches geändert werden muss...
www.fromdual.com
13 / 39
Upgrade / Release Cycles?
● Major Releases:
● MySQL 5.1, 5.5, 5.6, 5.7 (ca. alle 2 Jahre)
● MariaDB 5.1, 5.2, 5.3, 5.5, 10.0, 10.1 (ca. alle 18 Monate)
● Minor Releases:
● 5.6.x
● MySQL ca. 6 pro Jahr (also alle 2 Monate)
● MariaDB ca. 6 pro Jahr (also alle 2 Monate)
● Und jetzt, alle 2 Monate ein Upgrade?
● Ja, warum nicht?
● Wir haben Testautomation und
● automatisierte Deployments (siehe andere Vorträge...)
www.fromdual.com
14 / 39
Upgrade in der Praxis
● Oracle liefert Critical Patch Updates (CPU)
● (4 pro Quartal, alle 3 Monate)
● Distributionen ähnliche Zyklen?
● ziehen die wirklich alles nach?
● Ubuntu Security Notes (USN): alle 3 Monate
● RHEL/CentOS?
● potentielle Probleme:
● Wer testet wie gut (Distribution / Betreiber)?
● Upgrade erfolgt automatisch
● Restart der DB-Instanz (Red Hat/CentOS)
● http://fromdual.com/security
www.fromdual.com
15 / 39
Upgrade wie tun:
● Major Release NICHT überspringen!
● daher mindestens alle 2 Jahre ein upgrade
● Offizielle Methode:
● Dump/Restore (aber wie mit meinen 5 Tbyte?)
● Geht meist auch:
● Binary Upgrade
● ab 5.7 offiziell supportet!!!
● Anschliessend NICHT vergessen:
● mysql_upgrade
slac3
www.fromdual.com
16 / 39
Warum kein Upgrade böse?
● Darum: slac4
● Oracle hat Security relevante Bugs heute
versteckt...
● Aber, der Findige lässt sich nicht unterkriegen:
https://bugzilla.redhat.com/show_bug.cgi?id=919247
● Ich habe keine 15 Minuten gebraucht...
ERROR 2013 (HY000): Lost connection to MySQL server
during query
www.fromdual.com
17 / 39
MySQL Crash
● Crash ist IMMER böse = IMMER ein Bug
150620 14:59:27 [ERROR] mysqld got signal 11 ;
This could be because you hit a bug...
Thread pointer: 0x47e10e0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x7f8949817ea8 thread_stack 0x48000
mysqld(my_print_stacktrace+0x2e) [0x9c493e]
mysqld(handle_segfault+0x3b3) [0x611eb3]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10340) [0x7f8948a70340]
mysqld() [0x75aaf0]
mysqld(Geometry::append_points(String*, unsigned int, char const*, unsigned int) const+0x4e)
mysqld(Gis_polygon::get_data_as_wkt(String*, char const**) const+0xbb) [0x75c68b]
mysqld(Item_func_as_wkt::val_str(String*)+0x145) [0x5d6f55]
...
mysqld(mysql_execute_command(THD*)+0x2d4e) [0x62066e]
mysqld(mysql_parse(THD*, char*, unsigned int, char const**)+0x299) [0x623ff9]
mysqld(dispatch_command(enum_server_command, THD*, char*, unsigned int)+0xb9b) [0x624b9b]
mysqld(do_command(THD*)+0x101) [0x6255b1]
mysqld(handle_one_connection+0xdf) [0x61690f]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x8182) [0x7f8948a68182]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f8947f8347d]
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7f88cc004b98): select astext(0x0100000000030000000100000000000010)
Connection ID (thread ID): 1
Status: NOT_KILLED
www.fromdual.com
18 / 39
Jeder hat seine Leidenschaft
● Es gibt Leute, die sammeln Briefmarken...
● Andere sammeln so was:
#
# Bug #68591: Geometry query crashes mysqld
# http://bugs.mysql.com/bug.php?id=68591
# https://mariadb.atlassian.net/browse/MDEV­4252
# https://bugzilla.redhat.com/show_bug.cgi?id=919247
#
# Fixed in: MySQL 5.6.12, 5.5.32, 5.1.70
#           MariaDB 5.5.30, 5.3.13, 5.2.15, 5.1.73
# Happens in: before
# Does not happen in: ­
# Public since 2013­03
#
SELECT ASTEXT(0x0100000000030000000100000000000010);
www.fromdual.com
19 / 39
Konfiguration Sicherheit
Name Scope Dynamic
allow_suspicious_udfs Global No
automatic_sp_privileges Global Yes
chroot Global No
des_key_file Global No
local_infile Global Yes
old_passwords Both Yes
safe_user_create Global Yes
secure_auth Global Yes
secure_file_priv Global No
skip_grant_tables Global No
skip_name_resolve Global No
skip_networking Global No
skip_show_database Global No
www.fromdual.com
20 / 39
Konfiguration Ressourcen
● Schlechte Performance
● DoS
● Unterallokation
● Schlechte Performance (I/O Sättigung)
● Überallokation
● Swapping (slow)
● kill/crash (32-bit)
● oom-killer (service outage)
● Einfluss auf andere (VM, noisy neighbours)
● Kosten
● Zu fette Hardware
www.fromdual.com
21 / 39
User Management
● Übersicht
● Host:
● skip_name_resolve wenn DNS nicht getraut wird oder instabil ist
● IP address spoofing (soll nicht ganz einfach sein)?
● CREATE USER, DROP USER
● Abgelegt unter: mysql.user
● Anonymous User kann immer verbinden (USAGE), in Kombination
mit test Schema, siehe oben.
SELECT user, host, password FROM mysql.user;
SHOW GRANTS FOR ''@localhost;
www.fromdual.com
22 / 39
Objekt Privilegien
● Was sind Objekte:
● Tabellen, Indices, Views, Procedures, Functions, Triggers, Events, Temporäre Tabellen
● Wer sollte was dürfen?
● read-only User:
● SELECT, SHOW DATABASES
● read-write User:
● UPDATE INSERT DELETE CREATE TEMPORARY TABLES, LOCK TABLES
● Schema Owner:
● ALTER ROUTINE, CREATE ROUTINE, EXECUTE, CREATE VIEW, SHOW VIEW,
TRIGGER, INDEX, ALTER, EVENT, REFERENCES, DROP, CREATE
● Privilegien-Hierarchie: Global, Schema, Tabelle/Routine, Spalte
● GRANT ... ON schema.table
● GRANT ... ON mysql.xxx vermeiden!
● Liegen unter mysql.{user, db, table_privs, procs_priv, 
column_privs)
www.fromdual.com
23 / 39
Globale/System Privilegien
● Globale Privilegien:
● ALL, USAGE, SUPER, SHUTDOWN, REPLICATION SLAVE, REPLICATION CLIENT, 
RELOAD, PROXY, PROCESS, CREATE USER, CREATE TABLESPACE, FILE, GRANT 
OPTION
● Liegen in mysql.user
● Was lässt sich so anstellen mit:
● ALL --> alles :-)
● USAGE --> verbinden, siehe oben
● SUPER --> CHANGE MASTER TO, KILL, PURGE BINARY LOGS, SET GLOBAL, Daten
änderungen (read_only) Replikation start/stop, Log ein/ausschalten, Definer in Stored
Programs ändern (Möglichkeit Privilegien aufzubohren?)
● REPLICATION SLAVE --> Binary Logs remote lesen
● PROCESS --> Anderer User Prozesse/Statements einsehen
● GRANT OPTION --> Anderen Usern eigene Rechte geben
● FILE --> Jedes beliebige File auf dem DB-Server lesen (welches mysql User lesen kann)
● Beispiel FILE
www.fromdual.com
24 / 39
Rollen / externe Authentifizierung
● MySQL kann native keine Rollen
● Nicht so tragisch, Rollen heute meist in Applikation abgebildet
● Rolen ab MySQL 5.7.7 mit "expanded Proxy User Support"
● http://mysqlblog.fivefarmers.com/2015/04/08/emulating-roles-with-expanded-proxy-user-
support-in-5-7-7/
● MariaDB (10.0.5):
● CREATE ROLE myrole;
● GRANT ... ON *.* to myrole;
● GRANT myrole to oli;
● MySQL Rollen mit PAM plugin
● https://www.percona.com/blog/2015/03/02/emulating-roles-percona-pam-plugin-
proxy-users/
● PAM Authentication (Unix, LDAP)
● Percona, MariaDB und MySQL Enterprise
www.fromdual.com
25 / 39
Verschlüsselung
● Wer ist der Angreifer?
● Client/Server SSL
● App: Record Encryption
● MariaDB 10.1.4
Table(space) Encryption
● Filesystem Encryption
● Keys aus Memory hacken
● Performance Einfluss
● Operations/Fehlerbehebung
www.fromdual.com
26 / 39
Zutritt verschaffen
● ~/.my.cnf --> user / password
● ~/.mylogin.cnf --> Entschlüsseln
● /etc/mysql/conf.d/debian.cnf (= root)
● shell> history
● ~/.mysql_history
● $datadir/master.info
● skip_grant_tables
● So fertig Security?
www.fromdual.com
27 / 39
Ups!
www.fromdual.com
28 / 39
Backup / Restore
● Backup? Nur für Mädchen...
● Bei logischen Fehlern
● Ups Query!
● Hardware-Ausfall --> HA Lösung
● Typen von Backup
● Logische Backups (mysqldump)
● Physische Backups (LVM, xtrabackup)
● Delayed Replikation
● Restore
● MTTR (Zeit)
● Erlaubter Datenverlust?
● Point-in-Time-Recovery (Binary Logs)
● Automatisieren, Testen (regelmässig)
● Warum?
● Unser Konzept...
www.fromdual.com
29 / 39
Restore regelmässig testen...
Prod QA Test Dev
EntwicklungProduktion
DBA Developer
bck
nightly restore
www.fromdual.com
30 / 39
Und jetzt das...
www.fromdual.com
31 / 39
Hochverfügbarkeit (HA)
● Ja, wir haben Sicherheit!
● Ja, wir haben Backup!
● Was passiert bei Hardwareausfall???
● MTTR bei Hardwareausfall?
● Redundanz
● Hilft aber nicht bei logischen Fehlern!
● Master/Slave, Galera
● Delayed Replikation für logische Fehler
www.fromdual.com
32 / 39
Automatisches Failover
● KISS
● Ihr müsst mit Eurem HA umgehen können...!
● Umschalten
● voll manuell
● halb-automatisch
● voll-automatisch
● Wer entscheidet ob failover oder nicht?
● Voll-automatisch kling verlockend!
● Oft falsche Failovers, da schwierig zu entscheiden
● Wir empfehlen: halb-automatisch...
www.fromdual.com
33 / 39
Monitoring
● Wie stellen wir fest, dass was schief läuft/lief?
● Überwachen (Monitoring)
● Notfall
● Trends
● MySQL Error log.
● Lösungen:
● FromDual Plugins für Nagios
● FromDual Performance Monitor für MySQL und MariaDB
● MySQL Enterprise Monitor
● Critical:
● DB up/down
● Filesystem full
● Replikation läuft
● Alles andere:
● Nice to have (Performance Graphen)
www.fromdual.com
34 / 39
Wo lauert das Böse?
● Personen (eher Datenklau als Zerstörung)
● Hardware-Schrauber
● Unix-Admin (root)
● DBA (kein root?)
● Entwickler?
● Endnutzer (Sales?)
● Sonstige (Putzfrau, Chef, ...)
● Hintermänner:
● Ehemalige Mitarbeiter
● Konkurrenz / Geheimdienste
● Kriminelle Organisationen, Erpressung, DoS
● Äussere Einflüsse (eher Zerstörung als Datenklau)
● Wasser (Stausee, Hochwasser, Flutwelle, Lawine)
● Feuer, Blitz, Sturm, KKW
● Erbeben, Erdrutsche
● Hochseefrachter :-)
● Terror- und/oder Bombenanschläge (Philipinen)
● Kriegerische Handlungen (Ukraine, „nuclear bomb blast on the city of London“)
● Sonstige Sabotage-Akte
www.fromdual.com
35 / 39
Angriffsvektoren
Prod QA Test Dev
EntwicklungProduktion
bck
File / Disk
?
www.fromdual.com
36 / 39
Beispiele aus der Praxis
www.fromdual.com
37 / 39
Literatur
● FromDual Security: http://www.fromdual.com/security
● MySQL Docu:
http://dev.mysql.com/doc/refman/5.6/en/security.html
● MySQL Enterprise Security:
http://dev.mysql.com/doc/refman/5.6/en/mysql-enterprise-
security.html
● Security in MySQL: http://dev.mysql.com/doc/mysql-
security-excerpt/5.6/en/index.html
● What is new in MySQL 5.7:
http://dev.mysql.com/doc/refman/5.7/en/mysql-nutshell.html
● Security Vulnerabilities Fixed in MariaDB:
https://mariadb.com/kb/en/mariadb/security/
www.fromdual.com
38 / 39
Wir suchen noch:
MySQL Datenbank Enthusiast/in für
Support / remote-DBA / Beratung
www.fromdual.com
39 / 39
Q & A
Fragen ?
Diskussion?
Wir haben Zeit für ein persönliches Gespräch...
● FromDual bietet neutral und unabhängig:
● Beratung
● Remote-DBA
● Support für MySQL, Galera, Percona Server und MariaDB
● Schulung
www.fromdual.com/presentations

Weitere ähnliche Inhalte

Andere mochten auch

MySQL Performance Tuning für Entwickler
MySQL Performance Tuning für EntwicklerMySQL Performance Tuning für Entwickler
MySQL Performance Tuning für EntwicklerFromDual GmbH
 
MySQL Replikation - Die Eier legende Wollmilchsau?
MySQL Replikation - Die Eier legende Wollmilchsau?MySQL Replikation - Die Eier legende Wollmilchsau?
MySQL Replikation - Die Eier legende Wollmilchsau?FromDual GmbH
 
High-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQLHigh-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQLFromDual GmbH
 
DOAG: NoSQL with MySQL
DOAG: NoSQL with MySQLDOAG: NoSQL with MySQL
DOAG: NoSQL with MySQLFromDual GmbH
 
MySQL - New Features 5.6
MySQL - New Features 5.6MySQL - New Features 5.6
MySQL - New Features 5.6FromDual GmbH
 
MySQL configuration - The most important Variables
MySQL configuration - The most important VariablesMySQL configuration - The most important Variables
MySQL configuration - The most important VariablesFromDual GmbH
 
OpenExpo: MySQL, Where are you going?
OpenExpo: MySQL, Where are you going?OpenExpo: MySQL, Where are you going?
OpenExpo: MySQL, Where are you going?FromDual GmbH
 
FOSDEM 2012: New Features in MySQL 5.6
FOSDEM 2012: New Features in MySQL 5.6FOSDEM 2012: New Features in MySQL 5.6
FOSDEM 2012: New Features in MySQL 5.6FromDual GmbH
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAsFromDual GmbH
 
Reading MySQL fingerprints
Reading MySQL fingerprintsReading MySQL fingerprints
Reading MySQL fingerprintsFromDual GmbH
 
MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability SolutionsFromDual GmbH
 
DOAG 2011: MySQL Performance Tuning
DOAG 2011: MySQL Performance TuningDOAG 2011: MySQL Performance Tuning
DOAG 2011: MySQL Performance TuningFromDual GmbH
 
Percona Live: Various MySQL High Availability (HA) Solutions
Percona Live: Various MySQL High Availability (HA) SolutionsPercona Live: Various MySQL High Availability (HA) Solutions
Percona Live: Various MySQL High Availability (HA) SolutionsFromDual GmbH
 
PERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaPERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaFromDual GmbH
 
MySQL Monitoring with Zabbix
MySQL Monitoring with ZabbixMySQL Monitoring with Zabbix
MySQL Monitoring with ZabbixFromDual GmbH
 

Andere mochten auch (17)

MySQL Performance Tuning für Entwickler
MySQL Performance Tuning für EntwicklerMySQL Performance Tuning für Entwickler
MySQL Performance Tuning für Entwickler
 
MySQL Replikation - Die Eier legende Wollmilchsau?
MySQL Replikation - Die Eier legende Wollmilchsau?MySQL Replikation - Die Eier legende Wollmilchsau?
MySQL Replikation - Die Eier legende Wollmilchsau?
 
High-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQLHigh-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQL
 
DOAG: NoSQL with MySQL
DOAG: NoSQL with MySQLDOAG: NoSQL with MySQL
DOAG: NoSQL with MySQL
 
NoSQL with MySQL
NoSQL with MySQLNoSQL with MySQL
NoSQL with MySQL
 
Froscon 2012 DWH
Froscon 2012 DWHFroscon 2012 DWH
Froscon 2012 DWH
 
MySQL - New Features 5.6
MySQL - New Features 5.6MySQL - New Features 5.6
MySQL - New Features 5.6
 
MySQL configuration - The most important Variables
MySQL configuration - The most important VariablesMySQL configuration - The most important Variables
MySQL configuration - The most important Variables
 
OpenExpo: MySQL, Where are you going?
OpenExpo: MySQL, Where are you going?OpenExpo: MySQL, Where are you going?
OpenExpo: MySQL, Where are you going?
 
FOSDEM 2012: New Features in MySQL 5.6
FOSDEM 2012: New Features in MySQL 5.6FOSDEM 2012: New Features in MySQL 5.6
FOSDEM 2012: New Features in MySQL 5.6
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAs
 
Reading MySQL fingerprints
Reading MySQL fingerprintsReading MySQL fingerprints
Reading MySQL fingerprints
 
MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability Solutions
 
DOAG 2011: MySQL Performance Tuning
DOAG 2011: MySQL Performance TuningDOAG 2011: MySQL Performance Tuning
DOAG 2011: MySQL Performance Tuning
 
Percona Live: Various MySQL High Availability (HA) Solutions
Percona Live: Various MySQL High Availability (HA) SolutionsPercona Live: Various MySQL High Availability (HA) Solutions
Percona Live: Various MySQL High Availability (HA) Solutions
 
PERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaPERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schema
 
MySQL Monitoring with Zabbix
MySQL Monitoring with ZabbixMySQL Monitoring with Zabbix
MySQL Monitoring with Zabbix
 

Ähnlich wie MySQL Security SLAC 2015

Rex - Infrastruktur als Code
Rex - Infrastruktur als CodeRex - Infrastruktur als Code
Rex - Infrastruktur als CodeJan Gehring
 
FROSCON 2011: MySQL Performance Tuning
FROSCON 2011: MySQL Performance TuningFROSCON 2011: MySQL Performance Tuning
FROSCON 2011: MySQL Performance TuningFromDual GmbH
 
MySQL HA and Security
MySQL HA and SecurityMySQL HA and Security
MySQL HA and SecurityFromDual GmbH
 
Einführung in Puppet und Vagrant
Einführung in Puppet und VagrantEinführung in Puppet und Vagrant
Einführung in Puppet und Vagrants0enke
 
FROSCON 2011: MySQL Replication
FROSCON 2011: MySQL ReplicationFROSCON 2011: MySQL Replication
FROSCON 2011: MySQL ReplicationFromDual GmbH
 
MySQL Replication for Beginners
MySQL Replication for BeginnersMySQL Replication for Beginners
MySQL Replication for BeginnersFromDual GmbH
 
Continuous Delivery - Aber Sicher?!
Continuous Delivery - Aber Sicher?!Continuous Delivery - Aber Sicher?!
Continuous Delivery - Aber Sicher?!Jan Dittberner
 
DevDay 2016 - Jan Dittberner - Continous Delivery - Aber sicher?!
DevDay 2016 - Jan Dittberner - Continous Delivery - Aber sicher?!DevDay 2016 - Jan Dittberner - Continous Delivery - Aber sicher?!
DevDay 2016 - Jan Dittberner - Continous Delivery - Aber sicher?!DevDay Dresden
 
Die Datenbank ist nicht immer Schuld - Gründe warum Datenbank-Migration schei...
Die Datenbank ist nicht immer Schuld - Gründe warum Datenbank-Migration schei...Die Datenbank ist nicht immer Schuld - Gründe warum Datenbank-Migration schei...
Die Datenbank ist nicht immer Schuld - Gründe warum Datenbank-Migration schei...Markus Flechtner
 
Grundlagen puppet
Grundlagen puppetGrundlagen puppet
Grundlagen puppetinovex GmbH
 
DOAG SIG: MySQL Replikation, Scale-Out, Master- Master Replikation, Backup
DOAG SIG: MySQL Replikation, Scale-Out, Master- Master Replikation, BackupDOAG SIG: MySQL Replikation, Scale-Out, Master- Master Replikation, Backup
DOAG SIG: MySQL Replikation, Scale-Out, Master- Master Replikation, BackupFromDual GmbH
 
Dnug35 ak-dev.071111-cookbook
Dnug35 ak-dev.071111-cookbookDnug35 ak-dev.071111-cookbook
Dnug35 ak-dev.071111-cookbookUlrich Krause
 
Qualitätssicherung in Webprojekten
Qualitätssicherung in WebprojektenQualitätssicherung in Webprojekten
Qualitätssicherung in WebprojektenSebastian Springer
 
DOAG SIG Security Vortrag 2013: Wann haben Sie das letzte Mal Ihre Datenbank ...
DOAG SIG Security Vortrag 2013: Wann haben Sie das letzte Mal Ihre Datenbank ...DOAG SIG Security Vortrag 2013: Wann haben Sie das letzte Mal Ihre Datenbank ...
DOAG SIG Security Vortrag 2013: Wann haben Sie das letzte Mal Ihre Datenbank ...Carsten Muetzlitz
 
DOAG 2011: MySQL Replication
DOAG 2011: MySQL ReplicationDOAG 2011: MySQL Replication
DOAG 2011: MySQL ReplicationFromDual GmbH
 
Internet Briefing 2010: Performance Tuning & Scale-Out mit MySQL
Internet Briefing 2010: Performance Tuning & Scale-Out mit MySQLInternet Briefing 2010: Performance Tuning & Scale-Out mit MySQL
Internet Briefing 2010: Performance Tuning & Scale-Out mit MySQLFromDual GmbH
 
Solr & Cassandra: Searching Cassandra with DataStax Enterprise
Solr & Cassandra: Searching Cassandra with DataStax EnterpriseSolr & Cassandra: Searching Cassandra with DataStax Enterprise
Solr & Cassandra: Searching Cassandra with DataStax EnterpriseDataStax Academy
 

Ähnlich wie MySQL Security SLAC 2015 (20)

Rex - Infrastruktur als Code
Rex - Infrastruktur als CodeRex - Infrastruktur als Code
Rex - Infrastruktur als Code
 
MySQL Backup
MySQL BackupMySQL Backup
MySQL Backup
 
FROSCON 2011: MySQL Performance Tuning
FROSCON 2011: MySQL Performance TuningFROSCON 2011: MySQL Performance Tuning
FROSCON 2011: MySQL Performance Tuning
 
MySQL HA and Security
MySQL HA and SecurityMySQL HA and Security
MySQL HA and Security
 
Einführung in Puppet und Vagrant
Einführung in Puppet und VagrantEinführung in Puppet und Vagrant
Einführung in Puppet und Vagrant
 
FROSCON 2011: MySQL Replication
FROSCON 2011: MySQL ReplicationFROSCON 2011: MySQL Replication
FROSCON 2011: MySQL Replication
 
MySQL Replication for Beginners
MySQL Replication for BeginnersMySQL Replication for Beginners
MySQL Replication for Beginners
 
Continuous Delivery - Aber Sicher?!
Continuous Delivery - Aber Sicher?!Continuous Delivery - Aber Sicher?!
Continuous Delivery - Aber Sicher?!
 
DevDay 2016 - Jan Dittberner - Continous Delivery - Aber sicher?!
DevDay 2016 - Jan Dittberner - Continous Delivery - Aber sicher?!DevDay 2016 - Jan Dittberner - Continous Delivery - Aber sicher?!
DevDay 2016 - Jan Dittberner - Continous Delivery - Aber sicher?!
 
Die Datenbank ist nicht immer Schuld - Gründe warum Datenbank-Migration schei...
Die Datenbank ist nicht immer Schuld - Gründe warum Datenbank-Migration schei...Die Datenbank ist nicht immer Schuld - Gründe warum Datenbank-Migration schei...
Die Datenbank ist nicht immer Schuld - Gründe warum Datenbank-Migration schei...
 
Grundlagen puppet
Grundlagen puppetGrundlagen puppet
Grundlagen puppet
 
DOAG SIG: MySQL Replikation, Scale-Out, Master- Master Replikation, Backup
DOAG SIG: MySQL Replikation, Scale-Out, Master- Master Replikation, BackupDOAG SIG: MySQL Replikation, Scale-Out, Master- Master Replikation, Backup
DOAG SIG: MySQL Replikation, Scale-Out, Master- Master Replikation, Backup
 
Dnug35 ak-dev.071111-cookbook
Dnug35 ak-dev.071111-cookbookDnug35 ak-dev.071111-cookbook
Dnug35 ak-dev.071111-cookbook
 
Qualitätssicherung in Webprojekten
Qualitätssicherung in WebprojektenQualitätssicherung in Webprojekten
Qualitätssicherung in Webprojekten
 
DOAG SIG Security Vortrag 2013: Wann haben Sie das letzte Mal Ihre Datenbank ...
DOAG SIG Security Vortrag 2013: Wann haben Sie das letzte Mal Ihre Datenbank ...DOAG SIG Security Vortrag 2013: Wann haben Sie das letzte Mal Ihre Datenbank ...
DOAG SIG Security Vortrag 2013: Wann haben Sie das letzte Mal Ihre Datenbank ...
 
DOAG 2011: MySQL Replication
DOAG 2011: MySQL ReplicationDOAG 2011: MySQL Replication
DOAG 2011: MySQL Replication
 
MySQL Security
MySQL SecurityMySQL Security
MySQL Security
 
XPages - The Basics
XPages - The BasicsXPages - The Basics
XPages - The Basics
 
Internet Briefing 2010: Performance Tuning & Scale-Out mit MySQL
Internet Briefing 2010: Performance Tuning & Scale-Out mit MySQLInternet Briefing 2010: Performance Tuning & Scale-Out mit MySQL
Internet Briefing 2010: Performance Tuning & Scale-Out mit MySQL
 
Solr & Cassandra: Searching Cassandra with DataStax Enterprise
Solr & Cassandra: Searching Cassandra with DataStax EnterpriseSolr & Cassandra: Searching Cassandra with DataStax Enterprise
Solr & Cassandra: Searching Cassandra with DataStax Enterprise
 

Mehr von FromDual GmbH

MariaDB/MySQL pitfalls - And how to come out again...
MariaDB/MySQL pitfalls - And how to come out again...MariaDB/MySQL pitfalls - And how to come out again...
MariaDB/MySQL pitfalls - And how to come out again...FromDual GmbH
 
MariaDB / MySQL tripping hazard and how to get out again?
MariaDB / MySQL tripping hazard and how to get out again?MariaDB / MySQL tripping hazard and how to get out again?
MariaDB / MySQL tripping hazard and how to get out again?FromDual GmbH
 
PXC 5.5 to MariaDB 10.4 Galera Cluster Migration Workshop
PXC 5.5 to MariaDB 10.4 Galera Cluster Migration WorkshopPXC 5.5 to MariaDB 10.4 Galera Cluster Migration Workshop
PXC 5.5 to MariaDB 10.4 Galera Cluster Migration WorkshopFromDual GmbH
 
IT Tage 2019 MariaDB 10.4 New Features
IT Tage 2019 MariaDB 10.4 New FeaturesIT Tage 2019 MariaDB 10.4 New Features
IT Tage 2019 MariaDB 10.4 New FeaturesFromDual GmbH
 
MariaDB 10.4 New Features
MariaDB 10.4 New FeaturesMariaDB 10.4 New Features
MariaDB 10.4 New FeaturesFromDual GmbH
 
MariaDB 10.2 New Features
MariaDB 10.2 New FeaturesMariaDB 10.2 New Features
MariaDB 10.2 New FeaturesFromDual GmbH
 
MySQL always-up with Galera Cluster
MySQL always-up with Galera ClusterMySQL always-up with Galera Cluster
MySQL always-up with Galera ClusterFromDual GmbH
 
MySQL Indexierung CeBIT 2014
MySQL Indexierung CeBIT 2014MySQL Indexierung CeBIT 2014
MySQL Indexierung CeBIT 2014FromDual GmbH
 
MySQL Cluster with Galera Cluster for MySQL
MySQL Cluster with Galera Cluster for MySQLMySQL Cluster with Galera Cluster for MySQL
MySQL Cluster with Galera Cluster for MySQLFromDual GmbH
 
Need for Speed: Mysql indexing
Need for Speed: Mysql indexingNeed for Speed: Mysql indexing
Need for Speed: Mysql indexingFromDual GmbH
 
MySQL Performance Tuning Variables
MySQL Performance Tuning VariablesMySQL Performance Tuning Variables
MySQL Performance Tuning VariablesFromDual GmbH
 

Mehr von FromDual GmbH (12)

MariaDB/MySQL pitfalls - And how to come out again...
MariaDB/MySQL pitfalls - And how to come out again...MariaDB/MySQL pitfalls - And how to come out again...
MariaDB/MySQL pitfalls - And how to come out again...
 
MariaDB / MySQL tripping hazard and how to get out again?
MariaDB / MySQL tripping hazard and how to get out again?MariaDB / MySQL tripping hazard and how to get out again?
MariaDB / MySQL tripping hazard and how to get out again?
 
PXC 5.5 to MariaDB 10.4 Galera Cluster Migration Workshop
PXC 5.5 to MariaDB 10.4 Galera Cluster Migration WorkshopPXC 5.5 to MariaDB 10.4 Galera Cluster Migration Workshop
PXC 5.5 to MariaDB 10.4 Galera Cluster Migration Workshop
 
IT Tage 2019 MariaDB 10.4 New Features
IT Tage 2019 MariaDB 10.4 New FeaturesIT Tage 2019 MariaDB 10.4 New Features
IT Tage 2019 MariaDB 10.4 New Features
 
MariaDB 10.4 New Features
MariaDB 10.4 New FeaturesMariaDB 10.4 New Features
MariaDB 10.4 New Features
 
MariaDB 10.2 New Features
MariaDB 10.2 New FeaturesMariaDB 10.2 New Features
MariaDB 10.2 New Features
 
MySQL always-up with Galera Cluster
MySQL always-up with Galera ClusterMySQL always-up with Galera Cluster
MySQL always-up with Galera Cluster
 
HA with Galera
HA with GaleraHA with Galera
HA with Galera
 
MySQL Indexierung CeBIT 2014
MySQL Indexierung CeBIT 2014MySQL Indexierung CeBIT 2014
MySQL Indexierung CeBIT 2014
 
MySQL Cluster with Galera Cluster for MySQL
MySQL Cluster with Galera Cluster for MySQLMySQL Cluster with Galera Cluster for MySQL
MySQL Cluster with Galera Cluster for MySQL
 
Need for Speed: Mysql indexing
Need for Speed: Mysql indexingNeed for Speed: Mysql indexing
Need for Speed: Mysql indexing
 
MySQL Performance Tuning Variables
MySQL Performance Tuning VariablesMySQL Performance Tuning Variables
MySQL Performance Tuning Variables
 

MySQL Security SLAC 2015

  • 1. www.fromdual.com 1 / 39 MySQL sicher aufsetzen und betreiben SLAC 2015, Berlin Oli Sennhauser Senior MySQL Consultant, FromDual GmbH oli.sennhauser@fromdual.com
  • 2. www.fromdual.com 2 / 39 FromDual GmbH Support remote-DBA Schulung Beratung
  • 3. www.fromdual.com 3 / 39 Inhalt MySQL sicher aufsetzen und betreiben ➢ Vorbereitungen ➢ Installation ➢ Härten ➢ Upgrade ➢ Konfiguration ➢ User Management ➢ Verschlüsselung ➢ Backup / Restore ➢ Hochverfügbarkeit ➢ Monitoring ➢ Wo lauert das Böse? ➢ Angriffsvektoren
  • 4. www.fromdual.com 4 / 39 Vorbereitung Installation ● Welches O/S, welche Distro? ● Windows kann heute auch sicher sein... ● Was könnt Ihr am besten? ● Welcher Branch/Fork? ● MySQL, MariaDB, Percona, Galera ● Packet, Binary Tarball, oder Source ● DEB/RPM von Distribution oder Hersteller ● Distribution oft veraltet ● und wie gut gepatched? ● und wenn gepachted, wie gut getestet? ● Version ● MySQL: 5.5, 5.6, (5.7), MariaDB 5.5, 10.0, (10.1)
  • 5. www.fromdual.com 5 / 39 Installation ● Durch wen? ● Pakete ● selber (mysql_install_db) ● Wohin? ● /var/lib/mysql ● /mount/mysql/data ● Advanced Security macht ärger! ● AppArmor ● SElinux ● weitere potentielle Problemchen ● /etc/mysql/conf.d/debian.cnf (root äquivalent) ● Syslog auf Debian/Ubuntu: die Log-Informationen sind auf nimmer wiedersehen weg, nicht theoretisch sonder praktisch!
  • 6. www.fromdual.com 6 / 39 Was passiert bei Installation? ● InnoDB Tablespace und Log Files ● MySQL Data Dictionary (mysql Schema) ● Kreiert User (root, anonymous) ● Kreiert test Schema slac1 ● Was ist das Problem? ● Härtet jemand von Euch nach Installation?
  • 7. www.fromdual.com 7 / 39 Härten von MySQL ● Wie: ● mysql_secure_installation ● leider „kaputt“ ● Was: ● root Passwort ● root von remote ● test Schema ● anonymous User (''@localhost) slac1
  • 8. www.fromdual.com 8 / 39 Warum härten? ● Root Passwort setzen ist klar? ● Nein mir nicht! ● Wenn niemand lokal zugriff hat ausser root braucht es dort auch kein Passwort. ● Root von remote ist klar? ● Sogar mir! ● Warum ist der anonymous User (''@server) böse? slac2 ● Warum ist das test Schema böse? ● Insbesondere Hoster/SaaS und Ähnliche aufpassen!!!
  • 9. www.fromdual.com 9 / 39 Neues Mätzchen mit 5.6 ● Seit MySQL 5.6 gilt: ● Passwort auf Kommandozeile ist böse, warum? ● Kann mir jemand sagen warum? slac2 ● Früher ~/.my.cnf (chmod 0600) ● Scheint heute immer noch sicher! shell> mysql --user=sicher --password=secret Warning: Using a password on the command line Interface can be insecure.
  • 10. www.fromdual.com 10 / 39 Heute: MySQL Config Editor ● Seit MySQL 5.6 gilt: ● Wieso geht das jetzt??? slac2 ● Fortsetzung folgt... shell> mysql_config_editor set -–login-path=slac2 --host=localhost --user=sicher –-password shell> mysql --login-path=slac2
  • 11. www.fromdual.com 11 / 39 Und wie cracken? ● Security by Obscurity??? ● Sicherheitsgewinn? ● Und jetzt wie cracken? :-) The encryption used by mysql_config_editor prevents passwords from appearing in .mylogin.cnf as cleartext and provides a measure of security by preventing inadvertent password exposure. For example, if you display a regular unencrypted my.cnf option file on the screen, any passwords it contains are visible for anyone to see. With .mylogin.cnf, that is not true. But the encryption used will not deter a determined attacker and you should not consider it unbreakable. A user who can gain system administration privileges on your machine to access your files could decrypt the .mylogin.cnf file with some effort.
  • 12. www.fromdual.com 12 / 39 Weitere Sicherheitsfeatures ● MySQL CLI: Filter auf password in History ● OK. Seh ich ja ein, ist aber mühsam: ● grep password ~/.mysql_history ● Installation in 5.7 automatisch sicher ● Kein test Schema mehr ● Kein anonymous User mehr ● Kein root von Remote mehr ● UND: root@localhost hat default Passwort, welches geändert werden muss...
  • 13. www.fromdual.com 13 / 39 Upgrade / Release Cycles? ● Major Releases: ● MySQL 5.1, 5.5, 5.6, 5.7 (ca. alle 2 Jahre) ● MariaDB 5.1, 5.2, 5.3, 5.5, 10.0, 10.1 (ca. alle 18 Monate) ● Minor Releases: ● 5.6.x ● MySQL ca. 6 pro Jahr (also alle 2 Monate) ● MariaDB ca. 6 pro Jahr (also alle 2 Monate) ● Und jetzt, alle 2 Monate ein Upgrade? ● Ja, warum nicht? ● Wir haben Testautomation und ● automatisierte Deployments (siehe andere Vorträge...)
  • 14. www.fromdual.com 14 / 39 Upgrade in der Praxis ● Oracle liefert Critical Patch Updates (CPU) ● (4 pro Quartal, alle 3 Monate) ● Distributionen ähnliche Zyklen? ● ziehen die wirklich alles nach? ● Ubuntu Security Notes (USN): alle 3 Monate ● RHEL/CentOS? ● potentielle Probleme: ● Wer testet wie gut (Distribution / Betreiber)? ● Upgrade erfolgt automatisch ● Restart der DB-Instanz (Red Hat/CentOS) ● http://fromdual.com/security
  • 15. www.fromdual.com 15 / 39 Upgrade wie tun: ● Major Release NICHT überspringen! ● daher mindestens alle 2 Jahre ein upgrade ● Offizielle Methode: ● Dump/Restore (aber wie mit meinen 5 Tbyte?) ● Geht meist auch: ● Binary Upgrade ● ab 5.7 offiziell supportet!!! ● Anschliessend NICHT vergessen: ● mysql_upgrade slac3
  • 16. www.fromdual.com 16 / 39 Warum kein Upgrade böse? ● Darum: slac4 ● Oracle hat Security relevante Bugs heute versteckt... ● Aber, der Findige lässt sich nicht unterkriegen: https://bugzilla.redhat.com/show_bug.cgi?id=919247 ● Ich habe keine 15 Minuten gebraucht... ERROR 2013 (HY000): Lost connection to MySQL server during query
  • 17. www.fromdual.com 17 / 39 MySQL Crash ● Crash ist IMMER böse = IMMER ein Bug 150620 14:59:27 [ERROR] mysqld got signal 11 ; This could be because you hit a bug... Thread pointer: 0x47e10e0 Attempting backtrace. You can use the following information to find out where mysqld died. If you see no messages after this, something went terribly wrong... stack_bottom = 0x7f8949817ea8 thread_stack 0x48000 mysqld(my_print_stacktrace+0x2e) [0x9c493e] mysqld(handle_segfault+0x3b3) [0x611eb3] /lib/x86_64-linux-gnu/libpthread.so.0(+0x10340) [0x7f8948a70340] mysqld() [0x75aaf0] mysqld(Geometry::append_points(String*, unsigned int, char const*, unsigned int) const+0x4e) mysqld(Gis_polygon::get_data_as_wkt(String*, char const**) const+0xbb) [0x75c68b] mysqld(Item_func_as_wkt::val_str(String*)+0x145) [0x5d6f55] ... mysqld(mysql_execute_command(THD*)+0x2d4e) [0x62066e] mysqld(mysql_parse(THD*, char*, unsigned int, char const**)+0x299) [0x623ff9] mysqld(dispatch_command(enum_server_command, THD*, char*, unsigned int)+0xb9b) [0x624b9b] mysqld(do_command(THD*)+0x101) [0x6255b1] mysqld(handle_one_connection+0xdf) [0x61690f] /lib/x86_64-linux-gnu/libpthread.so.0(+0x8182) [0x7f8948a68182] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f8947f8347d] Trying to get some variables. Some pointers may be invalid and cause the dump to abort. Query (0x7f88cc004b98): select astext(0x0100000000030000000100000000000010) Connection ID (thread ID): 1 Status: NOT_KILLED
  • 18. www.fromdual.com 18 / 39 Jeder hat seine Leidenschaft ● Es gibt Leute, die sammeln Briefmarken... ● Andere sammeln so was: # # Bug #68591: Geometry query crashes mysqld # http://bugs.mysql.com/bug.php?id=68591 # https://mariadb.atlassian.net/browse/MDEV­4252 # https://bugzilla.redhat.com/show_bug.cgi?id=919247 # # Fixed in: MySQL 5.6.12, 5.5.32, 5.1.70 #           MariaDB 5.5.30, 5.3.13, 5.2.15, 5.1.73 # Happens in: before # Does not happen in: ­ # Public since 2013­03 # SELECT ASTEXT(0x0100000000030000000100000000000010);
  • 19. www.fromdual.com 19 / 39 Konfiguration Sicherheit Name Scope Dynamic allow_suspicious_udfs Global No automatic_sp_privileges Global Yes chroot Global No des_key_file Global No local_infile Global Yes old_passwords Both Yes safe_user_create Global Yes secure_auth Global Yes secure_file_priv Global No skip_grant_tables Global No skip_name_resolve Global No skip_networking Global No skip_show_database Global No
  • 20. www.fromdual.com 20 / 39 Konfiguration Ressourcen ● Schlechte Performance ● DoS ● Unterallokation ● Schlechte Performance (I/O Sättigung) ● Überallokation ● Swapping (slow) ● kill/crash (32-bit) ● oom-killer (service outage) ● Einfluss auf andere (VM, noisy neighbours) ● Kosten ● Zu fette Hardware
  • 21. www.fromdual.com 21 / 39 User Management ● Übersicht ● Host: ● skip_name_resolve wenn DNS nicht getraut wird oder instabil ist ● IP address spoofing (soll nicht ganz einfach sein)? ● CREATE USER, DROP USER ● Abgelegt unter: mysql.user ● Anonymous User kann immer verbinden (USAGE), in Kombination mit test Schema, siehe oben. SELECT user, host, password FROM mysql.user; SHOW GRANTS FOR ''@localhost;
  • 22. www.fromdual.com 22 / 39 Objekt Privilegien ● Was sind Objekte: ● Tabellen, Indices, Views, Procedures, Functions, Triggers, Events, Temporäre Tabellen ● Wer sollte was dürfen? ● read-only User: ● SELECT, SHOW DATABASES ● read-write User: ● UPDATE INSERT DELETE CREATE TEMPORARY TABLES, LOCK TABLES ● Schema Owner: ● ALTER ROUTINE, CREATE ROUTINE, EXECUTE, CREATE VIEW, SHOW VIEW, TRIGGER, INDEX, ALTER, EVENT, REFERENCES, DROP, CREATE ● Privilegien-Hierarchie: Global, Schema, Tabelle/Routine, Spalte ● GRANT ... ON schema.table ● GRANT ... ON mysql.xxx vermeiden! ● Liegen unter mysql.{user, db, table_privs, procs_priv,  column_privs)
  • 23. www.fromdual.com 23 / 39 Globale/System Privilegien ● Globale Privilegien: ● ALL, USAGE, SUPER, SHUTDOWN, REPLICATION SLAVE, REPLICATION CLIENT,  RELOAD, PROXY, PROCESS, CREATE USER, CREATE TABLESPACE, FILE, GRANT  OPTION ● Liegen in mysql.user ● Was lässt sich so anstellen mit: ● ALL --> alles :-) ● USAGE --> verbinden, siehe oben ● SUPER --> CHANGE MASTER TO, KILL, PURGE BINARY LOGS, SET GLOBAL, Daten änderungen (read_only) Replikation start/stop, Log ein/ausschalten, Definer in Stored Programs ändern (Möglichkeit Privilegien aufzubohren?) ● REPLICATION SLAVE --> Binary Logs remote lesen ● PROCESS --> Anderer User Prozesse/Statements einsehen ● GRANT OPTION --> Anderen Usern eigene Rechte geben ● FILE --> Jedes beliebige File auf dem DB-Server lesen (welches mysql User lesen kann) ● Beispiel FILE
  • 24. www.fromdual.com 24 / 39 Rollen / externe Authentifizierung ● MySQL kann native keine Rollen ● Nicht so tragisch, Rollen heute meist in Applikation abgebildet ● Rolen ab MySQL 5.7.7 mit "expanded Proxy User Support" ● http://mysqlblog.fivefarmers.com/2015/04/08/emulating-roles-with-expanded-proxy-user- support-in-5-7-7/ ● MariaDB (10.0.5): ● CREATE ROLE myrole; ● GRANT ... ON *.* to myrole; ● GRANT myrole to oli; ● MySQL Rollen mit PAM plugin ● https://www.percona.com/blog/2015/03/02/emulating-roles-percona-pam-plugin- proxy-users/ ● PAM Authentication (Unix, LDAP) ● Percona, MariaDB und MySQL Enterprise
  • 25. www.fromdual.com 25 / 39 Verschlüsselung ● Wer ist der Angreifer? ● Client/Server SSL ● App: Record Encryption ● MariaDB 10.1.4 Table(space) Encryption ● Filesystem Encryption ● Keys aus Memory hacken ● Performance Einfluss ● Operations/Fehlerbehebung
  • 26. www.fromdual.com 26 / 39 Zutritt verschaffen ● ~/.my.cnf --> user / password ● ~/.mylogin.cnf --> Entschlüsseln ● /etc/mysql/conf.d/debian.cnf (= root) ● shell> history ● ~/.mysql_history ● $datadir/master.info ● skip_grant_tables ● So fertig Security?
  • 28. www.fromdual.com 28 / 39 Backup / Restore ● Backup? Nur für Mädchen... ● Bei logischen Fehlern ● Ups Query! ● Hardware-Ausfall --> HA Lösung ● Typen von Backup ● Logische Backups (mysqldump) ● Physische Backups (LVM, xtrabackup) ● Delayed Replikation ● Restore ● MTTR (Zeit) ● Erlaubter Datenverlust? ● Point-in-Time-Recovery (Binary Logs) ● Automatisieren, Testen (regelmässig) ● Warum? ● Unser Konzept...
  • 29. www.fromdual.com 29 / 39 Restore regelmässig testen... Prod QA Test Dev EntwicklungProduktion DBA Developer bck nightly restore
  • 31. www.fromdual.com 31 / 39 Hochverfügbarkeit (HA) ● Ja, wir haben Sicherheit! ● Ja, wir haben Backup! ● Was passiert bei Hardwareausfall??? ● MTTR bei Hardwareausfall? ● Redundanz ● Hilft aber nicht bei logischen Fehlern! ● Master/Slave, Galera ● Delayed Replikation für logische Fehler
  • 32. www.fromdual.com 32 / 39 Automatisches Failover ● KISS ● Ihr müsst mit Eurem HA umgehen können...! ● Umschalten ● voll manuell ● halb-automatisch ● voll-automatisch ● Wer entscheidet ob failover oder nicht? ● Voll-automatisch kling verlockend! ● Oft falsche Failovers, da schwierig zu entscheiden ● Wir empfehlen: halb-automatisch...
  • 33. www.fromdual.com 33 / 39 Monitoring ● Wie stellen wir fest, dass was schief läuft/lief? ● Überwachen (Monitoring) ● Notfall ● Trends ● MySQL Error log. ● Lösungen: ● FromDual Plugins für Nagios ● FromDual Performance Monitor für MySQL und MariaDB ● MySQL Enterprise Monitor ● Critical: ● DB up/down ● Filesystem full ● Replikation läuft ● Alles andere: ● Nice to have (Performance Graphen)
  • 34. www.fromdual.com 34 / 39 Wo lauert das Böse? ● Personen (eher Datenklau als Zerstörung) ● Hardware-Schrauber ● Unix-Admin (root) ● DBA (kein root?) ● Entwickler? ● Endnutzer (Sales?) ● Sonstige (Putzfrau, Chef, ...) ● Hintermänner: ● Ehemalige Mitarbeiter ● Konkurrenz / Geheimdienste ● Kriminelle Organisationen, Erpressung, DoS ● Äussere Einflüsse (eher Zerstörung als Datenklau) ● Wasser (Stausee, Hochwasser, Flutwelle, Lawine) ● Feuer, Blitz, Sturm, KKW ● Erbeben, Erdrutsche ● Hochseefrachter :-) ● Terror- und/oder Bombenanschläge (Philipinen) ● Kriegerische Handlungen (Ukraine, „nuclear bomb blast on the city of London“) ● Sonstige Sabotage-Akte
  • 35. www.fromdual.com 35 / 39 Angriffsvektoren Prod QA Test Dev EntwicklungProduktion bck File / Disk ?
  • 37. www.fromdual.com 37 / 39 Literatur ● FromDual Security: http://www.fromdual.com/security ● MySQL Docu: http://dev.mysql.com/doc/refman/5.6/en/security.html ● MySQL Enterprise Security: http://dev.mysql.com/doc/refman/5.6/en/mysql-enterprise- security.html ● Security in MySQL: http://dev.mysql.com/doc/mysql- security-excerpt/5.6/en/index.html ● What is new in MySQL 5.7: http://dev.mysql.com/doc/refman/5.7/en/mysql-nutshell.html ● Security Vulnerabilities Fixed in MariaDB: https://mariadb.com/kb/en/mariadb/security/
  • 38. www.fromdual.com 38 / 39 Wir suchen noch: MySQL Datenbank Enthusiast/in für Support / remote-DBA / Beratung
  • 39. www.fromdual.com 39 / 39 Q & A Fragen ? Diskussion? Wir haben Zeit für ein persönliches Gespräch... ● FromDual bietet neutral und unabhängig: ● Beratung ● Remote-DBA ● Support für MySQL, Galera, Percona Server und MariaDB ● Schulung www.fromdual.com/presentations