剣 KENSAI
← ब्लॉग पर वापस
ऑथेंटिकेशन सिक्योरिटी 3 अप्रैल 2026 22 मिनट पढ़ें

OAuth सिक्योरिटी टेस्टिंग चेकलिस्ट: हाई-इम्पैक्ट ऑथेंटिकेशन बग्स ढूँढना

OAuth 2.0 वल्नरेबिलिटीज़ लगातार क्रिटिकल-सिविरिटी बग बाउंटी पेआउट्स के चार्ट्स में शीर्ष पर रहती हैं। OAuth मिसकॉन्फ़िगरेशन के ज़रिए एक ही अकाउंट टेकओवर पूरे संगठनात्मक कॉम्प्रोमाइज़ में बदल सकता है — और ये बग्स अरबों लोगों द्वारा उपयोग किए जाने वाले एप्लिकेशंस में दिखाई देते हैं।

$10K-$100K
OAuth ATO पेआउट्स
क्रिटिकल
इम्पैक्ट क्लासिफ़िकेशन
4.2B+
वैश्विक स्तर पर प्रभावित यूज़र्स
OWASP A07
ID और Auth फ़ेल्योर्स

सिक्योरिटी टेस्टिंग के लिए OAuth 2.0 फ़ंडामेंटल्स

ℹ️ OAuth 2.0 फ़्लोज़

यह समझना कि टार्गेट किस फ़्लो का उपयोग करता है, यह निर्धारित करता है कि किन अटैक्स का परीक्षण करना है। Authorization Code फ़्लो (PKCE के साथ) सबसे सुरक्षित और सबसे आम है। अब डेप्रिकेटेड Implicit फ़्लो में कई वल्नरेबिलिटीज़ हैं। Client Credentials (मशीन-से-मशीन) का अपना अटैक सर्फ़ेस है। कभी प्रोडक्शन में उपयोग न करें: Resource Owner Password Credentials

मुख्य OAuth कॉम्पोनेंट्स


सेक्शन 1: Authorization Code इंटरसेप्शन

टेस्ट 1.1 — redirect_uri में Open Redirect

यदि authorization server redirect_uri को अपर्याप्त सटीकता के साथ वैलिडेट करता है, तो एक हमलावर authorization code को अपने नियंत्रित सर्वर पर रीडायरेक्ट कर सकता है।

# Legitimate request
https://auth.example.com/oauth/authorize?
  client_id=app123&
  redirect_uri=https://app.com/callback&
  response_type=code&state=xyz

# Attack attempts
# 1. Path traversal
redirect_uri=https://app.com/callback/../../../evil.com/steal

# 2. Additional path
redirect_uri=https://app.com.evil.com/callback

# 3. Fragment bypass
redirect_uri=https://app.com/callback%23@evil.com

# 4. Query string bypass
redirect_uri=https://app.com/callback?next=https://evil.com

टेस्ट 1.2 — State पैरामीटर वैलिडेशन

⚠️ Missing/Weak State = OAuth पर CSRF

state पैरामीटर OAuth फ़्लोज़ के दौरान CSRF अटैक्स को रोकता है। यदि अनुपस्थित या अनुमान लगाने योग्य है, तो एक हमलावर पीड़ितों को उनके अकाउंट्स को हमलावर-नियंत्रित पहचानों से कनेक्ट करने के लिए मजबूर कर सकता है — जो अकाउंट टेकओवर को सक्षम बनाता है।

# Check if state is:
# 1. Present in authorization request
# 2. Validated on callback
# 3. Cryptographically random (not sequential/predictable)
# 4. Single-use (replayed states should be rejected)

# Test: replay the same state parameter
curl -s "https://app.com/oauth/callback?code=VALID_CODE&state=PREVIOUSLY_USED_STATE"
# Should return: error (state already used)

टेस्ट 1.3 — Code Reuse

# Authorization codes must be single-use
# Test by replaying the code after first exchange:

# First use (legitimate)
POST /oauth/token
code=AUTH_CODE_123&grant_type=authorization_code&...

# Second use (should fail)
POST /oauth/token
code=AUTH_CODE_123&grant_type=authorization_code&...
# Expected: {"error": "invalid_grant"}

सेक्शन 2: PKCE बायपास टेस्टिंग

टेस्ट 2.1 — PKCE एनफ़ोर्समेंट

PKCE authorization code इंटरसेप्शन अटैक्स को रोकता है। यदि PKCE सपोर्ट करने वाला सर्वर इसे एनफ़ोर्स नहीं करता, तो पब्लिक क्लाइंट्स भेद्य हैं।

# Start flow WITH PKCE (legitimate)
code_verifier = generate_random_string(64)
code_challenge = base64url(sha256(code_verifier))

GET /authorize?
  code_challenge=abc123&
  code_challenge_method=S256&...

# Attack: exchange code WITHOUT providing code_verifier
POST /token
grant_type=authorization_code&
code=INTERCEPTED_CODE&
redirect_uri=https://legitimate-app.com/callback
# Missing: code_verifier
# If this succeeds -> PKCE not enforced -> क्रिटिकल वल्नरेबिलिटी

टेस्ट 2.2 — code_challenge_method डाउनग्रेड

# Attempt to downgrade from S256 to plain (less secure)
GET /authorize?
  code_challenge=ACTUAL_CODE_VERIFIER&
  code_challenge_method=plain&...
  
# If accepted: server may be using plain instead of S256
# Then exchange with code_verifier = original plain text
POST /token
code_verifier=ORIGINAL_PLAIN_TEXT&...

सेक्शन 3: टोकन वल्नरेबिलिटीज़

टेस्ट 3.1 — Referrer के ज़रिए Access Token लीकेज

⚠️ Fragment बनाम Query टोकन हैंडलिंग

Implicit फ़्लो में (डेप्रिकेटेड लेकिन अभी भी पाया जाता है), URL फ़्रैगमेंट्स में access tokens (#access_token=...) Referer हेडर्स में नहीं भेजे जाते — लेकिन क्वेरी पैरामीटर्स में टोकन (?access_token=...) भेजे जाते हैं। हमेशा जाँचें कि टोकन URLs में कैसे दिखाई देते हैं।

टेस्ट 3.2 — Token Scope एस्केलेशन

# Request minimal scope
GET /authorize?scope=read:email&...

# After getting access token, test unauthorized API calls
GET /api/user/delete
Authorization: Bearer ACCESS_TOKEN_WITH_READ_SCOPE
# Should return 403, not 200

टेस्ट 3.3 — JWT Access Token वल्नरेबिलिटीज़

# If access tokens are JWTs, test:

# 1. Algorithm confusion (RS256 -> HS256)
header = {"alg": "HS256", "typ": "JWT"}
# Sign with the public key as HMAC secret

# 2. None algorithm
header = {"alg": "none", "typ": "JWT"}
# Some libraries accept unsigned tokens

# 3. Kid injection (if 'kid' is used)
header = {"alg": "HS256", "kid": "' OR 1=1--"}
# SQL injection in kid parameter

# Tools:
# jwt_tool: python3 jwt_tool.py TOKEN -T (tamper)
# jwt-cracker: for weak secrets

टेस्ट 3.4 — Refresh Token Rotation बायपास

# Test if old refresh tokens are invalidated after rotation
POST /token
grant_type=refresh_token&refresh_token=OLD_REFRESH_TOKEN

# If this returns a new token -> old token not invalidated
# Attacker who stole old refresh token can still get new access tokens

सेक्शन 4: अकाउंट टेकओवर सिनैरियोज़

टेस्ट 4.1 — बिना ईमेल वेरिफ़िकेशन के OAuth अकाउंट लिंकिंग

💡 हाई-इम्पैक्ट फ़ाइंडिंग पैटर्न

यदि एक पीड़ित ईमेल/पासवर्ड के साथ साइन अप करता है (ईमेल: victim@gmail.com) और एक हमलावर उसी ईमेल के साथ एक Google OAuth अकाउंट को लिंक करके पीड़ित के अकाउंट को टेकओवर कर सकता है — बिना Google द्वारा स्वामित्व सत्यापित किए — तो यह एक क्रिटिकल अकाउंट टेकओवर है। यह विशेष रूप से उन प्लेटफ़ॉर्म्स में आम है जो कई ऑथ प्रोवाइडर्स को लिंक करने की अनुमति देते हैं।

टेस्ट 4.2 — Pre-Account टेकओवर

# Attack scenario:
# 1. Attacker creates account with victim@example.com (before victim registers)
# 2. Attacker links their OAuth provider to this email
# 3. When victim later registers with Google OAuth using victim@example.com
# 4. Victim gains access to attacker's pre-created account (or vice versa)

# Test by:
# 1. Register account with victim's email (before they exist)
# 2. Connect OAuth from different email
# 3. Try to access victim's future account

टेस्ट 4.3 — Token Fixation

# Some implementations allow specifying access_token in request
# or don't properly bind tokens to sessions

# Test: force a known token value
GET /oauth/callback?access_token=KNOWN_VALUE

# If the app accepts and uses this token -> token fixation

टेस्ट 4.4 — Sub/Email Claim कन्फ़्यूज़न

# If an application ties accounts to email (not sub):
# Register malicious OAuth provider with victim's email as their 'email' claim
# Some providers let you set arbitrary email claims

# Test by creating custom OAuth provider with:
{
  "sub": "attacker-unique-id",
  "email": "victim@example.com",
  "email_verified": true
}

सेक्शन 5: Authorization Server वल्नरेबिलिटीज़

टेस्ट 5.1 — Client Authentication कमज़ोरी

# Confidential clients must authenticate with client_secret
# Test if client_secret is optional:
POST /token
grant_type=authorization_code&
code=CODE&
client_id=CONFIDENTIAL_CLIENT_ID&
# Missing: client_secret
# If this works -> client authentication not enforced

टेस्ट 5.2 — Device Authorization Flow दुरुपयोग

# Device flow (for input-constrained devices) can be abused for phishing
POST /device/code
client_id=LEGITIMATE_CLIENT

# Returns user_code that victim enters at verification_uri
# Attacker uses this for social engineering:
# "Enter code XXXX-XXXX at accounts.target.com/activate"

पूर्ण OAuth टेस्टिंग चेकलिस्ट

प्री-ऑथराइज़ेशन फ़ेज़

Authorization Request टेस्ट्स

Token Exchange टेस्ट्स

Token Security टेस्ट्स

Account Linking टेस्ट्स


रियल-वर्ल्ड OAuth बग उदाहरण

बग टाइपप्लेटफ़ॉर्मप्रभावबाउंटी
redirect_uri bypassFacebookअकाउंट टेकओवर$25,000
State पैरामीटर मिसिंगAirbnbCSRF → ATO$8,000
Code ReuseMicrosoftरीप्ले अटैक$15,000
JWT none algorithmAuth0Auth बायपास$10,000
Email Confusion ATOSlackअकाउंट टेकओवर$20,000
PKCE एनफ़ोर्स्ड नहींमल्टीपलCode Interception$5,000+

टेस्टिंग टूल्स

OAuth सिक्योरिटी टेस्टिंग को स्वचालित करें

KENSAI का AI-संचालित स्कैनर authorization code इंटरसेप्शन, PKCE बायपास, टोकन वल्नरेबिलिटीज़, और अकाउंट टेकओवर सिनैरियोज़ के लिए आपके OAuth इम्प्लीमेंटेशंस का स्वचालित रूप से परीक्षण करता है।

मुफ़्त स्कैन शुरू करें →

सिक्योरिटी वैकल्पिक नहीं है।

🗡️ KENSAI टीम

संबंधित लेख

Smart Slider WordPress-CVE betrifft 500K Websites, TP-Link & Cisco IOS patchen k الإنتربول يفكك 45,000 عنوان IP خبيث، جوجل تصلح CVE-2026-28756: Cross-Site Scripting (XSS) in Zohocorp ManageEngine Exchange Rep