securing your data in postgres
play

Securing Your Data in Postgres Payal Singh DBA@OmniTI - PowerPoint PPT Presentation

Securing Your Data in Postgres Payal Singh DBA@OmniTI payal@omniti.com Contents Event Triggers Authentication ACLs Auditing Row-Level Security SSL / TLS Encryption Replication https://www.postgresql.org/support/security/ 1.


  1. Securing Your Data in Postgres Payal Singh DBA@OmniTI payal@omniti.com

  2. Contents Event Triggers Authentication ACLs Auditing Row-Level Security SSL / TLS Encryption Replication

  3. https://www.postgresql.org/support/security/

  4. 1. Authentication

  5. # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128

  6. ident peer trust scram reject ldap md5 Password

  7. #> SET password_encryption = 'scram'; SET #> CREATE ROLE sales PASSWORD 'ReallyBadPassword'; CREATE ROLE #> SELECT substring(rolpassword, 1, 14) FROM pg_authid WHERE rolname = 'sales'; substring ---------------- scram-sha-256: (1 row)

  8. Don’t Trust TRUST ! Initdb -A md5

  9. Reject

  10. psql#> SELECT pg_realod_conf( ) ;

  11. Grand Total Of Fall Throughs Allowed: 0

  12. 2. Access Control Lists

  13. “ list st of permissions attached to an object. An ACL specifies which Grant users or system processes are granted ac acces cess to objects, as well Revo voke ke as what operations are allowed on given objects.

  14. rolename=xxxx -- privileges granted to a role =xxxx -- privileges granted to PUBLIC r -- SELECT ("read") w -- UPDATE ("write") a -- INSERT ("append") d -- DELETE D -- TRUNCATE x -- REFERENCES t -- TRIGGER X -- EXECUTE U -- USAGE C -- CREATE c -- CONNECT T -- TEMPORARY arwdDxt -- ALL PRIVILEGES (for tables, varies for other objects) * -- grant option for preceding privilege /yyyy -- role that granted this privilege

  15. Transactional DDLs psql#> BEGIN; BEGIN psql#> GRANT SELECT ON test TO payal; GRANT psql#> ROLLBACK; ROLLBACK postgres@postgres:5432# \dp test Access privileges Schema | Name | Type | Access privileges | Column privileges | Policies --------+------+-------+-------------------+-------------------+---------- public | test | table | | | (1 row)

  16. ALTER DEFAULT PRIVILEGES IN SCHEMA < schema_name > GRANT < privilege > ON TABLES TO < role >;

  17. Roles and Groups Roles Bob: Sales Rachel:

  18. Column Level ACLs postgres@postgres:5432# GRANT UPDATE(name) ON test TO rachel; GRANT postgres@postgres:5432# \dp test Access privileges Schema | Name | Type | Access privileges | Column privileges | Policies --------+------+-------+-------------------+---------------------+---------- public | test | table | | +| name: | | | | | rachel=w/postgres (1 row)

  19. PUBLIC Schema

  20. 3. Row Level Security

  21. Row Level Security CREATE TABLE accounts (manager text, company text, contact_email text); ALTER TABLE accounts ENABLE ROW LEVEL SECURITY; CREATE POLICY account_managers ON accounts TO managers USING (manager = current_user);

  22. RLS BYPASSRLS Table Owner ALTER TABLE accounts FOR FORCE CE ROW LEVEL SECURITY; Default Policy Exceptions

  23. 4. SSL / TLS

  24. ssl = o on # (change e requires es restart) #ssl_cipher ers = 'ALL:! :!ADH:! :!LOW:! W:!EXP:! :!MD5:@ :@STRE TRENGTH GTH' ' # allow owed ed SSL ciphers #ssl_prefer er_ser erver er_cipher ers = on # (change e requires es restart) #ssl_ecdh_curve e = 'prime2 e256v1' ' # (change e requires es restart) ssl_ce cert_fi t_file = '/etc tc/ssl ssl/post stgre res/ s/sta starr rry. y.io. o.crt' crt' # (change e requi uires es restart) ssl_key_ y_fi file = '/etc tc/ssl ssl/postg ostgre res/ s/sta starry. ry.io. o.key' y' # (change e requires es restart) ssl_ca_file le = '' # (change e requires es restart) #ssl_crl_ l_file le = '' # (change e requires es restart)

  25. OpenSSL --with-openssl at build time Encryption Permissions New Certificates

  26. Modes DISABLE No SSL connections allowed ALLOW Allow SSL Connections if connections without SSL fails PREFER Allow non-SSL connection if SSL connection fails REQUIRE Certificate verification required to connect VERIFY-CA Verify server certificate VERIFY-FULL Server HostName same as name in certificate

  27. Tunneling ssh -L 63333:localhost:5432 joe@foo.com psql -h localhost -p 63333 postgres

  28. 5. Event Triggers

  29. Event Triggers

  30. Auditing Unwanted modification of data Accidental data loss Trigger-based replication Ownership

  31. ddl_command_start ddl_command_end sql_drop table_rewrite in pg10!

  32. 6. Auditing

  33. Storage !

  34. Pg_Audit

  35. Monitoring Roles (PG10 and onwards) Pg_monitor Pg_read_all_settings Pg_read_all_stats Pg_stat_scan_tables

  36. 7. Encryption & PCI

  37. At-Rest pgcrypto - AES-128, AES-192, or AES-256 - Performance impact Backups Volumes instance-level - 3rd party patch! https://www.postgresql.org/message-id/CA%2BCSw_tb3bk5i7if6inZFc3yyf%2B9HEVNTy51QFBoeUk7UE_V%3Dw@mail.gmail.com

  38. Shared_preload_libraries = ‘pg_stat_statements’

  39. Monitors

  40. Key Management Key Storage Location Encryption/Decryption Location Encrypted query processing

  41. 8. Replication

  42. Binary Replication READ-ONLY Replicas Orchestrators Chef Data Bags ● Ansible Vault ● Recovery File

  43. Logical Replication Create publication CREATE privilege Add tables table owner Add all tables superuser Create subscription superuser Subscriptions apply process

  44. 9. Procedural Languages

  45. Trusted VS Untrusted Security Definer LEAKPROOF

  46. Upcoming Features in PG11 SCRAM-SHA-256-Plus - Channel Binding SASL mechanism - Mutual Authentication - tls-unique - tls-server-end-point PG_TEST_EXTRA - More authentication type tests Large object ACL permissions

  47. Desired Features Data Redaction Oracle TDE - key management http://www.oracle.com/technetwork/database/security/twp-transparent-data-encryption-bes-130696.pdf SHOW GRANTS

  48. Thank You ! Twitter: @postgres_women Slack: #pgsql-women

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend