]> begriffs open source - ai-pg/blob - full-docs/html/preventing-server-spoofing.html
Include latest toc output
[ai-pg] / full-docs / html / preventing-server-spoofing.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>18.7. Preventing Server Spoofing</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="upgrading.html" title="18.6. Upgrading a PostgreSQL Cluster" /><link rel="next" href="encryption-options.html" title="18.8. Encryption Options" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">18.7. Preventing Server Spoofing</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="upgrading.html" title="18.6. Upgrading a PostgreSQL Cluster">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="runtime.html" title="Chapter 18. Server Setup and Operation">Up</a></td><th width="60%" align="center">Chapter 18. Server Setup and Operation</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="encryption-options.html" title="18.8. Encryption Options">Next</a></td></tr></table><hr /></div><div class="sect1" id="PREVENTING-SERVER-SPOOFING"><div class="titlepage"><div><div><h2 class="title" style="clear: both">18.7. Preventing Server Spoofing <a href="#PREVENTING-SERVER-SPOOFING" class="id_link">#</a></h2></div></div></div><a id="id-1.6.5.10.2" class="indexterm"></a><p>
3    While the server is running, it is not possible for a malicious user
4    to take the place of the normal database server.  However, when the
5    server is down, it is possible for a local user to spoof the normal
6    server by starting their own server.  The spoof server could read
7    passwords and queries sent by clients, but could not return any data
8    because the <code class="varname">PGDATA</code> directory would still be secure because
9    of directory permissions. Spoofing is possible because any user can
10    start a database server; a client cannot identify an invalid server
11    unless it is specially configured.
12   </p><p>
13    One way to prevent spoofing of <code class="literal">local</code>
14    connections is to use a Unix domain socket directory (<a class="xref" href="runtime-config-connection.html#GUC-UNIX-SOCKET-DIRECTORIES">unix_socket_directories</a>) that has write permission only
15    for a trusted local user.  This prevents a malicious user from creating
16    their own socket file in that directory.  If you are concerned that
17    some applications might still reference <code class="filename">/tmp</code> for the
18    socket file and hence be vulnerable to spoofing, during operating system
19    startup create a symbolic link <code class="filename">/tmp/.s.PGSQL.5432</code> that points
20    to the relocated socket file.  You also might need to modify your
21    <code class="filename">/tmp</code> cleanup script to prevent removal of the symbolic link.
22   </p><p>
23    Another option for <code class="literal">local</code> connections is for clients to use
24    <a class="link" href="libpq-connect.html#LIBPQ-CONNECT-REQUIREPEER"><code class="literal">requirepeer</code></a>
25    to specify the required owner of the server process connected to
26    the socket.
27   </p><p>
28    To prevent spoofing on TCP connections, either use
29    SSL certificates and make sure that clients check the server's certificate,
30    or use GSSAPI encryption (or both, if they're on separate connections).
31   </p><p>
32    To prevent spoofing with SSL, the server
33    must be configured to accept only <code class="literal">hostssl</code> connections (<a class="xref" href="auth-pg-hba-conf.html" title="20.1. The pg_hba.conf File">Section 20.1</a>) and have SSL key and certificate files
34    (<a class="xref" href="ssl-tcp.html" title="18.9. Secure TCP/IP Connections with SSL">Section 18.9</a>). The TCP client must connect using
35    <code class="literal">sslmode=verify-ca</code> or
36    <code class="literal">verify-full</code> and have the appropriate root certificate
37    file installed (<a class="xref" href="libpq-ssl.html#LIBQ-SSL-CERTIFICATES" title="32.19.1. Client Verification of Server Certificates">Section 32.19.1</a>). Alternatively the
38    <a class="link" href="libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT">system CA pool</a>, as defined
39    by the SSL implementation, can be used using <code class="literal">sslrootcert=system</code>; in
40    this case, <code class="literal">sslmode=verify-full</code> is forced for safety, since
41    it is generally trivial to obtain certificates which are signed by a public
42    CA.
43   </p><p>
44    To prevent server spoofing from occurring when using
45    <a class="link" href="auth-password.html" title="20.5. Password Authentication">scram-sha-256</a> password authentication
46    over a network, you should ensure that you connect to the server using SSL
47    and with one of the anti-spoofing methods described in the previous
48    paragraph. Additionally, the SCRAM implementation in
49    <span class="application">libpq</span> cannot protect the entire authentication
50    exchange, but using the <code class="literal">channel_binding=require</code> connection
51    parameter provides a mitigation against server spoofing. An attacker that
52    uses a rogue server to intercept a SCRAM exchange can use offline analysis to
53    potentially determine the hashed password from the client.
54   </p><p>
55     To prevent spoofing with GSSAPI, the server must be configured to accept
56     only <code class="literal">hostgssenc</code> connections
57     (<a class="xref" href="auth-pg-hba-conf.html" title="20.1. The pg_hba.conf File">Section 20.1</a>) and use <code class="literal">gss</code>
58     authentication with them.  The TCP client must connect
59     using <code class="literal">gssencmode=require</code>.
60   </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="upgrading.html" title="18.6. Upgrading a PostgreSQL Cluster">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="runtime.html" title="Chapter 18. Server Setup and Operation">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="encryption-options.html" title="18.8. Encryption Options">Next</a></td></tr><tr><td width="40%" align="left" valign="top">18.6. Upgrading a <span class="productname">PostgreSQL</span> Cluster </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 18.8. Encryption Options</td></tr></table></div></body></html>