CVE-2020-1602 - Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

Severity

88%

Complexity

27%

Confidentiality

98%

When a device using Juniper Network's Dynamic Host Configuration Protocol Daemon (JDHCPD) process on Junos OS or Junos OS Evolved which is configured in relay mode it vulnerable to an attacker sending crafted IPv4 packets who may remotely take over the code execution of the JDHDCP process. This issue affect IPv4 JDHCPD services. This issue affects: Juniper Networks Junos OS: 15.1 versions prior to 15.1R7-S6; 15.1X49 versions prior to 15.1X49-D200; 15.1X53 versions prior to 15.1X53-D592; 16.1 versions prior to 16.1R7-S6; 16.2 versions prior to 16.2R2-S11; 17.1 versions prior to 17.1R2-S11, 17.1R3-S1; 17.2 versions prior to 17.2R2-S8, 17.2R3-S3; 17.3 versions prior to 17.3R3-S6; 17.4 versions prior to 17.4R2-S7, 17.4R3; 18.1 versions prior to 18.1R3-S8; 18.2 versions prior to 18.2R3-S2; 18.2X75 versions prior to 18.2X75-D60; 18.3 versions prior to 18.3R1-S6, 18.3R2-S2, 18.3R3; 18.4 versions prior to 18.4R1-S5, 18.4R2-S3, 18.4R3; 19.1 versions prior to 19.1R1-S3, 19.1R2; 19.2 versions prior to 19.2R1-S3, 19.2R2*. and All versions prior to 19.3R1 on Junos OS Evolved. This issue do not affect versions of Junos OS prior to 15.1, or JDHCPD operating as a local server in non-relay mode.

When a device using Juniper Network's Dynamic Host Configuration Protocol Daemon (JDHCPD) process on Junos OS or Junos OS Evolved which is configured in relay mode it vulnerable to an attacker sending crafted IPv4 packets who may remotely take over the code execution of the JDHDCP process. This issue affect IPv4 JDHCPD services. This issue affects: Juniper Networks Junos OS: 15.1 versions prior to 15.1R7-S6; 15.1X49 versions prior to 15.1X49-D200; 15.1X53 versions prior to 15.1X53-D592; 16.1 versions prior to 16.1R7-S6; 16.2 versions prior to 16.2R2-S11; 17.1 versions prior to 17.1R2-S11, 17.1R3-S1; 17.2 versions prior to 17.2R2-S8, 17.2R3-S3; 17.3 versions prior to 17.3R3-S6; 17.4 versions prior to 17.4R2-S7, 17.4R3; 18.1 versions prior to 18.1R3-S8; 18.2 versions prior to 18.2R3-S2; 18.2X75 versions prior to 18.2X75-D60; 18.3 versions prior to 18.3R1-S6, 18.3R2-S2, 18.3R3; 18.4 versions prior to 18.4R1-S5, 18.4R2-S3, 18.4R3; 19.1 versions prior to 19.1R1-S3, 19.1R2; 19.2 versions prior to 19.2R1-S3, 19.2R2*. and All versions prior to 19.3R1 on Junos OS Evolved. This issue do not affect versions of Junos OS prior to 15.1, or JDHCPD operating as a local server in non-relay mode.

CVSS 3.1 Base Score 8.8. CVSS Attack Vector: adjacent_network. CVSS Attack Complexity: low. CVSS Vector: (CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

CVSS 2.0 Base Score 8.3. CVSS Attack Vector: adjacent_network. CVSS Attack Complexity: low. CVSS Vector: (AV:A/AC:L/Au:N/C:C/I:C/A:C).

Demo Examples

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

CWE-78

This example code intends to take the name of a user and list the contents of that user's home directory. It is subject to the first variant of OS command injection.


               
system($command);

The $userName variable is not checked for malicious input. An attacker could set the $userName variable to an arbitrary OS command such as:


               
;rm -rf /

Which would result in $command being:


               
ls -l /home/;rm -rf /

Since the semi-colon is a command separator in Unix, the OS would first execute the ls command, then the rm command, deleting the entire file system.

Also note that this example code is vulnerable to Path Traversal (CWE-22) and Untrusted Search Path (CWE-426) attacks.

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

CWE-78

This example is a web application that intends to perform a DNS lookup of a user-supplied domain name. It is subject to the first variant of OS command injection.


               
}
close($fh);
print "<br>\n";

Suppose an attacker provides a domain name like this:


               
cwe.mitre.org%20%3B%20/bin/ls%20-l

The "%3B" sequence decodes to the ";" character, and the %20 decodes to a space. The open() statement would then process a string like this:


               
/path/to/nslookup cwe.mitre.org ; /bin/ls -l

As a result, the attacker executes the "/bin/ls -l" command and gets a list of all the files in the program's working directory. The input could be replaced with much more dangerous commands, such as installing a malicious program on the server.

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

CWE-78

The example below reads the name of a shell script to execute from the system properties. It is subject to the second variant of OS command injection.


               
System.exec(script);

If an attacker has control over this property, then they could modify the property to point to a dangerous program.

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

CWE-78

In the example below, a method is used to transform geographic coordinates from latitude and longitude format to UTM format. The method gets the input coordinates from a user through a HTTP request and executes a program local to the application server that performs the transformation. The method passes the latitude and longitude coordinates as a command-line option to the external program and will perform some processing to retrieve the results of the transformation and return the resulting UTM coordinates.


               
}
return utmCoords;
// process results of coordinate transform// ...

However, the method does not verify that the contents of the coordinates input parameter includes only correctly-formatted latitude and longitude coordinates. If the input coordinates were not validated prior to the call to this method, a malicious user could execute another program local to the application server by appending '&' followed by the command for another program to the end of the coordinate string. The '&' instructs the Windows operating system to execute another program.

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

CWE-78

The following code is from an administrative web application designed to allow users to kick off a backup of an Oracle database using a batch-file wrapper around the rman utility and then run a cleanup.bat script to delete some temporary files. The script rmanDB.bat accepts a single command line parameter, which specifies what type of backup to perform. Because access to the database is restricted, the application runs the backup as a privileged user.


               
...
"&&c:\\utl\\cleanup.bat\"")

The problem here is that the program does not do any validation on the backuptype parameter read from the user. Typically the Runtime.exec() function will not execute multiple commands, but in this case the program first runs the cmd.exe shell in order to run multiple commands with a single call to Runtime.exec(). Once the shell is invoked, it will happily execute multiple commands separated by two ampersands. If an attacker passes a string of the form "& del c:\\dbms\\*.*", then the application will execute this command along with the others specified by the program. Because of the nature of the application, it runs with the privileges necessary to interact with the database, which means whatever command the attacker injects will run with those privileges as well.

Overview

Type

Juniper

First reported 5 years ago

2020-01-15 09:15:00

Last updated 5 years ago

2020-01-24 15:06:00

Affected Software

Juniper Junos OS 15.1 R7

15.1

Juniper JUNOS 15.1 R7-S1

15.1

Juniper JUNOS 15.1 R7-S2

15.1

Juniper JUNOS 15.1 R7-S3

15.1

Juniper Junos OS 15.1 R7-s4

15.1

Juniper Junos OS 15.1 R7-s5

15.1

Juniper JunOS 15.1x49 D10

15.1x49

Juniper Junos OS 15.1X49 D110

15.1x49

Juniper Junos OS 15.1X49 D140

15.1x49

Juniper JunOS 15.1x49 D150

15.1x49

Juniper Junos OS 15.1X49 D170

15.1x49

Juniper Junos OS 15.1X49 D180

15.1x49

Juniper JUNOS 15.1X49 D190

15.1x49

Juniper JunOS 15.1x49 D20

15.1x49

Juniper JunOS 15.1X49 D30

15.1x49

Juniper Junos 15.1X49 D35

15.1x49

Juniper JunOS 15.1X49 D40

15.1x49

Juniper JunOS 15.1X49 D50

15.1x49

Juniper JunOS 15.1X49 D55

15.1x49

Juniper JunOS 15.1X49 D60

15.1x49

Juniper JunOS 15.1X49 D65

15.1x49

Juniper JunOS 15.1X49 D70

15.1x49

Juniper JunOS 15.1X49 D75

15.1x49

Juniper JunOS 15.1X49 D80

15.1x49

Juniper Junos OS 15.1X49 D90

15.1x49

Juniper Junos 15.1X53 D20

15.1x53

Juniper Junos 15.1X53 D21

15.1x53

Juniper JunOS 15.1X53 D210

15.1x53

Juniper JunOS 15.1X53 D25

15.1x53

Juniper Junos 15.1X53 D30

15.1x53

Juniper JUNOS 15.1X53 D31

15.1x53

Juniper Junos 15.1X53 D32

15.1x53

Juniper Junos 15.1X53 D33

15.1x53

Juniper Junos 15.1X53 D34

15.1x53

Juniper JunOS 15.1X53 D40

15.1x53

Juniper JunOS 15.1X53 D45

15.1x53

Juniper JUNOS 15.1X53 D470

15.1x53

Juniper JUNOS 15.1x53 D495

15.1x53

Juniper Junos 15.1x53 D56

15.1x53

Juniper Junos OS 15.1X53 D591

15.1x53

Juniper JunOS 15.1X53 D60

15.1x53

Juniper JunOS 15.1X53 D61

15.1x53

Juniper JunOS 15.1X53 D62

15.1x53

Juniper JunOS 15.1X53 D63

15.1x53

Juniper JUNOS 15.1x53 D65

15.1x53

Juniper JunOS 15.1X53 D70

15.1x53

Juniper JUNOS 16.1

16.1

Juniper JunOS 16.1 R1

16.1

Juniper JunOS 16.1 R2

16.1

Juniper JunOS 16.1 R3

16.1

Juniper Junos 16.1 R3-S10

16.1

Juniper JunOS 16.1 R4

16.1

Juniper Junos 16.1 R5-S4

16.1

Juniper Junos 16.1 R6-S1

16.1

Juniper Junos 16.1 R7

16.1

Juniper JUNOS 16.1R7-S4

16.1

Juniper JUNOS 16.1R7-S5

16.1

Juniper JUNOS 16.2

16.2

Juniper JunOS 16.2 R1

16.2

Juniper JunOS 16.2 R2

16.2

Juniper Junos 16.2 R2-S1

16.2

Juniper JUNOS 16.2 R2-S2

16.2

Juniper Junos 16.2 R2-S5

16.2

Juniper JUNOS 16.2 R2-S6

16.2

Juniper JUNOS 16.2 R2-S7

16.2

Juniper JUNOS 16.2R2-S8

16.2

Juniper JUNOS 16.2 R2-S9

16.2

Juniper JUNOS 17.1

17.1

Juniper JunOS 17.1 R1

17.1

Juniper Junos 17.1 R2-S1

17.1

Juniper JUNOS 17.1 R2-S10

17.1

Juniper JUNOS 17.1 R2-S2

17.1

Juniper JUNOS 17.1 R2-S3

17.1

Juniper JUNOS 17.1 R2-S4

17.1

Juniper JUNOS 17.1 R2-S5

17.1

Juniper JUNOS 17.1 R2-S6

17.1

Juniper Junos 17.1 R2-S7

17.1

Juniper JUNOS 17.2

17.2

Juniper JUNOS 17.2 R1-S2

17.2

Juniper JUNOS 17.2 R1-S4

17.2

Juniper Junos 17.2 R1-S7

17.2

Juniper JUNOS 17.2 R1-S8

17.2

Juniper JUNOS 17.2 R2-S6

17.2

Juniper JUNOS 17.2 R2-S7

17.2

Juniper JUNOS 17.2R3-S1

17.2

Juniper JUNOS 17.2 R3-S2

17.2

Juniper JUNOS 17.3

17.3

Juniper JUNOS 17.3 R1-S1

17.3

Juniper Junos 17.3 R2

17.3

Juniper JUNOS 17.3 R2-S1

17.3

Juniper JUNOS 17.3R2-S2

17.3

Juniper JUNOS 17.3 R3-S1

17.3

Juniper JUNOS 17.3 R3-S2

17.3

Juniper JUNOS 17.3 R3-S3

17.3

Juniper JUNOS 17.3R3-S4

17.3

Juniper JUNOS 17.4

17.4

Juniper Junos 17.4 R1

17.4

Juniper JUNOS 17.4 R1-S1

17.4

Juniper JUNOS 17.4 R1-S2

17.4

Juniper JUNOS 17.4R1-S4

17.4

Juniper JUNOS 17.4 R1-S6

17.4

Juniper JUNOS 17.4R1-S7

17.4

Juniper Junos 17.4 R2

17.4

Juniper JUNOS 17.4 R2-S1

17.4

Juniper JUNOS 17.4 R2-S3

17.4

Juniper JUNOS 17.4R2-S4

17.4

Juniper JUNOS 17.4 R2-S5

17.4

Juniper JUNOS 17.4 R2-S6

17.4

Juniper JUNOS 18.1 R3-S6

18.1

Juniper JUNOS 18.1 R3-S7

18.1

Juniper JUNOS 18.2

18.2

Juniper JUNOS 18.2 R1-S5

18.2

Juniper JUNOS 18.2 R2-S1

18.2

Juniper JUNOS 18.2R2-S2

18.2

Juniper JUNOS 18.2R2-S3

18.2

Juniper JUNOS18.2 R2-S4

18.2

Juniper JUNOS 18.2R3

18.2

Juniper JUNOS 18.2 R3-S1

18.2

Juniper Junos 18.2x75 -

18.2x75

Juniper JUNOS 18.2x75 D20

18.2x75

Juniper JUNOS 18.2X75-D40

18.2x75

Juniper JUNOS 18.3

18.3

Juniper JUNOS 18.3 R1

18.3

Juniper JUNOS 18.3 R1-S1

18.3

Juniper JUNOS 18.3 R1-S2

18.3

Juniper JUNOS 18.3R1-S3

18.3

Juniper JUNOS 18.3 R1-S5

18.3

Juniper JUNOS 18.3 R2

18.3

Juniper JUNOS 18.4

18.4

Juniper JunOS 18.4 R1

18.4

Juniper Junos OS 18.4 R1-S1

18.4

Juniper JUNOS 18.4R1-S2

18.4

Juniper JUNOS 18.4R2

18.4

Juniper Junos OS 19.1 R1

19.1

Juniper Junos OS 19.1 R1-s1

19.1

Juniper JUNOS 19.1 R1-S2

19.1

Juniper Junos OS 19.2 R1

19.2

Juniper JUNOS 19.2 R1-S1

19.2

Juniper JUNOS 19.2 R1-S2

19.2

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.