Monday, 27 April 2015

Pwning a thin client in less than two minutes

Have you ever encountered a zero client or a thin client? It looks something like this...

If yes, keep reading below, if not, then if you encounter one, you know what you can do if you read below...

The model above is a T520, produced by HP - this model and other similar models are typically employed to support a medium/large VDI (Virtual Desktop Infrastructure) enterprise.

These clients run a Linux-based HP ThinPro OS by default and I had a chance to play with image version T6X44017 in particular, which is fun to play with it, since you can get a root shell in a very short time without knowing any password...

Normally, HP ThinPro OS interface is configured in a kiosk mode, as the concept of a thin/zero client is based on using a thick client to connect to another resource. For this purpose, a standard user does not need to authenticate to the thin client per se and would just need to perform a connection - e.g. VMware Horizon View. The user will eventually authenticate through the connection.

The point of this blog post is to demonstrate that a malicious actor can compromise such thin clients in a trivial and quick way provided physical access, a standard prerequisite in an attack against a kiosk.

During my testing, I have tried to harden as much as possible the thin client, with the following options:

I did not set the "Allow user to lock screen" to simulate a scenario where users can use any thin-clients (kiosk style). However, I have also noticed that the default password for the account "user" is "user", so if you find an environment where they enforce account lockout, you can try that password directly (it is very often unchanged...)

I also set a password for the administrator's view, so when a user attempts to switch to the admin view, a password would be required.

In this scenario, the standard user does not know this password and should only be able to use a single VMware Horizon View pre-configured connection, as shown below:

However, I have found out that unless there is user lockout enabled, then it is possible to get a root shell following the steps below:

- Select the connection profile, and edit the profile (if it auto-starts, then you should cancel the connection)

- A new window with a form is presented to you - fill the server field with dummy data and then click on the General options

- Perform the attack to "escape" from the ThinPro Control Center kiosk by entering under "Command Line Arguments": && xterm

- Click Ok to save the new "VMware Horizon View" profile

- Click on new "VMware Horizon View" profile and the connection will timeout/fail, as dummy data was entered. However, when you close/cancel the window, the xterm window will be spawn

- You have bash shell access to the HP Zero client

The user id is user, so no root yet.

However, if you check sudo -ll you see that by default, the account user can perform a lot of commands as root without the need to enter a password. The output of sudo is included in this pastebin and an exerpt below:


Sudoers entry:
    RunAsUsers: root
NOPASSWD: /usr/bin/hpobl


The most interesting command I have found is: /usr/bin/hpobl

This command allows access to the HP Easy Setup Wizard panel. Through this one, it is possible to change settings. However, in this scenario, you do not know any password, so you must find a way to get a root shell from this Wizard panel.

By going directly to the last step "Thank you" (all the previous steps can be ignored for the lolz), then click on the link - this will spawn Firefox to load the link you just clicked.

At this stage, you have launched HP Easy Setup Wizard as root and Firefox process is also launched as root. One elegant option to get a shell of Firefox is to set Firefox's external mail handler - Edit / Preferences / Applications / Mailto - and point it to /usr/bin/xterm

Then you just need to point a tab to: and you will then be gratified with a root shell:

Here is a video of the entire attack which takes less than two minutes, in respect of the title of this blog post (in reality, the title was " less that one minute", but couldn't do it in that time frame lol...if you do it in less than one minute let me know...):

So what's the catch?

If you are performing a penetration testing against a VDI, look for quick wins as this one... if you are responsible for VDI, then consider that those machines can be compromised very easily - a soft key logger will be enough to get credentials to a Windows domain... also, check what configuration is enforced on the thin-client itself. It might even be more relaxed than the one considered in this scenario.

If you like kiosks and more in particular you like to break them, then you absolutely need to try: . Greetz to Paul Craig, the "self-proclaimed" king of kiosks! ;-)

I haven't tried other HP Thin Pro images yet, but it might be possible that the attack shown in this blog also affects versions earlier than T6X44017.

If you find other ways to bypass HP ThinPro OS, please let me know.

Wednesday, 1 April 2015

Playing with Kemp Load Master

Kemp virtual load master is a virtual load-balancer appliance which comes with a web administrative interface. I had a chance to test it and this blog post summarises some of the most interesting vulnerabilities I have discovered and which have not been published yet. For those of you who want to try it as well, you can get a free trial version here:

By default, Kemp web administrative interface is protected by Basic authentication, so the vulnerabilities discussed in the post below can either be exploited attacking an authenticated user via CSRF or XSS based attacks.

The following vulnerabilities were discovered when looking at Kemp Load Master v.7.1-16 and some of them should be fixed in the latest version (7.1-20b or later).

Change logs of the fixed issues can be found at the following page:

"PD-2183 Functions have been added to sanitize input in the WUI in order to resolve some security issues – fix for CVE-2014-5287 and CVE-2014-5288".

Remote Code Execution - status: fixed in 7.1.20b (reported in June 2014) - CVE-2014-5287/5288

An interesting remote code execution vector can be found through the attack payload below:


The web application functionality is based on multiple bash scripts contained in the /usr/wui/progs folder. The application is using CGI so that the scripts can handle HTTP requests.

The main page "fwaccess" executes the following function:

[snip] from /usr/wui/progs/fwaccess

We notice that if the result of the command on line 285 is not positive (check on 286), then seterrmsg function is called.

The seterrmsg function is defined in /usr/wui/progs/ and it is shown below:

On line 318 we see a dangerous "eval" against our parameters. By simply attempting multiple characters, the seterrmsg function is invoked and returns plenty of interesting information:



HTTP/1.1 200 OK
Date: Sat, 27 Dec 2014 23:25:55 GMT
Server: mini-http/1.0 (unix)
Connection: close
Content-Type: text/html
/usr/wui/progs/ eval: line 318: unexpected EOF while looking for matching `''
/usr/wui/progs/ eval: line 319: syntax error: unexpected end of file

line 318 contains an eval against the $@ (which contains our arguments). The arguments are passed via the fwaccess page, where IFS is set with a slash "/" separator.

By attempting the request below, it is possible to achieve code execution:



Line 120 and line 190 reports an integer expression expected error, as our argument is "1|ls" is obviously no longer an integer. However, the command execution works fine, as we are redirecting output through the pipe character and to "ls" command.

The application is flawed in so many other points, also, via HTTP POST requests, as shown below:

Other injection points that were found:

Page: /progs/geoctrl/doadd
Method: POST
Parameter: fqdn

Page: /progs/networks/hostname
Method: POST
Parameter: host

Page: /progs/networks/servadd
Method: POST
Parameter: addr

Page: /progs/useradmin/setopts
Method: POST
Parameter: xuser

So how can we exploit all this goodness?

CSRF (Cross Site Request Forgery) - status: not fixed - reported in June 2014

We can use another vulnerability, such as CSRF - most of the pages of the administrative are vulnerable to this attack, so even though a user is authenticated via Basic authentication, the forged request will force the browser to pass the credentials within the HTTP request.

Interestingly enough, there are some kind of protections against CSRF for critical functions, such as factory reset, shutdown and reset. However, they are flawed as well, as the "magic" token matches with the unix epoch timestamp, so it is predictable and can be passed within the request (see below):

Reflected and Stored XSS - status: partially fixed - reported on June 2014

Another way to attack users is via XSS - in this case, we have plenty of options, as both reflected and stored XSS are there. For instance, a user might want to CSRF -> Store XSS -> BeEF just to achieve persistence.

Reflected XSS was found on this point:

Page: /progs/useradmin/setopts
Method: POST
Parameter: xuser

Example payload:

Stored XSS was found on the following points:

Page: /progs/geoctrl/doadd
Method: POST
Parameter: fqdn

Rendered page: /progs/geoctrl/fqdn

A further injection points:

Page: /progs/fwaccess/add/0
Method: POST
Parameter: comment

Page: /progs/doconfig/setmotd
Method: POST

BeEF Module

As part of this research, I have developed a BeEF module to take advantage of chaining these vulnerabilities together. It is always sweet to use a XSS as a starting point to perform code execution against an appliance.

The github pull request for the module can be found here, and below you can find a video of it in action:

For this module, I wanted to use the function, using a POST method, required to exploit the above RCE vector attacks. However, POST method was not usable at moment of writing this module and @antisnatchor was very quick to fix it in this case. So if you want to try it, ensure you have the latest version of BeEF installed.

Extra - bonus

Denial of Service - status: unknown - reported on June 2014

It appears the thc-ssl-dos tool can bring down the Kemp Load Master administrative interface, which is served over SSL. The same goes if a balanced service is using SSL via Kemp Load Master.

Shell-shock - status: unknown - reported in 2015

Obviously, the application is not immune from the infamous shell-shock vulnerability. This was found by my friend Paul Heneghan and then by a user complaining on the vendor's blog (the comment has been removed shortly after).

For those of you who are more curios, the shell-shock vulnerability works perfectly via the User-Agent header, also in version 7.1-18 and possibly on version 7.1-20 as well.

Funny enough, Kemp provides Web Application Firewall protection, but I wonder how they can "prevent" the OWASP Top Ten (as they claim here), if their main product is affected by so many critical vulnerabilities ;-)

If you are keen for an extra-extra bonus, keep reading...

Extra - extra bonus:

No license, no web authentication

If you manage to invalidate your license, you will be prompted to a page such as the one below:

However, most of the underlying functionality is still available and "attackable" without need of basic authentication. You can invalidate the license with a CSRF setting time far in the future ;-)

Hope you enjoyed the post - I am sure there are other vulnerabilities in this product. If you find them, please let me know.