Securing
Securing
1 / 32
Attack Vectors
https://www.flickr.com/photos/twalmsley/
2 / 32
External Attack Vectors
• ’Trust’ security
• Passwords / authentication theft
• Network snooping
• Network pass-through spoofing
• Server / backup theft
• Administrator access
3 / 32
Internal Attack Vectors
(Not Covered)
4 / 32
Authentication Security
https://www.flickr.com/photos/brookward/
5 / 32
Avoid “Trust” Security in pg_hba.conf
6 / 32
Password Snooping
md5(password+username)
md5(password+username)
md5(password+username)
md5(password+username)
7 / 32
MD5 Authentication
Prevents Password Snooping
md5(password+username)
md5(password+username)
md5(password+username)
md5(password+username)
8 / 32
MD5 Authentication
Prevents Password Replay
md5(password+username)
Connection request md5(password+username)
Malicious md5(password+username)
Database Need md5, sent random salt1 md5(password+username)
Client
md5(md5(password+username) + salt0) X
replay
9 / 32
SCRAM Authentication
10 / 32
SCRAM-SHA-256 Authentication
Connection request
PostgreSQL
Need scram−sha−256
Database Username, client nonce Database
Client
Client nonce, server nonce, salt Server
Client nonce, server nonce, client proof
sha256(password+salt)
sha256(password+salt)
sha256(password+salt)
sha256(password+salt)
https://en.wikipedia.org/wiki/Salted_Challenge_Response_Authentication_Mechanism
11 / 32
Password Attacks
• Weak passwords
• Reuse of old passwords
• Brute-force password attacks
None of these vulnerabilities is prevented by Postgres directly, but
external authentication methods, like LDAP, PAM, and SSPI, can
prevent them. Some authentication methods are difficult to use with
connection pooling.
12 / 32
Queries and Data Still
Vulnerable to Network Snooping
13 / 32
SSL Prevents Snooping
By Encrypting Queries and Data
14 / 32
Preventing Spoofing
https://www.flickr.com/photos/tomhickmore/
15 / 32
Localhost Spoofing
While the Database Server Is Down
16 / 32
Network Spoofing
17 / 32
Network Spoofing Pass-Through
Result
18 / 32
SSL ’Prefer’ Is Not Secure
SSL or
Non−SSL
Result
19 / 32
SSL ’Require’ Is Not Secure
From Spoofing
SSL or
Non−SSL
Result
20 / 32
SSL ’Verify-CA’ Is Secure
From Spoofing
server.crt
21 / 32
Channel Binding
server.crt
Certificates are sent to peers as part of the TLS handshake. Later the certificate hash
is hashed with the password hash to prove the TLS peer knows the password hash.
This is tls−server−end−point channel binding.
22 / 32
SSL Certificates for Authentication
server.crt
23 / 32
Data Encryption
To Avoid Data Theft
https://www.flickr.com/photos/debarshiray/
24 / 32
Disk Volume Encryption
This helps prevent stolen storage devices from being read, and helps
with secure media destruction. https://www.flickr.com/photos/icebrkr/
25 / 32
Column Encryption
id | name | credit_card_number
--------+--------------------+------------------------------
428914 | Piller Plaster Co. | \xc30d04070302254dc045353f28
; 456cd241013e2d421e198f3320e8
; 41a7e4f751ebd9e2938cb6932390
; 5c339c02b5a8580663d6249eb24f
; 192e226c1647dc02536eb6a79a65
; 3f3ed455ffc5726ca2b67430d5
Encryption methods are decryptable (e.g., AES), while hashes are
one-way (e.g., MD5). A one-way hash is best for data like passwords
that only need to be checked for a match, rather than decrypted.
26 / 32
Where to Store the Key?
On the Server
key
27 / 32
Store the Key on an
Intermediate Server
key
28 / 32
Store the Key on the Client and
Encrypt/Decrypt on the Server
29 / 32
Encrypt/Decrypt on the Client
30 / 32
Store the Key on a
Client Hardware Token
31 / 32
Conclusion
https://momjian.us/presentations https://www.flickr.com/photos/stevensnodgrass/
32 / 32