PostgreSQL Default Unpassworded Account - Nessus

High   Plugin ID: 10483

This page contains detailed information about the PostgreSQL Default Unpassworded Account Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 10483
Name: PostgreSQL Default Unpassworded Account
Filename: postgresql_unpassworded.nasl
Vulnerability Published: 1999-07-17
This Plugin Published: 2000-07-27
Last Modification Time: 2022-04-11
Plugin Version: 1.25
Plugin Type: remote
Plugin Family: Databases
Dependencies: postgresql_detect.nasl

Vulnerability Information


Severity: High
Vulnerability Published: 1999-07-17
Patch Published: N/A
CVE [?]: CVE-1999-0508
CPE [?]: cpe:/a:postgresql:postgresql
Default Account Vulnerability: True

Synopsis

The remote database server can be accessed without a password.

Description

It is possible to connect to the remote PostgreSQL database server using an unpassworded account. This may allow an attacker to launch further attacks against the database.

Solution

Log into this host and set a password for any affected accounts using the 'ALTER USER' command.

In addition, configure the service by editing the file 'pg_hba.conf' to require a password (or Kerberos) authentication for all remote hosts that have legitimate access to this service and to require a password locally using the line 'local all password'.

Public Exploits


Target Network Port(s): 5432
Target Asset(s): Services/postgresql
Exploit Available: True (Metasploit Framework)
Exploit Ease: Exploits are available

Here's the list of publicly known exploits and PoCs for verifying the PostgreSQL Default Unpassworded Account vulnerability:

  1. Metasploit: auxiliary/scanner/snmp/snmp_login
    [SNMP Community Scanner]
  2. Metasploit: auxiliary/scanner/snmp/snmp_login
    [SNMP Community Login Scanner]

Before running any exploit against any system, make sure you are authorized by the owner of the target system(s) to perform such activity. In any other case, this would be considered as an illegal activity.

Risk Information


CVSS V2 Vector [?]: AV:N/AC:L/Au:N/C:P/I:P/A:P
CVSS Base Score:7.5 (High)
Impact Subscore:6.4
Exploitability Subscore:10.0
CVSS Temporal Score:NA (None)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:7.5 (High)

Go back to menu.

Plugin Source


This is the postgresql_unpassworded.nasl nessus plugin source code. This script is Copyright (C) 2000-2022 Tenable Network Security, Inc.

#%NASL_MIN_LEVEL 70300
#
# (C) Tenable Network Security, Inc.
#

include('deprecated_nasl_level.inc');
include('compat.inc');

if (description)
{
  script_id(10483);
  script_version("1.25");
  script_set_attribute(attribute:"plugin_modification_date", value:"2022/04/11");

  script_cve_id("CVE-1999-0508");

  script_name(english:"PostgreSQL Default Unpassworded Account");

  script_set_attribute(attribute:"synopsis", value:
"The remote database server can be accessed without a password.");
  script_set_attribute(attribute:"description", value:
"It is possible to connect to the remote PostgreSQL database server
using an unpassworded account. This may allow an attacker to launch
further attacks against the database.");
  script_set_attribute(attribute:"solution", value:
"Log into this host and set a password for any affected accounts using
the 'ALTER USER' command.

In addition, configure the service by editing the file 'pg_hba.conf'
to require a password (or Kerberos) authentication for all remote
hosts that have legitimate access to this service and to require a
password locally using the line 'local all password'.");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:P/I:P/A:P");

  script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
  script_set_attribute(attribute:"exploit_available", value:"true");
  script_set_attribute(attribute:"exploited_by_nessus", value:"true");
  script_set_attribute(attribute:"metasploit_name", value:'SNMP Community Scanner');
  script_set_attribute(attribute:"exploit_framework_metasploit", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"1999/07/17");
  script_set_attribute(attribute:"plugin_publication_date", value:"2000/07/27");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:postgresql:postgresql");
  script_set_attribute(attribute:"default_account", value:"true");
  script_set_attribute(attribute:"thorough_tests", value:"true");
  script_end_attributes();

  script_category(ACT_GATHER_INFO);
  script_family(english:"Databases");

  script_copyright(english:"This script is Copyright (C) 2000-2022 Tenable Network Security, Inc.");

  script_dependencies("postgresql_detect.nasl");
  script_require_ports("Services/postgresql", 5432);

  exit(0);
}

include("audit.inc");
include("global_settings.inc");
include("misc_func.inc");

port = get_service(svc:"postgresql", default:5432, exit_on_fail:TRUE);

#
# Request the database 'template1' as the user 'postgres' or 'pgsql'
#
zero = raw_string(0x00);

user[0] = "postgres";
user[1] = "pgsql";

for(i=0;i<2;i=i+1)
{
 soc = open_sock_tcp(port);
 if (!soc) audit(AUDIT_PORT_CLOSED, port);

 usr = user[i];
 len = 224 - strlen(usr);

 req = raw_string(0x00, 0x00, 0x01, 0x28, 0x00, 0x02,
    	         0x00, 0x00, 0x74, 0x65, 0x6D, 0x70, 0x6C, 0x61,
		 0x74, 0x65, 0x31) + crap(data:zero, length:55) +
        usr +
       crap(data:zero, length:len);


 send(socket:soc, data:req);
 r = recv(socket:soc, length:5);
 r2 = recv(socket:soc, length:1024);

 if((r[0]=="R") && (strlen(r2) == 10))
  {
    dbs = "";
    req = raw_string(0x51) + "select * from pg_database;" +
    	  raw_string(0x00);
    send(socket:soc, data:req);

    r = recv(socket:soc, length:65535);
    #display(r);
    close(soc);
    skip = 87;
    ok = 1;
    while(ok)
    {
     db = "";

     len = ord(r[skip]);
     len_r = strlen(r);
     lenskip = len + skip;

     if(lenskip > len_r)ok = 0;
     else
     {
      len = ord(r[skip]) - 4;
      for(i=0;i<len;i=i+1)
       db = db + r[skip+i+1];

      dbs = dbs + ". " + db + string("\n");
      skip = skip + len + 21 + len;
      if(skip > strlen(r))ok=0;
     }
   }

    report = string(
      "\n",
      "Nessus was able to log in as the user '", usr, "'.\n",
      "\n",
      "Here is the list of the databases on the remote host :\n",
      "\n",
      dbs, "\n"
    );
    security_hole(port:port, extra:report);
    set_kb_item(name: 'postgresql/no_pass/'+port, value: TRUE);
    exit(0);
  }
  close(soc);
}

The latest version of this script can be found in these locations depending on your platform:

  • Linux / Unix:
    /opt/nessus/lib/nessus/plugins/postgresql_unpassworded.nasl
  • Windows:
    C:\ProgramData\Tenable\Nessus\nessus\plugins\postgresql_unpassworded.nasl
  • Mac OS X:
    /Library/Nessus/run/lib/nessus/plugins/postgresql_unpassworded.nasl

Go back to menu.

How to Run


Here is how to run the PostgreSQL Default Unpassworded Account as a standalone plugin via the Nessus web user interface (https://localhost:8834/):

  1. Click to start a New Scan.
  2. Select Advanced Scan.
  3. Navigate to the Plugins tab.
  4. On the top right corner click to Disable All plugins.
  5. On the left side table select Databases plugin family.
  6. On the right side table select PostgreSQL Default Unpassworded Account plugin ID 10483.
  7. Specify the target on the Settings tab and click to Save the scan.
  8. Run the scan.

Here are a few examples of how to run the plugin in the command line. Note that the examples below demonstrate the usage on the Linux / Unix platform.

Basic usage:

/opt/nessus/bin/nasl postgresql_unpassworded.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

/opt/nessus/bin/nasl -a postgresql_unpassworded.nasl -t <IP/HOST>

Run the plugin with trace script execution written to the console (useful for debugging):

/opt/nessus/bin/nasl -T - postgresql_unpassworded.nasl -t <IP/HOST>

Run the plugin with using a state file for the target and updating it (useful for running multiple plugins on the target):

/opt/nessus/bin/nasl -K /tmp/state postgresql_unpassworded.nasl -t <IP/HOST>

Go back to menu.

References


See also: Similar and related Nessus plugins:
  • 10747 - 3Com Superstack 3 Switch Multiple Default Accounts
  • 18415 - Bay Networks Accelar 1200 Switch Default Password (password) for 'usrname' Account
  • 18414 - Allied Telesyn Router/Switch Default Password
  • 18413 - Allied Telesyn Router/Switch Web Interface Default Password
  • 17638 - Avaya P330 Stackable Switch Default Password
  • 10961 - AirConnect Default Password
  • 11202 - Enhydra Multiserver Default Password
  • 10820 - F5 Device Default Support Password
  • 10995 - Sun JavaServer Default Admin Password
  • 10998 - Shiva LanRover Blank Password
  • 10999 - Linksys Router Default Password
  • 11203 - Motorola Vanguard with No Password (telnet check)
  • 10798 - Symantec pcAnywhere Service Unrestricted Access
  • 10778 - SiteScope Web Service Unpassworded Access
  • 11004 - Ipswitch WhatsUp Gold Default Admin Account
  • 30213 - MikroTik RouterOS with Blank Password (telnet check)
  • 40354 - OpenWrt Router with a Blank Password (telnet check)
  • 10345 - Cayman DSL Router Unauthenticated Access
  • 10500 - Shiva Integrator Default Password
  • 63353 - PostgreSQL 8.3 < 8.3.19 / 8.4 < 8.4.12 / 9.0 < 9.0.8 / 9.1 < 9.1.4 Multiple Vulnerabilities
  • 63354 - PostgreSQL 8.3 < 8.3.20 / 8.4 < 8.4.13 / 9.0 < 9.0.9 / 9.1 < 9.1.5 Multiple Vulnerabilities
  • 64669 - PostgreSQL 8.3 < 8.3.23 / 8.4 < 8.4.16 / 9.0 < 9.0.12 / 9.1 < 9.1.8 / 9.2 < 9.2.3 Denial of Service
  • 65854 - PostgreSQL 8.4 < 8.4.17 / 9.0 < 9.0.13 / 9.1 < 9.1.9 / 9.2 < 9.2.4 Multiple Vulnerabilities
  • 100260 - PostgreSQL 9.2.x < 9.2.21 / 9.3.x < 9.3.17 / 9.4.x < 9.4.12 / 9.5.x < 9.5.7 / 9.6.x < 9.6.3 Multiple Vulnerabilities
  • 102527 - PostgreSQL 9.2.x < 9.2.22 / 9.3.x < 9.3.18 / 9.4.x < 9.4.13 / 9.5.x < 9.5.8 / 9.6.x < 9.6.4 Multiple Vulnerabilities
  • 107226 - PostgreSQL 9.3.x < 9.3.22 / 9.4.x < 9.4.17 / 9.5.x < 9.5.12 / 9.6.x < 9.6.8 / 10.x < 10.3 Privilege Escalation Vulnerability
  • 127905 - PostgreSQL 9.4.x < 9.4.24 / 9.5.x < 9.5.19 / 9.6.x < 9.6.15 / 10.x < 10.10 / 11.x < 11.5 Multiple Vulnerabilities
  • 148419 - PostgreSQL 11.x < 11.11 / 12.x < 12.6 / 13.x < 13.2 Multiple Vulnerabilities
  • 104031 - PostgreSQL Empty Password Handling Remote Authentication Bypass

Version


This page has been produced using Nessus Professional 10.1.2 (#68) LINUX, Plugin set 202205072148.
Plugin file postgresql_unpassworded.nasl version 1.25. For more plugins, visit the Nessus Plugin Library.

Go back to menu.