ImageMagick 7.x < 7.0.2-0 ReadSUNImage() Function SUN Image Handling DoS

2016-06-22T00:00:00
ID IMAGEMAGICK_7_0_2_0.NASL
Type nessus
Reporter This script is Copyright (C) 2016-2018 Tenable Network Security, Inc.
Modified 2020-02-02T00:00:00

Description

The remote Windows host has a version of ImageMagick installed that is 7.x prior to 7.0.2-0. It is, therefore, affected by a denial of service vulnerability due to a flaw in the ReadSUNImage() function in sun.c that is triggered during the handling of malformed SUN images. An unauthenticated, remote attacker can exploit this, by convincing a user to open a specially crafted SUN image, to crash processes linked against the library, resulting in a denial of service condition.

                                        
                                            #
# (C) Tenable Network Security, Inc.
#

include("compat.inc");

if (description)
{
  script_id(91764);
  script_version("1.6");
  script_cvs_date("Date: 2018/08/08 12:52:14");


  script_name(english:"ImageMagick 7.x < 7.0.2-0 ReadSUNImage() Function SUN Image Handling DoS");
  script_summary(english:"Checks the version of ImageMagick.");

  script_set_attribute(attribute:"synopsis", value:
"The remote Windows host has an application installed that is affected
by a denial of service vulnerability.");
  script_set_attribute(attribute:"description", value:
"The remote Windows host has a version of ImageMagick installed that is
7.x prior to 7.0.2-0. It is, therefore, affected by a denial of
service vulnerability due to a flaw in the ReadSUNImage() function
in sun.c that is triggered during the handling of malformed SUN
images. An unauthenticated, remote attacker can exploit this, by
convincing a user to open a specially crafted SUN image, to crash
processes linked against the library, resulting in a denial of service
condition.");
  script_set_attribute(attribute:"see_also", value:"http://www.imagemagick.org/script/changelog.php");
  script_set_attribute(attribute:"see_also", value:"https://github.com/ImageMagick/ImageMagick/issues/123");
  script_set_attribute(attribute:"solution", value:
"Upgrade to ImageMagick version 7.0.2-0 or later.

Note that you may need to manually uninstall the vulnerable version
from the system.");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:M/Au:N/C:N/I:N/A:C");
  script_set_cvss_temporal_vector("CVSS2#E:U/RL:OF/RC:C");

  script_set_attribute(attribute:"vuln_publication_date", value:"2016/02/04");
  script_set_attribute(attribute:"patch_publication_date", value:"2016/06/10");
  script_set_attribute(attribute:"plugin_publication_date", value:"2016/06/22");

  script_set_attribute(attribute:"plugin_type", value:"local");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:imagemagick:imagemagick");
  script_end_attributes();

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

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

  script_dependencies("imagemagick_installed.nasl");
  script_require_keys("installed_sw/ImageMagick");

  exit(0);
}

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

app = "ImageMagick";
fix = "7.0.2";
fix_build = 0;

# Get installs
install = get_single_install(app_name:app, exit_if_unknown_ver:TRUE);
display_version = install['display_version'];
version         = install['version'];
build           = install['build'];
path            = install['path'];

vuln = FALSE;

display_fix = fix + "-" + fix_build;

if (version !~ "^7\.") audit(AUDIT_NOT_INST, "ImageMagick 7.x");

if (ver_compare(ver:version, fix:fix, strict:FALSE) < 0)
  vuln = TRUE;

if ((ver_compare(ver:version, fix:fix, strict:FALSE) == 0)  &&
    build < fix_build
   )
  vuln = TRUE;

if (vuln)
{
  port = get_kb_item("SMB/transport");
  if (!port) port = 445;

  items = make_array("Installed version", display_version,
                     "Fixed version", display_fix,
                     "Path", path
                    );

  order = make_list("Path", "Installed version", "Fixed version");
  report = report_items_str(report_items:items, ordered_fields:order);

  security_report_v4(port:port, extra:report, severity:SECURITY_HOLE);
  exit(0);
}
else
  audit(AUDIT_INST_PATH_NOT_VULN, app, display_version, path);