• No results found

Securing PostgreSQL From External Attack

N/A
N/A
Protected

Academic year: 2021

Share "Securing PostgreSQL From External Attack"

Copied!
29
0
0

Loading.... (view fulltext now)

Full text

(1)

Securing PostgreSQL

From External Attack

B

RUCE

M

OMJIAN

January, 2012

Database systems are rich with attack vectors to exploit. This

presentation explores the many potential PostgreSQL external

vulnerabilities and shows how they can be secured. Includes

(2)

Attack Vectors

(3)

External Attack Vectors

’Trust’ security

Passwords / authentication theft

Network snooping

Network pass-through spoofing

Server / backup theft

(4)

Internal Attack Vectors

(Not Covered)

Database object permissions

SQL injection attacks

Application vulnerability

Operating system compromise

(5)
(6)

Avoid ’Trust’ Security

# TYPE DATABASE

USER

CIDR-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

trust

# IPv6 local connections:

host

all

all

::1/128

trust

Solution: Use the initdb -A flag, i.e., you don’t want to see this:

WARNING: enabling "trust" authentication for local connections

You can change this by editing pg_hba.conf or using the -A option the

next time you run initdb.

(7)

Password Snooping

Vulnerable to snooping Client PostgreSQL Database Server md5(password+username) md5(password+username) md5(password+username) md5(password+username)

Using ’username’ in the MD5 string prevents the same password used by different users from appearing the same. It also adds some randomness to the md5 checksums.

Connection Request Need Password Password Sent Database

(8)

MD5 Authentication

Prevents Password Snooping

Database PostgreSQL Database Server md5(password+username) md5(password+username) md5(password+username) md5(password+username) connection request need password, sent random salt md5(md5(password+username) + salt) Client

(9)

MD5 Authentication

Prevents Password Replay

X OK Malicious PostgreSQL Database Server md5(password+username) md5(password+username) md5(password+username) md5(password+username) connection request need password, sent random salt0 md5(md5(password+username) + salt0)

connection request need password, sent random salt1 md5(md5(password+username) + salt0) replay Client Database Client Database

salt is a random four-byte integer so millions of connection

(10)

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.

(11)

Queries and Data Still

Vulnerable to Network Snooping

Queries and data vulnerable to snooping Client

PostgreSQL Database

Server Barr Bearings | $10230 | James Akel

SELECT * FROM customers; Database

(12)

SSL Prevents Snooping

By Encrypting Queries and Data

Queries and data encrypted by SSL Client

Database

PostgreSQL Database

Server AES256(Barr Bearings | $10230 | James Akel)

AES256(SELECT * FROM customers);

(13)
(14)

Localhost Spoofing

While the Database Server Is Down

X Client Database Fake PostgreSQL Database Server Connection Request Password Sent

use with the real server Records passwords for later

Need Plain Password

Uses a fake socket or binds to

and 5432 is not a root-only port.) port 5432 while the real server is down. (/tmp is world-writable

The server controls the choice of ’password’ instead of ’md5’.

(15)

Network Spoofing

X Client Database Fake PostgreSQL Database Server Connection Request Password Sent

use with the real server Records passwords for later Need Plain Password

Without SSL ’root’ certificates there is no way to know if the server you are connecting to is a legitimate server.

(16)

Network Spoofing Pass-Through

OK Client Database Database Server PostgreSQL Fake PostgreSQL Database Server

Records passwords for later use with the real server. It can also capture queries, queries. data, and inject its own

Password Sent Connection Request

Without SSL ’root’ certificates there is no way to know if the server you are connecting to is a legitimate server. Need Plain Password

Query Result

Query Result

(17)

SSL ’Prefer’ Is Not Secure

OK Client Database Database Server PostgreSQL Fake PostgreSQL Database Server

Records passwords for later use with the real server. It can also capture queries,

queries. data, and inject its own

Non−SSL

Without SSL ’root’ certificates there is no way to know if the server you are connecting to is a legitimate server. Query Result Query Result Prefer SSL No SSL SSL or Non−SSL

(18)

SSL ’Require’ Is Not Secure

From Spoofing

OK Client Database Database Server PostgreSQL Fake PostgreSQL Database Server

Records passwords for later use with the real server. It can also capture queries,

queries. data, and inject its own

Without SSL ’root’ certificates there is no way to know if the server you are connecting to is a legitimate server. Query Result Query Result SSL or Non−SSL OK SSL SSL Require SSL

(19)

SSL ’Verify-CA’ Is Secure

From Spoofing

server.crt X root.crt Database Fake PostgreSQL Database Server PostgreSQL SSL verify-ca Invalid certificate Server (no CA signature) Client Database

(20)

SSL ’Verify-full’ Is Secure

Even From Some Certificate Thefts

0000000 0000000 1111111 1111111 X root.crt server.crt server.crt Client

Database Invalid certificate

(hostname mismatch) Fake PostgreSQL Database Server Database Server PostgreSQL

Certificate stolen from a CA−trusted computer, server.

but not the database SSL verify−full

(21)

Data Encryption

To Avoid Data Theft

(22)

Disk Volume Encryption

http://www.pclaunches.com/

Securing PostgreSQL, From External Attack 22 / 29

(23)

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.

(24)

Where to Store the Key?

On the Server

Decrypted data key Client Database PostgreSQL Database Server Barr Bearings | $10230 | James Akel

SELECT * FROM customers;

(25)

Store the Key on an

Intermediate Server

key Decrypted Encrypted SELECT SELECT Client Database Cryptographic Server PostgreSQL Database Server

(26)

Store the Key on the Client and

Encrypt/Decrypt on the Server

key Decrypted data Client Database PostgreSQL Database Server Barr Bearings | $10230 | James Akel

SELECT decrypt(col, key) FROM customers;

(27)

Encrypt/Decrypt on the Client

key Encrypted data Client Database PostgreSQL Database Server V#aei32ok3

SELECT * FROM customers;

(28)

Store the Key on a

Client Hardware Token

key Client Encrypted data

Database

PostgreSQL Database

Server V#aei32ok3

SELECT * FROM customers;

This prevents problems caused by client hardware theft.

(29)

References

Related documents

The keystore contains the SSL certificate that the Cisco IPICS server uses to verify its identity when a client attempts to connect to the server, and the URL for the web

In addition, virtual unenhanced CT images, iodine maps, color-coded images superimpos- ing iodine distribution on the virtual nonenhanced data, bone-subtraction images for

We present aspects of preventive self monitoring that emerged from our BP study, related to: the complexity of guidelines for self-measuring, reliability of measurements,

To do this, swipe your card first, then enter your WINDOWS username and password and add money to your account if you wish.. The next time you want to

3.1.1 Installing the PEM Server and ApacheHTTPD on the Same Host The easiest PEM server installation configuration consists of a PEM backend database server (hosted on a

The influence of Japanese kimono on European bustles and their representation in the paintings of the late nineteenth century.. I RIA R OS P IÑEIRO (University of Valencia,

[root@pctcp48 sslca]# /usr/share/ssl/misc/CA -newca CA certificate filename (or enter to create). Making CA

• jdk1.8: Oracle Java 8 environment from OpenNMS respository • postgresql: PostgreSQL database server from distribution repository • postgresql-libs: PostgreSQL database