CVE-2016-4922 - Improper Neutralization of Special Elements used in a Command ('Command Injection')

Severity

72%

Complexity

39%

Confidentiality

165%

Certain combinations of Junos OS CLI commands and arguments have been found to be exploitable in a way that can allow unauthorized access to the operating system. This may allow any user with permissions to run these CLI commands the ability to achieve elevated privileges and gain complete control of the device. Affected releases are Juniper Networks Junos OS 11.4 prior to 11.4R13-S3; 12.1X46 prior to 12.1X46-D60; 12.1X47 prior to 12.1X47-D45; 12.3 prior to 12.3R12; 12.3X48 prior to 12.3X48-D35; 13.2 prior to 13.2R9; 13.3 prior to 13.3R4-S11, 13.3R9; 14.1 prior to 14.1R4-S12, 14.1R7; 14.1X53 prior to 14.1X53-D28, 14.1X53-D40; 14.1X55 prior to 14.1X55-D35; 14.2 prior to 14.2R3-S10, 14.2R4-S7, 14.2R5; 15.1 prior to 15.1F4, 15.1R3; 15.1X49 prior to 15.1X49-D60; 15.1X53 prior to 15.1X53-D57, 15.1X53-D70.

Certain combinations of Junos OS CLI commands and arguments have been found to be exploitable in a way that can allow unauthorized access to the operating system. This may allow any user with permissions to run these CLI commands the ability to achieve elevated privileges and gain complete control of the device. Affected releases are Juniper Networks Junos OS 11.4 prior to 11.4R13-S3; 12.1X46 prior to 12.1X46-D60; 12.1X47 prior to 12.1X47-D45; 12.3 prior to 12.3R12; 12.3X48 prior to 12.3X48-D35; 13.2 prior to 13.2R9; 13.3 prior to 13.3R4-S11, 13.3R9; 14.1 prior to 14.1R4-S12, 14.1R7; 14.1X53 prior to 14.1X53-D28, 14.1X53-D40; 14.1X55 prior to 14.1X55-D35; 14.2 prior to 14.2R3-S10, 14.2R4-S7, 14.2R5; 15.1 prior to 15.1F4, 15.1R3; 15.1X49 prior to 15.1X49-D60; 15.1X53 prior to 15.1X53-D57, 15.1X53-D70.

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

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

Demo Examples

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

CWE-77

The following simple program accepts a filename as a command line argument and displays the contents of the file back to the user. The program is installed setuid root because it is intended for use as a learning tool to allow system administrators in-training to inspect privileged system files without giving them the ability to modify them or damage the system.


               
}
system(cmd);

Because the program runs with root privileges, the call to system() also executes with root privileges. If a user specifies a standard filename, the call works as expected. However, if an attacker passes a string of the form ";rm -rf /", then the call to system() fails to execute cat due to a lack of arguments and then plows on to recursively delete the contents of the root partition.

Note that if argv[1] is a very long argument, then this issue might also be subject to a buffer overflow (CWE-120).

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

CWE-77

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.

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

CWE-77

The following code from a system utility uses the system property APPHOME to determine the directory in which it is installed and then executes an initialization script based on a relative path from the specified directory.


               
...

The code above allows an attacker to execute arbitrary commands with the elevated privilege of the application by modifying the system property APPHOME to point to a different path containing a malicious version of INITCMD. Because the program does not validate the value read from the environment, if an attacker can control the value of the system property APPHOME, then they can fool the application into running malicious code and take control of the system.

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

CWE-77

The following code is a wrapper around the UNIX command cat which prints the contents of a file to standard out. It is also injectable:


               
}
return (0);

Used normally, the output is simply the contents of the file requested:


               
When last we left our heroes...

However, if we add a semicolon and another command to the end of this line, the command is executed by catWrapper with no complaint:


               
a.out*

If catWrapper had been set to have a higher privilege level than the standard user, arbitrary commands could be executed with that higher privilege.

Overview

Type

Juniper

First reported 7 years ago

2017-10-13 17:29:00

Last updated 5 years ago

2019-10-09 23:18:00

Affected Software

Juniper JUNOS 11.4

11.4

Juniper Junos 11.4 R1

11.4

Juniper Junos 11.4 R10

11.4

Juniper Junos 11.4 R11

11.4

Juniper JUNOS 11.4R12

11.4

Juniper Junos 11.4 R2

11.4

Juniper Junos 11.4 R3

11.4

Juniper Junos 11.4 R4

11.4

Juniper Junos 11.4 R5

11.4

Juniper Junos 11.4 R6

11.4

Juniper Junos 11.4 R7

11.4

Juniper Junos 11.4 R8

11.4

Juniper Junos 11.4 R9

11.4

Juniper JunOS 11.4R13 S2

11.4r13

Juniper JUNOS 12.1X46

12.1x46

Juniper Junos 12.1x46 D10

12.1x46

Juniper Junos 12.1x46 D15

12.1x46

Juniper JUNOS 12.1X46-D20

12.1x46

Juniper Junos 12.1x46 D25

12.1x46

Juniper JunOS 12.1x46 D30

12.1x46

Juniper JunOS 12.1x46 D35

12.1x46

Juniper JunOS 12.1x46 D40

12.1x46

Juniper Junos 12.1X46 D45

12.1x46

Juniper Junos 12.1X46 D50

12.1x46

Juniper JunOS 12.1X46 D55

12.1x46

Juniper JUNOS 12.1X47

12.1x47

Juniper JUNOS 12.1X47-D10

12.1x47

Juniper JunOS 12.1x47 D15

12.1x47

Juniper JunOS 12.1x47 D20

12.1x47

Juniper JunOS 12.1x47 D25

12.1x47

Juniper Junos 12.1X47 D30

12.1x47

Juniper Junos 12.1X47 D35

12.1x47

Juniper JunOS 12.1X47 D40

12.1x47

Juniper JUNOS 12.3

12.3

Juniper Junos 12.3 R1

12.3

Juniper JunOS 12.3 R10

12.3

Juniper Junos 12.3 R11

12.3

Juniper Junos 12.3 R2

12.3

Juniper Junos 12.3 R3

12.3

Juniper Junos 12.3 R4

12.3

Juniper Junos 12.3 R5

12.3

Juniper Junos 12.3 R6

12.3

Juniper JUNOS 12.3R7

12.3

Juniper Junos 12.3 R8

12.3

Juniper JunOS 12.3 R9

12.3

Juniper JunOS 12.3x48 D10

12.3x48

Juniper JunOS 12.3x48 D15

12.3x48

Juniper Junos 12.3X48 D25

12.3x48

Juniper Junos OS 12.3X48 D30

12.3x48

Juniper JUNOS 13.2

13.2

Juniper Junos 13.2 R1

13.2

Juniper Junos 13.2 R2

13.2

Juniper Junos 13.2 R3

13.2

Juniper Junos 13.2 R4

13.2

Juniper JUNOS 13.2R5

13.2

Juniper JunOS 13.2 R6

13.2

Juniper JunOS 13.2 R7

13.2

Juniper JunOS 13.2 R7-s1

13.2

Juniper JunOS 13.2 R7-s2

13.2

Juniper JUNOS 13.3

13.3

Juniper Junos 13.3 R1

13.3

Juniper Junos 13.3 R2

13.3

Juniper JUNOS 13.3R2-S2

13.3

Juniper Junos 13.3 R3

13.3

Juniper Junos 13.3 R4

13.3

Juniper Junos 13.3 R5

13.3

Juniper JUNOS 13.3 R6

13.3

Juniper Junos 13.3 R7

13.3

Juniper Junos 13.3 R8

13.3

Juniper JUNOS 14.1

14.1

Juniper JUNOS 14.1R1

14.1

Juniper Junos 14.1 R2

14.1

Juniper Junos 14.1 R3

14.1

Juniper JunOS 14.1 R4

14.1

Juniper Junos 14.1 R5

14.1

Juniper Junos 14.1 R6

14.1

Juniper JunOS 14.1x53

14.1x53

Juniper JunOS 14.1x53 D10

14.1x53

Juniper JunOS 14.1x53 D15

14.1x53

Juniper JunOS 14.1x53 D16

14.1x53

Juniper JunOS 14.1x53 D25

14.1x53

Juniper JunOS 14.1x53 D26

14.1x53

Juniper Junos 14.1X53 D27

14.1x53

Juniper Junos 14.1X53 D30

14.1x53

Juniper Junos 14.1X53 D35

14.1x53

Juniper Junos 14.1X55

14.1x55

Juniper JunOS 14.1X55 D30

14.1x55

Juniper Junos 14.2 R1

14.2

Juniper Junos 14.2 R2

14.2

Juniper Junos 14.2 R3

14.2

Juniper Junos 14.2 R4

14.2

Juniper Junos 14.2 R5

14.2

Juniper Junos 15.1 A1

15.1

Juniper JunOS 15.1 F1

15.1

Juniper JunOS 15.1 F2

15.1

Juniper JunOS 15.1 F2-s1

15.1

Juniper Junos 15.1 F2-S2

15.1

Juniper Junos 15.1 F2-S3

15.1

Juniper Junos 15.1 F2-S4

15.1

Juniper Junos 15.1 F3

15.1

Juniper Junos 15.1 R1

15.1

Juniper JunOS 15.1 R2

15.1

Juniper JunOS 15.1x49 D10

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 D45

15.1x49

Juniper JunOS 15.1X49 D50

15.1x49

Juniper JunOS 15.1X49 D55

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 D32

15.1x53

Juniper Junos 15.1X53 D33

15.1x53

Juniper Junos 15.1X53 D34

15.1x53

Juniper Junos OS 15.1X53 D50

15.1x53

Juniper Junos OS 15.1X53 D51

15.1x53

Juniper Junos OS 15.1X53 D52

15.1x53

Juniper Junos OS 15.1X53 D55

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 OS 15.1X53 D64

15.1x53

Juniper JUNOS 15.1x53 D65

15.1x53

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.