CVE-2017-12617 - Unrestricted Upload of File with Dangerous Type

Severity

68%

Complexity

86%

Confidentiality

106%

When running Apache Tomcat versions 9.0.0.M1 to 9.0.0, 8.5.0 to 8.5.22, 8.0.0.RC1 to 8.0.46 and 7.0.0 to 7.0.81 with HTTP PUTs enabled (e.g. via setting the readonly initialisation parameter of the Default servlet to false) it was possible to upload a JSP file to the server via a specially crafted request. This JSP could then be requested and any code it contained would be executed by the server.

When running Apache Tomcat versions 9.0.0.M1 to 9.0.0, 8.5.0 to 8.5.22, 8.0.0.RC1 to 8.0.46 and 7.0.0 to 7.0.81 with HTTP PUTs enabled (e.g. via setting the readonly initialisation parameter of the Default servlet to false) it was possible to upload a JSP file to the server via a specially crafted request. This JSP could then be requested and any code it contained would be executed by the server.

CVSS 3.0 Base Score 8.1. CVSS Attack Vector: network. CVSS Attack Complexity: high. CVSS Vector: (CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H).

CVSS 2.0 Base Score 6.8. CVSS Attack Vector: network. CVSS Attack Complexity: medium. CVSS Vector: (AV:N/AC:M/Au:N/C:P/I:P/A:P).

Demo Examples

Unrestricted Upload of File with Dangerous Type

CWE-434

The following code intends to allow a user to upload a picture to the web server. The HTML code that drives the form on the user end has an input field of type "file".


               
</form>

Once submitted, the form above sends the file to upload_picture.php on the web server. PHP stores the file in a temporary location until it is retrieved (or discarded) by the server side code. In this example, the file is moved to a more permanent pictures/ directory.


               
}// Define the target location where the picture being// uploaded is going to be saved.// Move the uploaded file to the new location.
echo "The picture has been successfully uploaded.";
echo "There was an error uploading the picture, please try again.";

The problem with the above code is that there is no check regarding type of file being uploaded. Assuming that pictures/ is available in the web document root, an attacker could upload a file with the name:


               
malicious.php

Since this filename ends in ".php" it can be executed by the web server. In the contents of this uploaded file, the attacker could use:


               
?>
system($_GET['cmd']);

Once this file has been installed, the attacker can enter arbitrary commands to execute using a URL such as:


               
http://server.example.com/upload_dir/malicious.php?cmd=ls%20-l

which runs the "ls -l" command - or any other type of command that the attacker wants to specify.

Unrestricted Upload of File with Dangerous Type

CWE-434

The following code demonstrates the unrestricted upload of a file with a Java servlet and a path traversal vulnerability. The HTML code is the same as in the previous example with the action attribute of the form sending the upload file request to the Java servlet instead of the PHP code.


               
</form>

When submitted the Java servlet's doPost method will receive the request, extract the name of the file from the Http request header, read the file contents from the request and output the file to the local upload directory.


               
}
{...}
// output successful upload response HTML page
bw.close();
}
bw.flush();
...

As with the previous example this code does not perform a check on the type of the file being uploaded. This could allow an attacker to upload any executable file or other file with malicious code.

Additionally, the creation of the BufferedWriter object is subject to relative path traversal (CWE-22, CWE-23). Depending on the executing environment, the attacker may be able to specify arbitrary files to write to, leading to a wide variety of consequences, from code execution, XSS (CWE-79), or system crash.

Overview

Type

Apache

First reported 7 years ago

2017-10-04 01:29:00

Last updated 5 years ago

2019-04-23 19:29:00

Affected Software

Apache Software Foundation Tomcat 7.0.0

7.0.0

Apache Software Foundation Tomcat 7.0.1

7.0.1

Apache Software Foundation Tomcat 7.0.2

7.0.2

Apache Software Foundation Tomcat 7.0.2 beta

7.0.2

Apache Software Foundation Tomcat 7.0.3

7.0.3

Apache Software Foundation Tomcat 7.0.4

7.0.4

Apache Software Foundation Tomcat 7.0.4 beta

7.0.4

Apache Software Foundation Tomcat 7.0.5

7.0.5

Apache Tomcat 7.0.5 Beta

7.0.5

Apache Software Foundation Tomcat 7.0.6

7.0.6

Apache Software Foundation Tomcat 7.0.7

7.0.7

Apache Software Foundation Tomcat 7.0.8

7.0.8

Apache Software Foundation Tomcat 7.0.9

7.0.9

Apache Software Foundation Tomcat 7.0.10

7.0.10

Apache Software Foundation Tomcat 7.0.11

7.0.11

Apache Software Foundation Tomcat 7.0.12

7.0.12

Apache Software Foundation Tomcat 7.0.13

7.0.13

Apache Software Foundation Tomcat 7.0.14

7.0.14

Apache Software Foundation Tomcat 7.0.15

7.0.15

Apache Software Foundation Tomcat 7.0.16

7.0.16

Apache Software Foundation Tomcat 7.0.17

7.0.17

Apache Software Foundation Tomcat 7.0.18

7.0.18

Apache Software Foundation Tomcat 7.0.19

7.0.19

Apache Software Foundation Tomcat 7.0.20

7.0.20

Apache Software Foundation Tomcat 7.0.21

7.0.21

Apache Software Foundation Tomcat 7.0.22

7.0.22

Apache Software Foundation Tomcat 7.0.23

7.0.23

Apache Software Foundation Tomcat 7.0.24

7.0.24

Apache Software Foundation Tomcat 7.0.25

7.0.25

Apache Software Foundation Tomcat 7.0.26

7.0.26

Apache Software Foundation Tomcat 7.0.27

7.0.27

Apache Software Foundation Tomcat 7.0.28

7.0.28

Apache Software Foundation Tomcat 7.0.29

7.0.29

Apache Software Foundation Tomcat 7.0.30

7.0.30

Apache Software Foundation Tomcat 7.0.31

7.0.31

Apache Software Foundation Tomcat 7.0.32

7.0.32

Apache Software Foundation Tomcat 7.0.33

7.0.33

Apache Software Foundation Tomcat 7.0.34

7.0.34

Apache Software Foundation Tomcat 7.0.35

7.0.35

Apache Software Foundation Tomcat 7.0.36

7.0.36

Apache Software Foundation Tomcat 7.0.37

7.0.37

Apache Software Foundation Tomcat 7.0.38

7.0.38

Apache Software Foundation Tomcat 7.0.39

7.0.39

Apache Software Foundation Tomcat 7.0.40

7.0.40

Apache Software Foundation Tomcat 7.0.41

7.0.41

Apache Software Foundation Tomcat 7.0.42

7.0.42

Apache Software Foundation Tomcat 7.0.43

7.0.43

Apache Software Foundation Tomcat 7.0.44

7.0.44

Apache Software Foundation Tomcat 7.0.45

7.0.45

Apache Software Foundation Tomcat 7.0.46

7.0.46

Apache Software Foundation Tomcat 7.0.47

7.0.47

Apache Software Foundation Tomcat 7.0.48

7.0.48

Apache Software Foundation Tomcat 7.0.49

7.0.49

Apache Software Foundation Tomcat 7.0.50

7.0.50

Apache Software Foundation Tomcat 7.0.51

7.0.51

Apache Software Foundation Tomcat 7.0.54

7.0.54

Apache Software Foundation Tomcat 7.0.55

7.0.55

Apache Software Foundation Tomcat 7.0.56

7.0.56

Apache Software Foundation Tomcat 7.0.57

7.0.57

Apache Software Foundation Tomcat 7.0.58

7.0.58

Apache Tomcat 7.0.59

7.0.59

Apache Software Foundation Tomcat 7.0.60

7.0.60

Apache Tomcat 7.0.61

7.0.61

Apache Tomcat 7.0.62

7.0.62

Apache Tomcat 7.0.63

7.0.63

Apache Tomcat 7.0.64

7.0.64

Apache Software Foundation Tomcat 7.0.65

7.0.65

Apache Software Foundation Tomcat 7.0.66

7.0.66

Apache Software Foundation Tomcat 7.0.67

7.0.67

Apache Software Foundation Tomcat 7.0.68

7.0.68

Apache Software Foundation Tomcat 7.0.69

7.0.69

Apache Software Foundation Tomcat 7.0.70

7.0.70

Apache Software Foundation Tomcat 7.0.71

7.0.71

Apache Software Foundation Tomcat 7.0.72

7.0.72

Apache Software Foundation Tomcat 7.0.73

7.0.73

Apache Software Foundation Tomcat 7.0.74

7.0.74

Apache Software Foundation Tomcat 7.0.75

7.0.75

Apache Software Foundation Tomcat 7.0.76

7.0.76

Apache Software Foundation Tomcat 7.0.77

7.0.77

Apache Software Foundation Tomcat 7.0.79

7.0.79

Apache Software Foundation Tomcat 7.0.80

7.0.80

Apache Software Foundation Tomcat 7.0.81

7.0.81

Apache Software Foundation Tomcat 8.0.0 Release Candidate 1

8.0.0

Apache Software Foundation Tomcat 8.0.0 release candidate 10

8.0.0

Apache Software Foundation Tomcat 8.0.0 Release Candidate 2

8.0.0

Apache Software Foundation Tomcat 8.0.0 release candidate 5

8.0.0

Apache Software Foundation Tomcat 8.0.1

8.0.1

Apache Software Foundation Tomcat 8.0.2

8.0.2

Apache Software Foundation Tomcat 8.0.4

8.0.4

Apache Software Foundation Tomcat 8.0.6

8.0.6

Apache Software Foundation Tomcat 8.0.7

8.0.7

Apache Software Foundation Tomcat 8.0.9

8.0.9

Apache Software Foundation Tomcat 8.0.10

8.0.10

Apache Software Foundation Tomcat 8.0.11

8.0.11

Apache Software Foundation Tomcat 8.0.12

8.0.12

Apache Software Foundation Tomcat 8.0.13

8.0.13

Apache Software Foundation Tomcat 8.0.14

8.0.14

Apache Software Foundation Tomcat 8.0.15

8.0.15

Apache Software Foundation Tomcat 8.0.16

8.0.16

Apache Tomcat 8.0.17

8.0.17

Apache Tomcat 8.0.18

8.0.18

Apache Software Foundation Tomcat 8.0.19

8.0.19

Apache Tomcat 8.0.20

8.0.20

Apache Tomcat 8.0.21

8.0.21

Apache Tomcat 8.0.22

8.0.22

Apache Tomcat 8.0.23

8.0.23

Apache Tomcat 8.0.24

8.0.24

Apache Software Foundation Tomcat 8.0.25

8.0.25

Apache Tomcat 8.0.26

8.0.26

Apache Software Foundation Tomcat 8.0.27

8.0.27

Apache Software Foundation Tomcat 8.0.28

8.0.28

Apache Software Foundation Tomcat 8.0.29

8.0.29

Apache Software Foundation Tomcat 8.0.30

8.0.30

Apache Software Foundation Tomcat 8.0.31

8.0.31

Apache Software Foundation Tomcat 8.0.32

8.0.32

Apache Software Foundation Tomcat 8.0.33

8.0.33

Apache Software Foundation Tomcat 8.0.34

8.0.34

Apache Software Foundation Tomcat 8.0.35

8.0.35

Apache Software Foundation Tomcat 8.0.36

8.0.36

Apache Software Foundation Tomcat 8.0.37

8.0.37

Apache Software Foundation Tomcat 8.0.38

8.0.38

Apache Software Foundation Tomcat 8.0.39

8.0.39

Apache Software Foundation Tomcat 8.0.40

8.0.40

Apache Software Foundation Tomcat 8.0.41

8.0.41

Apache Software Foundation Tomcat 8.0.42

8.0.42

Apache Software Foundation Tomcat 8.0.43

8.0.43

Apache Software Foundation Tomcat 8.0.44

8.0.44

Apache Software Foundation Tomcat 8.0.45

8.0.45

Apache Software Foundation Tomcat 8.0.46

8.0.46

Apache Software Foundation Tomcat 8.5.0

8.5.0

Apache Software Foundation Tomcat 8.5.1

8.5.1

Apache Software Foundation Tomcat 8.5.2

8.5.2

Apache Software Foundation Tomcat 8.5.3

8.5.3

Apache Software Foundation Tomcat 8.5.4

8.5.4

Apache Software Foundation Tomcat 8.5.5

8.5.5

Apache Software Foundation Tomcat 8.5.6

8.5.6

Apache Software Foundation Tomcat 8.5.7

8.5.7

Apache Software Foundation Tomcat 8.5.8

8.5.8

Apache Software Foundation Tomcat 8.5.9

8.5.9

Apache Software Foundation Tomcat 8.5.10

8.5.10

Apache Software Foundation Tomcat 8.5.11

8.5.11

Apache Software Foundation Tomcat 8.5.12

8.5.12

Apache Software Foundation Tomcat 8.5.13

8.5.13

Apache Software Foundation Tomcat 8.5.14

8.5.14

Apache Software Foundation Tomcat 8.5.15

8.5.15

Apache Software Foundation Tomcat 8.5.16

8.5.16

Apache Software Foundation Tomcat 8.5.17

8.5.17

Apache Software Foundation Tomcat 8.5.18

8.5.18

Apache Software Foundation Tomcat 8.5.19

8.5.19

Apache Software Foundation Tomcat 8.5.20

8.5.20

Apache Software Foundation Tomcat 8.5.21

8.5.21

Apache Software Foundation Tomcat 8.5.22

8.5.22

Apache Software Foundation Tomcat 9.0.0 M1

9.0.0

Apache Software Foundation Tomcat 9.0.0 M10

9.0.0

Apache Software Foundation Tomcat 9.0.0 M11

9.0.0

Apache Software Foundation Tomcat 9.0.0 M12

9.0.0

Apache Software Foundation Tomcat 9.0.0 M13

9.0.0

Apache Software Foundation Tomcat 9.0.0 M14

9.0.0

Apache Software Foundation Tomcat 9.0.0 M15

9.0.0

Apache Software Foundation Tomcat 9.0.0 M16

9.0.0

Apache Software Foundation Tomcat 9.0.0 M17

9.0.0

Apache Software Foundation Tomcat 9.0.0 M18

9.0.0

Apache Software Foundation Tomcat 9.0.0 M19

9.0.0

Apache Software Foundation Tomcat 9.0.0 M2

9.0.0

Apache Software Foundation Tomcat 9.0.0 M20

9.0.0

Apache Software Foundation Tomcat 9.0.0 M21

9.0.0

Apache Software Foundation Tomcat 9.0.0 M22

9.0.0

Apache Software Foundation Tomcat 9.0.0 M3

9.0.0

Apache Software Foundation Tomcat 9.0.0 M4

9.0.0

Apache Software Foundation Tomcat 9.0.0 M5

9.0.0

Apache Software Foundation Tomcat 9.0.0 M6

9.0.0

Apache Software Foundation Tomcat 9.0.0 M7

9.0.0

Apache Software Foundation Tomcat 9.0.0 M8

9.0.0

Apache Software Foundation Tomcat 9.0.0 M9

9.0.0

References

http://www.oracle.com/technetwork/security-advisory/cpuapr2018-3678067.html

http://www.oracle.com/technetwork/security-advisory/cpujan2018-3236628.html

http://www.oracle.com/technetwork/security-advisory/cpujul2018-4258247.html

100954

Third Party Advisory, VDB Entry

1039552

Third Party Advisory, VDB Entry

RHSA-2017:3080

RHSA-2017:3081

RHSA-2017:3113

RHSA-2017:3114

RHSA-2018:0268

RHSA-2018:0269

RHSA-2018:0270

RHSA-2018:0271

RHSA-2018:0275

RHSA-2018:0465

RHSA-2018:0466

RHSA-2018:2939

[tomcat-dev] 20190415 svn commit: r1857582 [18/22] - in /tomcat/site/trunk: docs/ xdocs/stylesheets/

[tomcat-dev] 20190319 svn commit: r1855831 [25/30] - in /tomcat/site/trunk: ./ docs/ xdocs/

[tomcat-dev] 20190325 svn commit: r1856174 [22/29] - in /tomcat/site/trunk: docs/ xdocs/ xdocs/stylesheets/

[tomcat-dev] 20190415 svn commit: r1857582 [17/22] - in /tomcat/site/trunk: docs/ xdocs/stylesheets/

[announce] 20171003 [SECURITY] CVE-2017-12617 Apache Tomcat Remote Code Execution via JSP upload

Mailing List, Vendor Advisory

[tomcat-dev] 20190325 svn commit: r1856174 [23/29] - in /tomcat/site/trunk: docs/ xdocs/ xdocs/stylesheets/

[tomcat-dev] 20190415 svn commit: r1857582 [19/22] - in /tomcat/site/trunk: docs/ xdocs/stylesheets/

[tomcat-dev] 20190413 svn commit: r1857494 [16/20] - in /tomcat/site/trunk: ./ docs/ xdocs/

[tomcat-dev] 20190413 svn commit: r1857494 [17/20] - in /tomcat/site/trunk: ./ docs/ xdocs/

[tomcat-dev] 20190325 svn commit: r1856174 [24/29] - in /tomcat/site/trunk: docs/ xdocs/ xdocs/stylesheets/

[tomcat-dev] 20190413 svn commit: r1857496 [3/4] - in /tomcat/site/trunk: ./ docs/ xdocs/

[tomcat-dev] 20190319 svn commit: r1855831 [24/30] - in /tomcat/site/trunk: ./ docs/ xdocs/

[tomcat-dev] 20200203 svn commit: r1873527 [25/30] - /tomcat/site/trunk/docs/

[tomcat-dev] 20200213 svn commit: r1873980 [29/34] - /tomcat/site/trunk/docs/

[tomcat-dev] 20200203 svn commit: r1873527 [24/30] - /tomcat/site/trunk/docs/

[tomcat-dev] 20200213 svn commit: r1873980 [27/34] - /tomcat/site/trunk/docs/

[tomcat-dev] 20200213 svn commit: r1873980 [28/34] - /tomcat/site/trunk/docs/

[debian-lts-announce] 20171107 [SECURITY] [DLA 1166-1] tomcat7 security update

https://security.netapp.com/advisory/ntap-20171018-0002/

https://security.netapp.com/advisory/ntap-20180117-0002/

https://support.f5.com/csp/article/K53173544

https://support.hpe.com/hpsc/doc/public/display?docLocale=en_US&docId=emr_na-hpesbhf03812en_us

https://support.hpe.com/hpsc/doc/public/display?docLocale=en_US&docId=emr_na-hpesbux03828en_us

USN-3665-1

42966

Exploit, Third Party Advisory, VDB Entry

43008

Exploit, Third Party Advisory, VDB Entry

https://www.oracle.com/technetwork/security-advisory/cpuapr2019-5072813.html

Stay updated

ExploitPedia is constantly evolving. Sign up to receive a notification when we release additional functionality.

Get in touch

If you'd like to report a bug or have any suggestions for improvements then please do get in touch with us using this form. We will get back to you as soon as we can.