Skip to content
Account takeover Write-up Intermediate

Problem Statement

The Android app encrypted a 4-digit login token on the client side, and the server had no brute-force protection. An attacker who knew a user ID could reverse the app's encryption logic, generate all possible encrypted tokens, and try them against the login endpoint to take over any account.

sanjay-gondaliya.medium.com

Published on sanjay-gondaliya.medium.com

During android application penetration testing, I found an interesting scenario where the android application built on top of React Native and source code was obfuscated. During the login process, the application asks for userid and token, the token is of 4 digits.

Sanjay Gondaliya, on sanjay-gondaliya.medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the client-side encryption of a low-entropy 4-digit token combined with no server-side rate limiting or lockout on the authentication endpoint.

Impact

An attacker who knows a victim's user ID could brute-force the encrypted 4-digit token and log in to that account, leading to account takeover.

What the attacker needed

Knowledge of the victim's user ID; ability to install a modified app or send requests directly; no server-side rate limiting

The fix

The server should enforce rate limiting and account lockout on the authentication endpoint, and the token should not rely on client-side encryption of a low-entropy value.

How it was found

  1. Capture the login request and observe that only an encrypted token and userId are sent to /user/authenticate.
  2. Extract the APK from the device and decompile it with apktool to locate the request in index.android.bundle.
  3. Use adb logcat with React Native filters and inject console.log statements into the bundle to trace the encryption function.
  4. Identify the pinEntrySucceeded function and its argument that produces the encrypted token via B(t, n).
  5. Modify the bundle to add a brute-force loop that logs encrypted tokens for a range of PINs, then rebuild, sign, and reinstall the app.
  6. Capture an invalid login request, load the generated tokens into Burp Intruder, and find the token that returns 200 OK.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The app turned a short 4-digit PIN into a scrambled value before sending it to the server. Because the scrambling happened inside the app, someone could take the app apart, work out how the scrambling was done, and then produce every possible scrambled PIN. The server did not limit how many login attempts were allowed, so trying all of them until one worked let the attacker log in as any user whose ID they knew.

What is Account takeover?

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.