Digilocker OAuth Spoofing

Key Takeaways & TL;DR

DigiLocker's OAuth authorization screen trusted unvalidated base64-encoded app_name and partner_name query parameters. An attacker could construct malicious OAuth links displaying trusted banking names to deceive users during Aadhaar authorization.

🔍 Recently, I delved into the depth of Digilocker integration, specifically examining the OAuth flow. OAuth, a crucial component, facilitates user authorisation and resource owner authentication.

🔐 During this exploration, I stumbled upon a significant security concern. The login screen prompts users to input their Aadhaar number, displaying the client's branding—app name and organisation name—associated with Digilocker.

Legitimate DigiLocker consent screen with SBI Cards partner branding
Legitimate DigiLocker consent screen displaying app and organization name

🔍 Upon inspecting the OAuth initiation URL, I discovered parameters named app_name and partner_name, both base64 encoded and rendered directly on the OAuth screen without any server-side validation.

URL decoding the OAuth consent URL revealing app_name and partner_name parameters
Inspecting OAuth parameters: app_name and partner_name in the URL
Decoding app_name parameter revealing plaintext KYC Renewal
Decoding app_name base64 string -> "KYC Renewal"
Decoding partner_name parameter revealing plaintext SBI Cards and Payment Services Ltd.
Decoding partner_name base64 string -> "SBI Cards and Payment Services Ltd."

🚨 This poses a serious potential threat, as other clients could exploit this flaw to impersonate legitimate entities like banking institutions. By encoding their name in base64 and adding it to the parameters, they could mislead users into divulging sensitive information.

Base64 encoding arbitrary partner name LinkedIn Corporation
Encoding arbitrary partner name ("LinkedIn Corporation")
Base64 encoding arbitrary app name LinkedIn Test
Encoding arbitrary app name ("LinkedIn Test")
Spoofed DigiLocker OAuth consent screen displaying LinkedIn Test branding
Spoofed DigiLocker OAuth screen reflecting the attacker-controlled names

🛡️ The proposed solution to this critical issue is for Digilocker to fetch and render the app and organization names using the verified data collected during the client's registration process, rather than relying on query parameters.

🌐 The gravity of this situation cannot be overstated. Addressing this security loophole is imperative to ensure the integrity and trustworthiness of the Digilocker integration platform.

Ali Abbas

Software engineer who likes building close to the metal, reverse engineering APIs, and exploring client-side security.