Reverse Engineering the OBi200 Google Voice Appliance: Part 3

In part 1 of this series, I analyzed the firmware of the OBi200 and walked through exploiting some RCE vulns to pop a shell. In part 2, I covered the process of identifying and connecting to the board’s undocumented UART port to access the console. This post will cover cross-compiling 3rd party binaries from source for the target, debugging crashes in the OBi binaries, and some other interesting findings.

Tools

After getting console access to the device, the next steps in diving deeper required some additional tools. For example, running tcpdump right on the device would help in understanding more about the listening services:

The included busybox was old and a bit limited as well:

Since the board didn’t have the resources to run gdb, I also needed to build gdbserver. In order to build these and other utilities, I needed to get my hands on a toolchain capable of compiling for the OBi.

Toolchain

Getting ahold of the right toolchain for cross compiling ARM was made a lot simpler with crosstool-NG. After installation, I chose the pre-configured arm-unknown-linux-uclibcgnueabi toolchain and built it by running ct-ng build. It took some time to run the build process, but ultimately produced binaries that would run on the OBi target.

Next, I cross-compiled tcpdump, gdbserver, busybox, strace, and some other tools from source and moved them over to the OBi with netcat. Most of the aforementioned projects have some documentation on cross compiling — see the wiki for gdbserver, for instance:

And of course, I couldn’t resist building a cryptocoin miner:

Obviously just for fun — it didn’t exactly run well despite its impressive hardware!

Debugging

With the above-mentioned tools now copied over to the OBi, I was able to begin exploring more extensively. Recall from part 1 of this series the numerous vulnerabilities previously disclosed in some similar Obihai software components. I tested some of those same crash scenarios to see if the OBi200 (at its shipped firmware version) was similarly vulnerable. Here’s an example request attempting to overflow a static buffer used for preparing a command string sent to the OBi IPC socket:

As suspected, the OBi crashed and immediately rebooted. Let’s debug the crash.

The OBi’s watchdog daemon made it difficult to kill and relaunch the main binary with gdbserver, so instead I attached to the currently-running process using multi mode:

From another machine, I connected the gdb client:

Note the executed gdb was produced by crosstool-NG — not the one installed by the distro’s package manager. The host and target configuration must match your respective debugging environment.

Next, I attached to the running obiapp process and continued execution of the threads.

After running the example HTTP request above, the crash was caught — the dumped stack and registers are below:

Note the program generates a segmentation fault upon continuing to the invalid memory address 0x41414140 — just 0x00000001 away from the payload “AAAA” from the HTTP request above. This suggests that an attacker is possibly able to control the return address and interrupt program flow, ultimately leading to execution of malicious code. Unfortunately, before getting a chance to develop the exploit, I’d updated the OBi’s firmware which patched the overflow and I moved on to other areas.

Additional Findings

I wanted to touch on some other interesting areas of the OBi that weren’t fully explored. Let’s start with hard-coded keys — see the below pseudo code decompiled from the obiapp binary:

This function appears to decrypt Lua script modules sent from Obihai’s servers. Note the static string above copied into dest which is eventually passed as the data parameter in EVP_BytesToKey . The salt is passed into this function as the first parameter, though I didn’t confirm whether it was dynamic or NULL .

Another interesting finding from elsewhere in the decompiled code:

Two very interesting “secrets” above. The mention of a different model OBi left me unsure as to whether these variables were used in my model. The only usages I found were here:

Judging by the syslog messages, this seemed to be some kind of reporting functionality possibly sent back to Obihai.

There were a number of other areas I didn’t touch in the OBi — for example, the provisioning process through the cloud interface here (including Lua scripts) as well as potential crashes in the SIP/other UDP protocols. There are also a number of integrations (OBIEXTRAS) available for the device, making the attack surface quite vast.

Reported Issues

I identified several other vulnerabilities during the course of this research, including some of medium-risk as well as one critical issue. I’m still working with Obihai on these vulnerabilities and will likely disclose them after fixes are released.

Share this: Facebooktwittergoogle_pluslinkedin