<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Dmitrii Bezrukov</title>
    <description>The latest articles on Forem by Dmitrii Bezrukov (@boomeer).</description>
    <link>https://forem.com/boomeer</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1056114%2F2d382330-88a6-464e-8f5f-e9a777a198f4.jpg</url>
      <title>Forem: Dmitrii Bezrukov</title>
      <link>https://forem.com/boomeer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/boomeer"/>
    <language>en</language>
    <item>
      <title>Boosting Greenplum security</title>
      <dc:creator>Dmitrii Bezrukov</dc:creator>
      <pubDate>Fri, 31 Mar 2023 10:32:07 +0000</pubDate>
      <link>https://forem.com/boomeer/greenplums-giggly-glitch-5197</link>
      <guid>https://forem.com/boomeer/greenplums-giggly-glitch-5197</guid>
      <description>&lt;h2&gt;
  
  
  Meet Greenplum
&lt;/h2&gt;

&lt;p&gt;Greenplum, our advanced, open-source data warehouse pal, is a cousin of the PostgreSQL database project. It's got a knack for large-scale analytics and big data processing, thanks to its MPP (Massively Parallel Processing) architecture. Greenplum hustles, distributing data and queries across multiple nodes for top-notch performance and scalability.&lt;/p&gt;




&lt;h2&gt;
  
  
  Greenplum's Comical Confession
&lt;/h2&gt;

&lt;p&gt;Greenplum has a little secret: the &lt;code&gt;pg_hba.conf&lt;/code&gt; file. This undercover file controls client authentication and hangs out in the master data directory, usually placing at &lt;code&gt;$MASTER_DATA_DIRECTORY/pg_hba.conf&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Base &lt;code&gt;pg_hba.conf&lt;/code&gt; from opensource installation looks something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;host     all         gpadmin         10.130.2.230/32       trust
host     all         gpadmin         10.130.2.227/32       trust
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Groovy, right? But wait, there's a twist! &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Just hop on over to the &lt;code&gt;master/standby&lt;/code&gt; host;
&lt;/li&gt;
&lt;li&gt;An just execute the command&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;/usr/local/greenplum-db/bin/psql -d ${db_name} -U gpadmin -h ${master_address}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Voilà!&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;You're now an all-powerful admin with the keys to the kingdom.&lt;/strong&gt;&lt;br&gt;
Connect to any database, access or delete data, and reconfigure the base as you please.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhrmns27jdfc0b7q0dx1w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhrmns27jdfc0b7q0dx1w.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  How to fix?
&lt;/h2&gt;

&lt;p&gt;To fix the potential security issue in the &lt;code&gt;pg_hba.conf&lt;/code&gt; file of your Greenplum installation, you should update the authentication settings to enforce stricter access control. Here are some recommendations to improve the security of your Greenplum database:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; &lt;strong&gt;Restrict IP addresses&lt;/strong&gt;: Limit the IP addresses allowed to connect to your Greenplum cluster. Be specific about the IP addresses or ranges you want to grant access. For example, you can allow only certain subnets or individual IP addresses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;host    all    gpadmin    192.168.1.0/24    md5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example allows only connections from the &lt;code&gt;192.168.1.0/24&lt;/code&gt; subnet using the &lt;code&gt;md5&lt;/code&gt; password authentication method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; &lt;strong&gt;Use strong authentication methods&lt;/strong&gt;: Instead of using the trust method, which allows connections without a password, use a more secure authentication method like &lt;code&gt;md5&lt;/code&gt;, &lt;code&gt;scram-sha-256&lt;/code&gt;, or integrate with an external authentication provider such as LDAP, Kerberos, or others. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;host    all    gpadmin    192.168.1.0/24    scram-sha-256
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; &lt;strong&gt;Limit user access&lt;/strong&gt;: Configure the &lt;code&gt;pg_hba.conf&lt;/code&gt; file to allow access only to specific users or groups, rather than granting access to all users. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;host    mydatabase    myuser    192.168.1.0/24    md5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example allows only the &lt;code&gt;myuser&lt;/code&gt; to connect to the &lt;code&gt;mydatabase&lt;/code&gt; from the specified IP range using the &lt;code&gt;md5&lt;/code&gt; password authentication method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.&lt;/strong&gt; &lt;strong&gt;Use separate roles for different tasks&lt;/strong&gt;: Avoid using the &lt;code&gt;gpadmin&lt;/code&gt; superuser account for everyday tasks. Instead, create separate roles with the least privileges necessary for each task.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.&lt;/strong&gt; &lt;strong&gt;Regularly review and update your configuration&lt;/strong&gt;: Periodically review your &lt;code&gt;pg_hba.conf&lt;/code&gt; file and other security settings to ensure they are up-to-date and follow best practices.&lt;/p&gt;

&lt;h2&gt;
  
  
  How can we put our trust in this configuration?
&lt;/h2&gt;

&lt;p&gt;After updating the &lt;code&gt;pg_hba.conf&lt;/code&gt; file, make sure to reload the Greenplum configuration for the changes to take effect. You can do this by running the following command as the &lt;code&gt;gpadmin&lt;/code&gt; user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpstop -u
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will perform a &lt;em&gt;"soft"&lt;/em&gt; restart, reloading the configuration without stopping the database.&lt;/p&gt;

</description>
      <category>greenplum</category>
      <category>database</category>
      <category>security</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
