OTP Bypass through Session Manipulation

5 months ago 41
BOOK THIS SPACE FOR AD
ARTICLE AD

To understand how the server crafts session cookies, I used a valid OTP code during testing. Here’s how the process unfolded:

Using Valid Credentials and OTP:

After entering valid credentials and a valid OTP code, I observed the server’s response. The response included a session cookie crafted using PIDM and WEBID values from the POST request. For example:

valid OTP code in “VerC”

The server’s response was:

Set-Cookie: SESSID=QlZOWEY3MTIzNDcyNA==Decoding the Session Cookie:

Decoding this Base64 encoded cookie (QlZOWEY3MTIzNDcyNA==) revealed:

BVNXF71234724

This confirmed that the PIDM and WEBID were used to create the session cookie.

Crafting a Session Cookie:

With this knowledge, it was clear that by crafting a session cookie using PIDM and WEBID, an attacker could bypass the OTP. Here’s how:

Invalid OTP and Manual Crafting:

Even if an invalid OTP code is used, the attacker can craft a session cookie manually by combining PIDM and WEBID, encoding them using Base64, and manipulating the response to include this session cookie. This bypasses the need for a valid OTP.

Here’s the crafted session cookie process:

PIDM=1234724
WEBID=BVNXF7
Combined: BVNXF71234724
Base64: QlZOWEY3MTIzNDcyNA==

The crafted cookie can be used to manipulate the server response.

Observing Redirection to Dashboard:

After entering a valid OTP code, I noticed the server response contained:

<HTML>
<HEAD>
<meta http-equiv="refresh" content="0;url=/app/dashboard?welcome=true">
</HEAD>
</HTML>

Here are the detailed steps to exploit the vulnerability:

Log in with Valid Credentials:

Enter valid credentials on the login page to be redirected to the OTP page.

Submit Any OTP:

Enter a random number in the OTP input field and capture the POST request:

Random number in VerC

Crafting the Session Cookie:

Combine PIDM and WEBID values:

BVNXF71234724
Base64: QlZOWEY3MTIzNDcyNA==

Use this Base64 encoded string as the session cookie.

Manipulating the Response:

Intercept the server’s response and modify it to include the crafted session cookie:

When you send the Post request, intercept the response and add the cookie you craft

Access the Dashboard:

The manipulated response, containing the crafted session cookie, will redirect you to the dashboard, effectively bypassing the OTP verification.

Read Entire Article