SlideShare a Scribd company logo
1 of 50
Securing Data in Postgres
Payal Singh
@pallureshu
OmniTI Computer Consulting
https://omniti.com 1
Agenda
Host Based Authentication
Access Control Lists
Row-Level Security
SSL/TLS
Auditing
Encryption
PCI Compliance
Upcoming Features in pg10
Desired Features
2
Host Based Authentication
3
HBA
Host Based Authentication
4
HBA
Reloading authentication changes - pg_reload_conf()
5
HBA
Monitoring authentication - tail_n_mail
[1] (from line 262,856)
2017-05-30 17:35:39 EDT [[local]] [13667]: [2-1] user=marion,db=postgres,
e=28P01 FATAL: password authentication failed for user "marion" e=28P01
DETAIL: Connection matched pg_hba.conf line 18: "local all all md5"
6
HBA
Password file - .pgpass in $HOME
postgres@thinkpad ~ $ whoami
postgres
postgres@thinkpad ~ $ pwd
/home/postgres
postgres@thinkpad~ $ ls -l .pgpass
-rw------- 1 postgres postgres 29 Jul 9 11:23 .pgpass
postgres@thinkpad ~ $ cat .pgpass
*:*:*:postgres:HuyYheDAfqVq7
7
Access Control Lists
8
ACL
Access Control List
“list of permissions attached to an object. An ACL specifies which users or system processes are granted access to
objects, as well as what operations are allowed on given objects.”
GRANT - define access privileges
REVOKE - revoke access privileges
https://www.postgresql.org/docs/current/static/sql-grant.html
9
ACL
10
ACL
ACL commands are transactional in Postgres:
11
ACL
Not so much in MySQL:
12
ACL
Passwords In MySQL:
Passwords In Postgres:
13
ACL
SHOW GRANTS in MySQL
14
ACL
Roles and role membership
A role has privileges of all roles it is a member of
15
ACL
SET DEFAULT PRIVILEGES
ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name> GRANT <privilege> ON TABLES TO <role>;
Only applies to objects created in future
16
ACL
USAGE:
Roles must have usage on schema to access tables, functions
Usage on public schema granted by default to public role
Usage granted by default on all roles in MySQL
17
ACL - USAGE Example
18
Column Level ACLs
Grant privileges only on specific column(s)
NOTE: UPDATE privilege in practice requires SELECT as well
19
Row-Level Security
20
RLS
User-based or command-based row level access restrictions
Disabled by default
Exceptions - TRUNCATE, REFERENCES
Not a SQL Standard
Watch for performance improvements in pg10!
21
RLS
When enabled, all traffic goes through policies
22
RLS
Default Policy - all deny
23
RLS
Does not apply to table owner unless forced
BYPASSRLS attribute
24
RLS
In case of multiple policies, access is determined if any one or more of the policies
allow it (OR)
Referential integrity checks - covert channel leaks should be avoided
Race conditions - e.g. SELECT … FOR UPDATE
Solutions - SELECT … FOR SHARE; Exclusive locks on referenced
table
25
SSL/TLS
26
SSL/TLS
ssl = on # (change requires restart)
#ssl_ciphers = 'ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH' # allowed SSL ciphers
#ssl_prefer_server_ciphers = on # (change requires restart)
#ssl_ecdh_curve = 'prime256v1' # (change requires restart)
ssl_cert_file = '/etc/ssl/postgres/starry.io.crt' # (change requires restart)
ssl_key_file = '/etc/ssl/postgres/starry.io.key' # (change requires restart)
ssl_ca_file = '' # (change requires restart)
#ssl_crl_file = '' # (change requires restart)
27
SSL/TLS
Requirement: OpenSSL
At build time: --with-openssl
Authentication without encryption overhead: NULL-SHA or NULL-MD5
Not recommended: less secure
Overhead is minimal compared to authentication overhead
Certificate file permissions must be 600
Restart required for certs change
28
Event Triggers
29
Event Triggers
Database wide DDL event capture
Useful for:
Auditing
Unwanted modification of data
Accidental data loss
Trigger-based replication
http://tapoueh.org/images/confs/Fosdem2013_Event_Triggers.pdf
30
Event Triggers
31
Event Triggers
32
Event Triggers
Events:
ddl_command_start
ddl_command_end
sql_drop
table_rewrite in pg10!
33
Auditing
34
Auditing
Trigger based diff tracking
35
Auditing
Hstore - delta capture
36
Auditing
Delta function:
GIST and GIN index support for most operations
BTree and Hash index support useful for equivalence operations
37
Auditing
pgAudit extension
38
Auditing
PgAudit:
Shared_preload_libraries
Postgres development packages
Installation is a bit weird
39
Encryption and PCI Compliance
40
Encryption
pg_crypto extension - encrypts data
Encrypted backups
Postgres instance-level Encryption - 3rd party patch!
https://www.postgresql.org/message-
id/CA%2BCSw_tb3bk5i7if6inZFc3yyf%2B9HEVNTy51QFBoeUk7UE_V%3Dw@mail.gmail.com
http://www.cybertec.at/postgresql-instance-level-encryption/
SSL/TLS
41
PCI Compliance
pg_stat_statements extension
42
PCI Compliance
Monitors
43
PCI Compliance
Monitored queries:
44
PCI Compliance
pg_crypto
Key management
45
Upcoming Features in PG10
46
Upcoming
SSL - reload instead of a restart
SCRAM-SHA-256 authentication
Restrictive RLS Policies (AND)
New monitoring roles:
pg_monitor, pg_read_all_settings, pg_read_all_stats, and pg_stat_scan_tables
pg_hba_file_rules view
47
Desired Features
48
Desired
Data Redaction
Active Directory support
Oracle TDE - key management
http://www.oracle.com/technetwork/database/security/twp-transparent-data-encryption-bes-130696.pdf
SHOW GRANTS
49
Thank you!
Questions?
50
Twitter: @pallureshu
Email: payal@omniti.com

More Related Content

What's hot

PGEncryption_Tutorial
PGEncryption_TutorialPGEncryption_Tutorial
PGEncryption_Tutorial
Vibhor Kumar
 
Configure Proxy and Firewall (Iptables)
Configure Proxy and Firewall (Iptables)Configure Proxy and Firewall (Iptables)
Configure Proxy and Firewall (Iptables)
Tola LENG
 
Presentation netwok year 3
Presentation netwok year 3Presentation netwok year 3
Presentation netwok year 3
sroeurnsophai
 
Configuring cisco site to site ip sec vpn with dynamic ip endpoint cisco routers
Configuring cisco site to site ip sec vpn with dynamic ip endpoint cisco routersConfiguring cisco site to site ip sec vpn with dynamic ip endpoint cisco routers
Configuring cisco site to site ip sec vpn with dynamic ip endpoint cisco routers
phosika sithisane
 

What's hot (19)

PGEncryption_Tutorial
PGEncryption_TutorialPGEncryption_Tutorial
PGEncryption_Tutorial
 
MRA AMA Part 10: Kubernetes and the Microservices Reference Architecture
MRA AMA Part 10: Kubernetes and the Microservices Reference ArchitectureMRA AMA Part 10: Kubernetes and the Microservices Reference Architecture
MRA AMA Part 10: Kubernetes and the Microservices Reference Architecture
 
Configure Proxy and Firewall (Iptables)
Configure Proxy and Firewall (Iptables)Configure Proxy and Firewall (Iptables)
Configure Proxy and Firewall (Iptables)
 
What’s New in NGINX Plus R15?
What’s New in NGINX Plus R15?What’s New in NGINX Plus R15?
What’s New in NGINX Plus R15?
 
Open vpn server_linux
Open vpn server_linuxOpen vpn server_linux
Open vpn server_linux
 
Gns3moi
Gns3moiGns3moi
Gns3moi
 
Baking even more Clam(AV)s for Fun & Profit.
Baking even more Clam(AV)s for Fun & Profit.Baking even more Clam(AV)s for Fun & Profit.
Baking even more Clam(AV)s for Fun & Profit.
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2
 
Certificate Management on pfSense 2.4 - pfSense Hangout September 2017
Certificate Management on pfSense 2.4 - pfSense Hangout September 2017Certificate Management on pfSense 2.4 - pfSense Hangout September 2017
Certificate Management on pfSense 2.4 - pfSense Hangout September 2017
 
Squid
SquidSquid
Squid
 
Local DNS with pfSense 2.4 - pfSense Hangout April 2018
Local DNS with pfSense 2.4 - pfSense Hangout April 2018Local DNS with pfSense 2.4 - pfSense Hangout April 2018
Local DNS with pfSense 2.4 - pfSense Hangout April 2018
 
Presentation netwok year 3
Presentation netwok year 3Presentation netwok year 3
Presentation netwok year 3
 
Proxy SQL 2.0 with PXC
Proxy SQL 2.0 with PXCProxy SQL 2.0 with PXC
Proxy SQL 2.0 with PXC
 
HTTPS @Scale
HTTPS @ScaleHTTPS @Scale
HTTPS @Scale
 
Configuring cisco site to site ip sec vpn with dynamic ip endpoint cisco routers
Configuring cisco site to site ip sec vpn with dynamic ip endpoint cisco routersConfiguring cisco site to site ip sec vpn with dynamic ip endpoint cisco routers
Configuring cisco site to site ip sec vpn with dynamic ip endpoint cisco routers
 
Configure Webserver & SSL secure & redirect in SuSE Linux Enterprise
Configure Webserver & SSL secure & redirect in SuSE Linux EnterpriseConfigure Webserver & SSL secure & redirect in SuSE Linux Enterprise
Configure Webserver & SSL secure & redirect in SuSE Linux Enterprise
 
Ad, dns, dhcp, file server
Ad, dns, dhcp, file serverAd, dns, dhcp, file server
Ad, dns, dhcp, file server
 
EvasionTechniques
EvasionTechniquesEvasionTechniques
EvasionTechniques
 
RADIUS and LDAP on pfSense 2.4 - pfSense Hangout February 2018
RADIUS and LDAP on pfSense 2.4 - pfSense Hangout February 2018RADIUS and LDAP on pfSense 2.4 - pfSense Hangout February 2018
RADIUS and LDAP on pfSense 2.4 - pfSense Hangout February 2018
 

Similar to postgres_data_security_2017

Packet Inspection on ASA
Packet Inspection on ASAPacket Inspection on ASA
Packet Inspection on ASA
Pratik Bhide
 
At8000 s configurando_aaa
At8000 s configurando_aaaAt8000 s configurando_aaa
At8000 s configurando_aaa
NetPlus
 

Similar to postgres_data_security_2017 (20)

How to Bulletproof Your Scylla Deployment
How to Bulletproof Your Scylla DeploymentHow to Bulletproof Your Scylla Deployment
How to Bulletproof Your Scylla Deployment
 
PostgresOpen 2013 A Comparison of PostgreSQL Encryption Options
PostgresOpen 2013 A Comparison of PostgreSQL Encryption OptionsPostgresOpen 2013 A Comparison of PostgreSQL Encryption Options
PostgresOpen 2013 A Comparison of PostgreSQL Encryption Options
 
Postgre sql unleashed
Postgre sql unleashedPostgre sql unleashed
Postgre sql unleashed
 
DockerCon Live 2020 - Securing Your Containerized Application with NGINX
DockerCon Live 2020 - Securing Your Containerized Application with NGINXDockerCon Live 2020 - Securing Your Containerized Application with NGINX
DockerCon Live 2020 - Securing Your Containerized Application with NGINX
 
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
 
Hashicorp Vault: Open Source Secrets Management at #OPEN18
Hashicorp Vault: Open Source Secrets Management at #OPEN18Hashicorp Vault: Open Source Secrets Management at #OPEN18
Hashicorp Vault: Open Source Secrets Management at #OPEN18
 
Securing your MySQL / MariaDB Server data
Securing your MySQL / MariaDB Server dataSecuring your MySQL / MariaDB Server data
Securing your MySQL / MariaDB Server data
 
Using Vault to decouple MySQL Secrets
Using Vault to decouple MySQL SecretsUsing Vault to decouple MySQL Secrets
Using Vault to decouple MySQL Secrets
 
Postgresql 12 streaming replication hol
Postgresql 12 streaming replication holPostgresql 12 streaming replication hol
Postgresql 12 streaming replication hol
 
Packet Inspection on ASA
Packet Inspection on ASAPacket Inspection on ASA
Packet Inspection on ASA
 
Percona Live 2019 - MySQL Security
Percona Live 2019 - MySQL SecurityPercona Live 2019 - MySQL Security
Percona Live 2019 - MySQL Security
 
Securing PostgreSQL from External Attack
Securing PostgreSQL from External AttackSecuring PostgreSQL from External Attack
Securing PostgreSQL from External Attack
 
Enhancing MySQL Security
Enhancing MySQL SecurityEnhancing MySQL Security
Enhancing MySQL Security
 
PostgreSQL: Welcome To Total Security
PostgreSQL: Welcome To Total SecurityPostgreSQL: Welcome To Total Security
PostgreSQL: Welcome To Total Security
 
How to Manage Scale-Out Environments with MariaDB MaxScale
How to Manage Scale-Out Environments with MariaDB MaxScaleHow to Manage Scale-Out Environments with MariaDB MaxScale
How to Manage Scale-Out Environments with MariaDB MaxScale
 
Dynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency PlanningDynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency Planning
 
At8000 s configurando_aaa
At8000 s configurando_aaaAt8000 s configurando_aaa
At8000 s configurando_aaa
 
NGINX Plus R20 Webinar
NGINX Plus R20 WebinarNGINX Plus R20 Webinar
NGINX Plus R20 Webinar
 
Upgrade ipa to rhel 7
Upgrade ipa to rhel 7Upgrade ipa to rhel 7
Upgrade ipa to rhel 7
 
Hacking the swisscom modem
Hacking the swisscom modemHacking the swisscom modem
Hacking the swisscom modem
 

Recently uploaded

“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
Muhammad Subhan
 

Recently uploaded (20)

JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 

postgres_data_security_2017