Skip to content
Back to Blog
·9 min read·technology

OAuth 2.0 Security Misconfigurations Indian SaaS Must Fix

OAuth 2.0 misconfigurations — unvalidated redirect_uri, missing PKCE, absent state params — drive account takeovers in Indian SaaS. Fix all five gaps.

BR

Bachao.AI Research Team

Cybersecurity Research

Scan Your Attack Surface

Security exposure this creates

Unpatched vulnerabilities in your tech stack are the #1 entry point for breaches targeting Indian businesses. Here's what to watch.

The most dangerous OAuth 2.0 security misconfigurations are: unvalidated redirect_uri parameters, missing PKCE (Proof Key for Code Exchange), absent or predictable state parameters, over-broad token scopes, and implicit-flow token leakage through browser history. These flaws account for a disproportionate share of account-takeover and authorization-bypass incidents in web applications. According to OWASP's API Security Top 10, broken authentication and broken object-level authorization consistently top the charts — and OAuth misconfigurations feed directly into both categories. Indian SaaS teams integrating Google, Microsoft, or custom OAuth providers are shipping these gaps every week.


Why OAuth 2.0 Misconfigurations Are a Serious Threat

OAuth 2.0 was designed to delegate authorization — not to authenticate users. The distinction matters enormously in practice. When teams conflate the two, or when they implement OAuth flows without reading RFC 6749 and RFC 7636, they create attack surfaces that are easy to exploit and hard to detect in black-box testing alone.

In India, the threat surface has widened substantially. The Digital Personal Data Protection (DPDP) Act 2023 places legal obligations on data fiduciaries to ensure that access to personal data is properly authorized. An OAuth misconfiguration that lets an attacker hijack an authorization code and trade it for a token granting access to user PII is not merely a security finding — it is a potential DPDP compliance breach. Organizations handling personal data should review their authorization flows as part of any DPDP compliance program.

84%Web applications have at least one auth-related vulnerability (Verizon DBIR 2024)
34%Of all breaches involved stolen credentials or authentication weaknesses (Verizon DBIR 2024)

The OAuth 2.0 Authorization Code Flow — and Where Attackers Strike

The authorization code flow is the recommended pattern for server-side applications. But every step in the flow has a potential abuse vector.

graph TD U["User clicks Login"]:::normal --> C["Client app builds
authorization request"]:::normal C --> S["State param added
PKCE code verifier generated"]:::success C --> NS["State param missing
No PKCE — DANGEROUS"]:::danger S --> AS["Authorization Server
shows consent screen"]:::normal NS --> AS AS --> CB["Redirect to callback URI
with auth code"]:::normal CB --> RV["redirect_uri validated
exactly — SAFE"]:::success CB --> RU["redirect_uri open
or partial match — LEAKED"]:::danger RU --> ATK["Attacker intercepts code
via referrer or open redirect"]:::danger ATK --> TK["Attacker exchanges code
for access token"]:::danger RV --> EX["Client exchanges code
for token — server-side"]:::normal EX --> PKV["PKCE verifier checked
code binding confirmed"]:::success EX --> NOP["No PKCE check
code replay possible"]:::danger PKV --> AT["Access token issued
with minimum scope"]:::success NOP --> OB["Overly broad token
scope granted"]:::danger AT --> API["API call with token
in Authorization header"]:::success OB --> API API --> TL["Token stored in
localStorage — EXPOSED"]:::danger API --> SC["Token in httpOnly cookie
or memory — SAFE"]:::success classDef normal fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 classDef danger fill:#5f1e1e,stroke:#EF4444,color:#e2e8f0 classDef success fill:#1e3d2f,stroke:#10B981,color:#e2e8f0

Each red node in this flow represents an attack injection point. Let us examine each one in detail.


Misconfiguration 1 — Unvalidated or Partial redirect_uri

The redirect_uri is where the authorization server sends the authorization code after user consent. If your server performs only a partial match — say, checking that the URI starts with https://app.example.com — an attacker can register a malicious callback like https://app.example.com.attacker.io/callback and steal the code.

Some platforms are even more permissive, allowing any URI that contains the registered domain as a substring. This is a complete bypass of the redirect URI security model.

What to do:

    1. Register the exact, full callback URI including path and query parameters (where applicable).
    2. The authorization server must perform an exact string match, not a prefix or substring match.
    3. Reject any request where the redirect_uri in the token exchange differs from the one used in the authorization request.
    4. Audit every OAuth app you manage — especially those registered with Google Cloud Console, Azure AD, or any in-house identity provider.
🚨
DANGER
Open redirect vulnerabilities on your own domain amplify this risk. An attacker can chain an open redirect with a loosely validated redirect_uri to steal authorization codes even when prefix matching is used. Always audit open redirects alongside OAuth configuration.

Know your vulnerabilities before attackers do

Run a free VAPT scan — takes 5 minutes, no signup required.

Book Your Free Scan

Misconfiguration 2 — Missing or Absent PKCE

PKCE (Proof Key for Code Exchange, RFC 7636) was originally designed for native and mobile applications that cannot securely store a client secret. It has since been recommended for all public clients and, increasingly, for confidential clients as well.

PKCE works by binding the authorization request to a specific token exchange. The client generates a random code_verifier, hashes it into a code_challenge, and sends the challenge with the authorization request. When exchanging the code for a token, the server demands the original verifier and checks the hash. Without this binding, a stolen authorization code can be exchanged by any party.

Many Indian SaaS teams implement only the client secret for server-side apps and skip PKCE entirely. This leaves code interception attacks viable in any scenario where the authorization code is exposed — via referrer headers, browser history, or network interception.

⚠️
WARNING
If you are building an SPA (React, Vue, Angular) or a mobile app, you have no safe place to store a client secret. PKCE is not optional for you — it is the only mechanism preventing authorization code theft. The implicit flow, which was the old alternative, is now deprecated by OAuth 2.0 Security Best Current Practice (RFC 9700).

Misconfiguration 3 — Missing or Predictable State Parameter

The state parameter is a CSRF token for the OAuth flow. The client generates a random, unguessable value, sends it with the authorization request, and validates it when the authorization server redirects back with the code. If state is missing, an attacker can trick a logged-in user into authorizing a request the attacker crafted — the classic CSRF-against-OAuth attack.

Many teams either omit the state entirely, use a static value ("state=login"), or use the user's email or session ID as the state. All three patterns are exploitable.

The state value must be:

    1. Cryptographically random (at minimum 128 bits of entropy).
    2. Stored server-side or in a signed, tamper-evident cookie.
    3. Validated strictly on the callback — if absent or mismatched, the flow must be aborted.

Misconfiguration 4 — Token Leakage via Storage and Headers

Access tokens are bearer credentials. Whoever holds the token can act as the user. Yet many applications store tokens in localStorage, log them in server-side application logs, or expose them in Referer headers when navigating away from pages that embed the token in a URL fragment.

The OAuth 2.0 Threat Model (RFC 6819) explicitly calls out token leakage as a high-severity threat. The implicit flow, which returns access tokens directly in URL fragments, made this problem structural — which is why the implicit flow is now deprecated.

Secure token storage patterns:

    1. For SPAs: store tokens in memory (a JavaScript variable), never in localStorage or sessionStorage.
    2. Use httpOnly, Secure, SameSite=Strict cookies for session tokens on server-rendered applications.
    3. Never log tokens in application or access logs — use structured logging with field-level redaction.
    4. Rotate tokens aggressively and implement short expiry windows.

Misconfiguration 5 — Overly Broad Token Scopes

OAuth scopes define what a token can do. Teams frequently request the broadest available scope during development ("just use admin so we don't hit permission errors") and never narrow it before going to production.

A token with admin-level scopes for a Google Workspace integration, for instance, can read all Drive files, manage users, and send email on behalf of any user in the organization. If that token is compromised — through any of the attack vectors above — the blast radius is catastrophic.

💡
TIP
Apply the principle of least privilege to every OAuth token. Request only the scopes you will use in that specific flow. If a user grants read access to their calendar, do not request write access. Audit your OAuth application registrations quarterly and remove unused scopes.

OAuth Vulnerability Distribution in Real-World Audits

Based on findings patterns reported by OWASP and security researchers across web application audits:

pie title OAuth Vulnerability Types in Web App Security Audits "Redirect URI issues" : 31 "Missing PKCE" : 24 "Open redirect chains" : 18 "Token exposure" : 16 "Improper scope grants" : 11

Redirect URI issues dominate because they are often misconfigured at the identity provider registration level — a step developers frequently rush. PKCE omission is pervasive in Indian SaaS teams that integrated OAuth before PKCE became best practice.


OAuth Security Control Checklist

Use this checklist during code review and before any new OAuth integration goes to production:

ControlStatus CheckRisk if Missing
Exact redirect_uri matchVerify at authorization server config levelAuthorization code theft
PKCE enabledCheck code_challenge in auth request logsCode interception and replay
State parameterVerify random generation and server-side validationCSRF against OAuth flow
Implicit flow disabledConfirm only auth code flow in useToken leakage via URL fragment
Minimum scopeAudit registered scopes quarterlyBlast radius on token compromise
Token not in localStorageCheck frontend storage and network tabXSS token exfiltration
Tokens excluded from logsVerify log sanitization rulesToken exposure in log storage
Short token expiryCheck expires_in values in token responsesLong window for stolen token abuse
Token rotation on useVerify refresh token rotation policyRefresh token replay attacks
Audience validationConfirm aud claim checked on resource serverToken substitution attacks

What a Proper OAuth Security Audit Covers

A superficial scan will find open redirects but will miss PKCE bypass, state-param CSRF, or audience claim misvalidation. A thorough OAuth security audit requires whitebox access — source code review of the authorization request construction, the callback handler, and the token storage layer.

This is where VAPT tools that combine dynamic scanning with static analysis add material value. A free VAPT scan can surface redirect_uri issues and token exposure in HTTP responses; deeper misconfigurations — PKCE bypass, predictable state — require code-level review.

Bachao.AI surfaces OAuth-related findings as part of its web application security assessment, flagging redirect validation gaps, implicit flow usage, and token storage antipatterns. Dhisattva AI Pvt Ltd built this capability for Indian SaaS teams scaling OAuth integrations without dedicated security engineering resources.


India-Specific Context — Why This Matters Now

Three factors make OAuth security urgent for Indian SaaS right now:

DPDP Act obligations: Under the Digital Personal Data Protection Act 2023, data fiduciaries must implement appropriate technical safeguards. An OAuth misconfiguration enabling unauthorized access to personal data is a potential data breach with regulatory consequences.

Third-party integrations proliferating: Indian B2B SaaS is deeply integrated with Google Workspace, Microsoft 365, Zoho, and Razorpay — all via OAuth. Each integration is an attack surface.

CERT-In advisories: CERT-In's 2024 advisory on authentication weaknesses highlighted OAuth and SAML misconfigurations as recurring findings across critical sector assessments.

🛡️
SECURITY
The most commonly exploited OAuth vulnerability in India-facing SaaS platforms in 2024 was not a zero-day — it was a developer convenience shortcut: accepting any redirect_uri that starts with the registered domain. Fix this in your identity provider console before you do anything else.

🎯Key Takeaway
OAuth 2.0 is not plug-and-play. Every integration requires deliberate security decisions: exact redirect_uri validation, PKCE for all public clients, cryptographically random state parameters, minimum scopes, and secure token storage. Indian SaaS teams that skip these controls are one targeted phishing campaign away from a full account takeover. Audit your OAuth flows before an attacker does.

Frequently Asked Questions

What is the most common OAuth 2.0 security misconfiguration in Indian SaaS applications?
The most common finding is an unvalidated or partially validated redirect_uri. Many teams configure their OAuth app to accept any URI starting with their domain, which allows attackers to redirect authorization codes to attacker-controlled endpoints. Fix: enforce exact string matching at the authorization server.
Is PKCE required if I'm using a confidential client with a client secret?
PKCE is mandatory for public clients (SPAs, mobile apps) and is strongly recommended for confidential clients as well. OAuth 2.0 Security Best Current Practice (RFC 9700) recommends PKCE universally because it protects against code interception even when the channel is not fully trusted. Many modern identity providers enforce it by default.
Can localStorage be used to store OAuth access tokens in a React SPA?
No. localStorage is accessible by any JavaScript running on the page, including injected scripts from XSS attacks. Store tokens in memory (a module-level variable or React state) and use silent token renewal via a hidden iframe or refresh token flow. For added protection, use httpOnly cookies with a backend-for-frontend (BFF) pattern.
What is an OAuth state parameter CSRF attack?
If your application does not generate and validate a state parameter, an attacker can trick a user into completing an OAuth flow that the attacker initiated. The attacker crafts an authorization request, pauses before the redirect, then sends the partially completed flow URL to the victim. The victim authenticates, and the resulting token is linked to the attacker's session. Always generate a random state, store it server-side, and validate it strictly on callback.
Does fixing OAuth misconfigurations count as a DPDP Act compliance control?
Yes. The DPDP Act 2023 requires data fiduciaries to implement appropriate technical safeguards to protect personal data. OAuth misconfigurations that enable unauthorized access to personal data are a technical safeguard failure. Remediation should be documented as part of your DPDP compliance program. See the Bachao.AI DPDP compliance resource at /dpdp-compliance.
How do I audit which OAuth scopes my application is requesting?
Review your OAuth client registration at each identity provider (Google Cloud Console, Azure App Registrations, etc.) and compare the registered scopes against the scopes your application actively uses in production. Remove any scope your application does not need. Also inspect the scope field in token introspection responses or JWT claims to confirm what is actually being granted at runtime.
BR

Bachao.AI Research Team

Cybersecurity Research

AI-powered security research and threat intelligence from the Bachao.AI team. Covering the latest vulnerabilities, CVEs, and cybersecurity developments affecting Indian businesses.

Get cybersecurity insights for Indian SMBs

Weekly vulnerability alerts, DPDP compliance tips, and security guides. No spam — unsubscribe anytime.

We respect your privacy. Your email is never shared.

Find out if you're exposed to this class of threat

Free automated scan — risk score in under 2 hours. No credit card required.

Scan Your Attack Surface
Find your vulnerabilitiesStart free scan →