Live lesson · progress saved to your account

Mobile & UPI App Security

India runs on phones and UPI. Open up an Android APK, read its manifest like an attacker, learn OWASP MASVS and MASTG, find hardcoded secrets, plaintext storage and missing certificate pinning, then trace a UPI payment through PSPs, NPCI and the banks and learn the collect-request, QR, fake-helpline, screen-sharing and SIM-swap frauds that abuse it.

intermediate120 minwalkthrough

Anyone can read this lesson. To submit answers and earn XP, create a free account.

TASK 01Mission briefing: ChaiPay's launch week

MESSAGE · from the CTO of ChaiPay (fictional) · Wednesday 18:40 "We launch our UPI app on Monday. An external tester says our APK 'leaks secrets', and our beta users already report people losing money to 'collect requests'. Tell me what's wrong with the app, and what's wrong with how users get fooled."

ChaiPay is a Bengaluru fintech building a UPI payments app for Android. Two problems, two halves of this room:

  1. App security: what an attacker can pull out of the app itself. Every user downloads a full copy of your app, and so does every attacker. An Android app ships as an APK, which is simply a ZIP archive:
An APK is just a ZIP file 0/6 unpacked
chaipay.apkunzip / apktool d

AndroidManifest.xml: Package name, permissions, components (activities, services, receivers, providers) and flags. Look for: debuggable / allowBackup / exported components.

Anything you ship inside the APK, every user (and every attacker) gets a copy of. Obfuscation slows readers down; it doesn't hide secrets.

  1. Payment fraud: UPI itself is well protected, but scammers trick people into authorising payments. Most UPI fraud abuses people, not the protocol.

By the end you'll deliver ChaiPay's launch verdict: MASVS-mapped findings plus the in-app warnings that stop the common scams.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 02Android app anatomy: the manifest and permissions

AndroidManifest.xml is the app's declaration to the system: its package name, the permissions it requests, its components and security-relevant flags. It is the first file a tester reads:

Reading AndroidManifest.xml like an attacker 4 risky lines

Debuggable in a release build: anyone with USB access can attach a debugger and read the app's private files with run-as.

Components: activities (screens), services (background work), broadcast receivers (events) and content providers (shared data). A component with android:exported="true" can be started by other apps; if it does something sensitive, protect it with a permission or don't export it.

Permissions: normal permissions (like INTERNET) are granted at install; dangerous permissions (SMS, contacts, location, camera) need the user's runtime consent. Request only what the app truly needs.

Release flags to check

  • android:debuggable="true" must never ship in a release build.
  • android:allowBackup="true" lets app data be included in device backups.
  • android:usesCleartextTraffic and the network security config control whether plain HTTP is allowed.

Every APK is signed by its developer. Android only installs an update if it is signed with the same key, so protecting the signing key protects your users.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 03OWASP MASVS and MASTG

The OWASP Mobile Application Security project gives testers two key documents:

  • MASVS (Mobile Application Security Verification Standard): what a secure app must do, organised into control groups.
  • MASTG (Mobile Application Security Testing Guide): how to test each control on Android and iOS, with techniques and tools.
OWASP MASVS: what to verify · MASTG: how to test it MASVS-STORAGE

Example test: Is the session token stored in plaintext SharedPreferences?

GroupFocus
MASVS-STORAGEsensitive data at rest
MASVS-CRYPTOcryptography and key management
MASVS-AUTHauthentication and authorisation
MASVS-NETWORKsecure communication
MASVS-PLATFORMinteraction with the OS and other apps
MASVS-CODEcode quality, input handling, dependencies
MASVS-RESILIENCEresisting reverse engineering and tampering
MASVS-PRIVACYuser privacy (added in v2.1)

A tester typically combines static analysis (decompiling the APK, reading code and config) with dynamic analysis (running the app on a test device, intercepting traffic, inspecting files it writes).

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 04Common mobile bugs: secrets, storage and pinning

1. Hardcoded secrets. API keys, signing secrets and passwords in code, strings.xml or assets/ can be pulled out by anyone with a decompiler such as jadx. Some keys are designed to be public (a maps key restricted to your app's package and signature); server secrets are not. Anything that proves "this request is trusted" must stay on the server.

2. Insecure storage. SharedPreferences are plain XML files in the app's private folder. That folder is protected by the OS, until the phone is rooted, the build is debuggable, or data leaves via backups:

Where the session token lives plaintext SharedPreferences

/data/data/in.chaipay.app/shared_prefs/session.xml

<map>

 <string name="auth_token">eyJhbGciOi…user=9876…</string>

 <string name="mobile">98xxxxxx10</string>

</map>

1. Debuggable build or rooted phone

2. Attacker runs: run-as / adb backup / file browser

3. Reads the token in plaintext

4. Replays the token: logged in as the user

Store as little as possible, never store the UPI PIN at all, and encrypt what you must keep with a key held in the Android Keystore.

Store less, never store the UPI PIN, and encrypt what you must keep with a key held in the Android Keystore.

3. Weak network security. All traffic should use TLS with proper certificate validation. Certificate pinning goes further: the app accepts only its own server's certificate or public key, so an interception proxy with a different certificate is refused:

Interception proxy vs certificate pinning no pinning
AppProxy (fake cert)APITLS

Since Android 7, apps ignore user-installed CAs by default unless their network security config opts in. Pinning goes further: the app only accepts its own server's key, so even a trusted-but-wrong certificate fails. Pin a backup key too, or a certificate rotation will lock users out.

Since Android 7 (API 24), apps don't trust user-installed CA certificates by default; a network security config can opt back in, which is fine for debug builds but risky in production.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 05How UPI works

UPI (Unified Payments Interface) is run by NPCI, the National Payments Corporation of India. It lets anyone pay instantly from their bank account using a phone:

Where ₹120 travels in two seconds Payer's UPI app
Payer's UPI appPSP appPayer PSPbank behind the appNPCI UPI switchcentral switchRemitter bankRavi's bankBeneficiary bankshop's bankConfirmationback to both apps

Ravi pays chai@okpaybank ₹120 and enters his UPI PIN (encrypted on the device).

VPA = Virtual Payment Address (UPI ID), like name@bankhandle. PSP = Payment Service Provider. NPCI = National Payments Corporation of India, which runs UPI.

  • VPA (Virtual Payment Address, your UPI ID) such as name@bankhandle hides your account number.
  • PSP (Payment Service Provider): the bank that connects a UPI app to the system. The app you use is a PSP app.
  • NPCI's UPI switch routes requests between banks.
  • The remitter bank (payer's bank) verifies the UPI PIN and debits; the beneficiary bank credits.
  • The UPI PIN is entered in a secure screen and sent encrypted; the app must never see, log or store it.

Two ways money moves:

  • Push (pay): you start the payment (scan a QR, enter a VPA) and approve with your PIN.
  • Pull (collect request): someone requests money from you, and approving it with your PIN sends money out.

The golden rule: you never need your PIN, a QR scan or an approval to RECEIVE money.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 06UPI fraud patterns and defences

Most UPI fraud doesn't break cryptography. It persuades users to authorise payments themselves.

Collect-request fraud: a "buyer" or "refund desk" sends a collect request and says approving it will receive money:

The collect-request trick step 1/5

Buyer on a resale app

I'll buy your old sofa for ₹8,000! Sending the money now via UPI.

Because of this fraud, NPCI has tightened collect requests over time, and apps now show clear “you are paying” warnings. The rule hasn't changed: PIN = pay.

QR scams: "scan to receive" codes, and fake QR stickers pasted over a shop's real one:

QR codes only ever pay scam

Scam: scanning a UPI QR and entering your PIN always PAYS. No QR ever receives money.

Other common patterns

  • Fake customer-care numbers planted in search results, maps listings and social media.
  • Screen-sharing / remote-access apps installed "to help you", letting the caller see PINs and OTPs.
  • SIM swap: a duplicate SIM issued to the attacker, who then receives your OTPs. A sudden, long "No service" is the warning sign.

What the app can do: show the payee's verified name before the PIN, show clear "you are PAYING ₹X" warnings on collect requests, detect screen-sharing during payments, keep help contacts inside the app, and add friction (cooling-off, limits) for new payees.

What users should do: read the name and amount before entering the PIN, never share PIN/OTP, use help inside the app, and report fraud immediately on 1930 / cybercrime.gov.in and to their bank.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 07Hands-on: reverse-engineer chaipay.apk

ChaiPay gave you a test build and a USB-connected test device. Decompile the APK, read the manifest and config files, search for secrets, then prove how the session token is stored.

Start with help. A file name is enough for cat once it's unique (for example cat config.json), and grep -ri secret chaipay searches every file.

Lab · Reverse-engineer chaipay.apk (authorised test build) 0/5 goals
tester@mobilelab
tester@mobilelab:~$ ChaiPay engagement: test device connected over USB · type 'help'
$

Goals

Decompile chaipay.apk

Spot the risky release flags in the manifest

Find the hardcoded secret

Find where cleartext HTTP is allowed

Prove the token is stored in plaintext on the device

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+30 XP

TASK 08Hands-on: ChaiPay fraud desk

Six beta users reported losing money, or nearly losing it. Name the fraud pattern behind each report (one is not fraud at all).

Lab · ChaiPay fraud desk: name the pattern classify six reports
#1Seller of a used phone gets an app prompt: 'Approve request from buyer@xyz for ₹15,000'. The buyer says approving is how he sends the money.
#2WhatsApp: 'Your ₹1,500 refund is ready. Scan this QR and enter your PIN to receive it.'
#3A failed payment; the user searches 'ChaiPay helpline', calls the top result. The 'agent' asks for the UPI PIN to reverse it.
#4A 'bank KYC officer' asks the user to install a remote-support app and open the UPI app 'so I can guide you'.
#5The phone suddenly shows 'No service' for hours. Next morning the user's UPI is active on another device and the account is empty.
#6At a tea stall the user scans the shop's own QR; the confirm screen shows 'Sharma Tea Stall', ₹120. They enter their PIN.

Answer the questions

+10 XP

+10 XP

+30 XP

TASK 09Final mission: ChaiPay's launch verdict

Monday is close. Map each finding to the MASVS control group the fix belongs to, so ChaiPay's developers can use the MASTG tests to verify it, then choose which in-app fraud protections ship with v1.0.

Final mission · ChaiPay launch verdict map findings, design warnings

Part A · Map each finding to its MASVS control group

M1Auth token saved in plaintext SharedPreferences
M2Payout signing secret hardcoded in assets/config.json
M3Server never expires sessions; payments don't re-check authentication
M4Cleartext HTTP allowed to the staging API; no pinning for production
M5PayConfirmActivity exported without a permission
M6Bundled image library has a publicly known vulnerability

Part B · Pick the in-app fraud protections to ship

Get the verdict accepted for the Pocket Guard badge and the room's XP.

Answer the questions

+10 XP

+10 XP

+30 XP