Authentication Bypass, tek bir exploit değil, kimlik doğrulama mekanizmasındaki zafiyetlerin bütünüdür. Gerçek dünyada auth bypass çoğu zaman workflow hatası, trust boundary ihlali veya eksik kontrolden kaynaklanır.
Authentication Bypass Katmanları:
Authentication bypass genelde 3 katmanda oluşur:
Katman Açıklama Örnek
Logic Flaw İş akışı hatası Email değiştirme re-auth yok
Authorization Missing Yetki kontrolü eksik IDOR, role escalation
Injection Enjeksiyon zafiyeti SQL/NoSQL injection
1. Logic Flaw Authentication Bypass (En Yaygın - %60 Bug Bounty)
Gerçek dünyada auth bypass'ların çoğu logic bug + trust issue + missing check kombinasyonudur.
Örnekler:
a. Email Change Without Re-Auth:
http
POST /api/user/email
{
"new_email": "[email protected]"
}
# ❌ Şifre veya 2FA onayı yok
b. Password Reset Without Ownership Check:
http
POST /api/password/reset
{
"email": "[email protected]",
"new_password": "saldirgan123"
}
# ❌ E-posta sahipliği doğrulanmıyor
c. Role Upgrade Flow Missing Validation:
http
POST /api/user/upgrade
{
"user_id": 123,
"role": "admin"
}
# ❌ Sadece UI'da kontrol, backend'de eksik
d. "Login doğru ama session yanlış bağlanmış":
http
POST /login
{
"username": "kurban",
"password": "dogru"
}
# ✅ Login başarılı
# ❌ Session farklı kullanıcıya bağlanıyor
e. "2FA var ama sadece UI'da kontrol ediliyor":
http
# Frontend: 2FA geçildi ✅
POST /api/sensitive-action
{
"action": "transfer",
"amount": 1000
}
# Backend: 2FA kontrolü YOK ❌
Koruma:
python
def change_email(user_id, new_email, password):
# 1. Re-auth kontrolü
if not verify_password(user_id, password):
raise Exception("Invalid password")
# 2. Email sahipliği kontrolü
if not verify_email_ownership(user_id, new_email):
raise Exception("Email ownership verification required")
# 3. 2FA kontrolü (opsiyonel)
if not verify_2fa(user_id):
raise Exception("2FA verification required")
# 4. Email değiştir
update_email(user_id, new_email)
2. Business Logic Authentication Bypass
En kritik eksik kategori. Bu, bug bounty'lerde en sık görülen auth bypass türüdür.
Örnekler:
a. Multi-step Flow Bypass:
http
# Step 1: Email doğrulama
POST /verify/email → { "verified": true }
# Step 2: Password reset
POST /reset/password → { "success": true }
# ❌ Step 1 bypass edilebilir mi?
# Saldırgan direkt Step 2'ye gider
b. "Skip 2FA" Endpoint:
http
POST /api/auth/skip-2fa
{
"user_id": 123,
"skip_reason": "trusted_device"
}
# ❌ İş mantığı hatası
c. Password Change Without Old Password:
http
POST /api/user/password
{
"new_password": "saldirgan123"
}
# ❌ Eski şifre kontrolü yok
Koruma:
python
def multi_step_flow_validator(request):
# Her adımda önceki adım doğrulaması
if not session.get('email_verified'):
raise Exception("Email verification required")
if not session.get('2fa_verified'):
raise Exception("2FA verification required")
# Sonraki adıma geç
process_password_reset()
3. Session / Cookie Hijacking — En Gerçek Saldırı
Modern Gerçek: XSS varsa → auth bypass zaten "game over". HttpOnly sadece cookie theft'i zorlaştırır, XSS'i çözmez.
Gerçek Riskler:
Risk Açıklama
XSS Session cookie çalma veya session action yapma
MITM Ağ üzerinden session ele geçirme (HTTPS zorunlu)
Malware Endpoint compromise
Session Reuse Aynı session farklı cihazlarda kullanım
Koruma:
python
# Session security
session.cookie.httponly = True
session.cookie.secure = True
session.cookie.samesite = 'Strict'
session.timeout = 3600 # 1 saat
# Anomaly detection
def detect_session_anomaly(session, request):
# Impossible travel
if is_impossible_travel(session['last_ip'], request.remote_addr):
kill_session(session)
return False
# Device fingerprint değişimi
if session.get('fingerprint') != generate_fingerprint(request):
# Risk skoru artır, hemen kill yapma
risk_score = calculate_risk_score(session, request)
if risk_score > 0.8:
kill_session(session)
return False
return True
4. Session Fixation — Modern Dünyada Azalan Risk
Çünkü: Framework'ler otomatik rotate ediyor:
Django
Express-session
Spring Security
Gerçek Exploit Condition:
Session rotation yok
Login sonrası session reuse var
Session ID tahmin edilebilir
Koruma:
python
def login_success(user):
# Framework'ün session regenerate fonksiyonu
session.regenerate() # Django, Express, Spring
# Güçlü session ID entropy
session['user_id'] = user.id
session['ip_address'] = request.remote_addr
session['user_agent'] = request.user_agent.string
5. IDOR — Aslında Auth Bypass Değil, AuthZ Bypass
En Önemli Düzeltme:
Konsept Gerçek Adı
IDOR Broken Access Control (BAC)
Auth Bypass Authentication Failure
IDOR ≠ Login Bypass
IDOR = Yetki Bypass
Örnek:
http
# Bu bir auth bypass DEĞİL
GET /api/users/123
# Kullanıcı login yapmış ama başka kullanıcıya erişiyor
# Bu bir auth bypass
GET /api/users
# Kullanıcı login yapmadan verilere erişiyor
Koruma:
python
def get_user_profile(user_id, current_user):
# Authentication
if not current_user.is_authenticated:
abort(401)
# Authorization (IDOR koruması)
if user_id != current_user.id and not current_user.is_admin:
abort(403)
return User.objects.get(id=user_id)
6. JWT Manipulation — Gerçek Dünya Farkı
Yanlış Yaygın Düşünce:
json
{ "alg": "none" }
Modern sistemlerde çoğu library bunu zaten reject eder.
Gerçek Riskler:
Risk Açıklama
Weak Secret Brute force ile secret tahmin etme
Key Reuse Aynı secret farklı servislerde
Token Leakage Log, URL, cache'de token sızıntısı
Missing Audience Check aud claim kontrolü yok
Missing Issuer Check iss claim kontrolü yok
Koruma:
python
def validate_jwt(token):
payload = jwt.decode(
token,
secret,
algorithms=['HS256'],
audience='api.hedef.com', # Audience check
issuer='auth.hedef.com', # Issuer check
options={
'require': ['exp', 'iat', 'sub', 'aud', 'iss']
}
)
return payload
7. 2FA Bypass — En Gerçek Exploit Alanı
En Sık Gerçek Bypass:
text
2FA sadece "frontend step"
Backend "verified=true" trust ediyor
Gerçek Exploit Pattern:
http
# 1. 2FA geç
POST /verify-2fa → { "verified": true }
# 2. Login endpoint role veriyor (2FA kontrolü yok)
POST /api/login → { "role": "admin" }
# ❌ Backend'de 2FA kontrolü eksik
Koruma:
python
def perform_sensitive_action(user_id, action, data):
# 1. Authentication kontrolü
if not is_authenticated(user_id):
abort(401)
# 2. 2FA kontrolü (server-side)
if requires_2fa(action):
if not is_2fa_verified(user_id):
abort(403, "2FA required")
# 3. Yetkilendirme kontrolü
if not has_permission(user_id, action):
abort(403)
# 4. İşlemi gerçekleştir
return execute_action(action, data)
8. OAuth Bypass — En Önemli Modern Issue
Kritik Gerçekler:
Yanlış Odak Gerçek Exploit
Redirect URI manipulation her zaman çalışır Missing PKCE, Missing State Validation, Token Reuse
Gerçek OAuth Exploit'leri:
a. Missing PKCE:
http
# PKCE olmadan code interception riski
GET /authorize?client_id=app&redirect_uri=https://hedef.com/callback
b. Missing State Validation:
http
# CSRF on OAuth
GET /authorize?state=weak_guessable
c. Token Reuse (Code Replay):
http
# Aynı authorization code tekrar kullanımı
POST /token?code=abc123 # İlk kullanım
POST /token?code=abc123 # Tekrar kullanım ❌
d. Misconfigured Audience:
json
{
"aud": "https://api.hedef.com" # Doğru değil
}
Koruma:
python
# OAuth State Validasyonu
state = secrets.token_urlsafe(32)
session['oauth_state'] = state
# PKCE
code_verifier = secrets.token_urlsafe(64)
code_challenge = hashlib.sha256(code_verifier.encode()).hexdigest()
# Token Reuse Detection
redis.setex(f"code_used:{code}", 3600, 'used')
9. API Auth Bypass — Gerçek Dünya Farkı
En Önemli Gerçek: Header spoofing tek başına çalışmaz.
http
X-Forwarded-For: 127.0.0.1
Sadece şu durumda çalışır: Backend proxy trust ediyorsa.
Gerçek Bug: Trust Boundary Misconfiguration
Koruma:
python
def get_client_ip(request):
# Sadece trusted proxy'lerden gelen header'ları kabul et
TRUSTED_PROXIES = ['10.0.0.1', '10.0.0.2']
if request.remote_addr in TRUSTED_PROXIES:
return request.headers.get('X-Forwarded-For', request.remote_addr)
return request.remote_addr
10. GraphQL Auth Bypass — Modern Gerçek
Yanlış: "GraphQL query = bypass"
Gerçek Exploit:
Resolver-level auth missing
Field-level authorization missing
Örnek:
graphql
# user endpoint secure
query {
user(id: 123) {
name
email
# ❌ email field exposed without auth
}
}
Koruma:
python
def resolve_user(self, info, user_id):
# Authentication kontrolü
if not info.context.get('user'):
raise Exception("Authentication required")
# Authorization kontrolü
user = User.objects.get(id=user_id)
if user.id != info.context['user'].id and not is_admin(info.context['user']):
raise Exception("Not authorized")
return user
# Field-level authorization
def resolve_email(self, info, user):
# Sadece kendi email'ini görebilir
if user.id != info.context['user'].id:
return None
return user.email
11. Injection Tabanlı Bypass (SQL / NoSQL)
Doğru Yaklaşım:
Prepared statements
ORM param binding
Kritik Yanlış Düşünce: "SQL injection = login bypass"
Gerçek:
Modern sistemlerde SQLi → daha çok data exfiltration
Login bypass sadece zayıf legacy sistemlerde
Koruma:
python
# SQL injection koruması
cursor.execute(
"SELECT * FROM users WHERE username = %s AND password = %s",
(username, password) # Param binding
)
# NoSQL injection koruması
User.objects.filter(username=username, password=password) # Django ORM
Authentication Bypass Haritası:
text
[Client Trust Issues]
↓
Frontend validation bypass
[Session Issues]
↓
fixation / reuse / weak binding
[Backend Logic]
↓
missing auth checks
[Authorization layer]
↓
IDOR / role escalation
[Injection layer]
↓
SQL / NoSQL injection
Production-Grade Protection (Minimum Secure Auth Stack):
yaml
1. Server-side session validation:
- HttpOnly, Secure, SameSite cookies
- Session ID regenerate on login
- Session timeout (15-30 min inactivity)
2. Strict RBAC on every request:
- Role check on every endpoint
- Permission-based access control
- No client-side role trust
3. No client-side role trust:
- Frontend'de role değil, sadece UI kontrol
- Backend'de her istekte rol kontrolü
4. 2FA server enforced:
- 2FA kontrolü server-side
- Sadece UI kontrolü değil
5. JWT with iss + aud + exp validation:
- Audience check
- Issuer check
- Expiration validation
6. Secure password reset flow:
- Token-based reset
- Email ownership check
- Rate limiting
7. Email change requires re-auth:
- Şifre onayı
- 2FA onayı (opsiyonel)
8. Session anomaly detection:
- Impossible travel
- Device fingerprint
- Behavioral signals
En Kritik Takeaway:
Authentication bypass neredeyse hiçbir zaman "tek payload" değildir. Gerçek dünya: logic bug + trust issue + missing check. Injection sadece bir "entry point" 'tir.
Authentication Bypass Katmanları:
Authentication bypass genelde 3 katmanda oluşur:
Katman Açıklama Örnek
Logic Flaw İş akışı hatası Email değiştirme re-auth yok
Authorization Missing Yetki kontrolü eksik IDOR, role escalation
Injection Enjeksiyon zafiyeti SQL/NoSQL injection
1. Logic Flaw Authentication Bypass (En Yaygın - %60 Bug Bounty)
Gerçek dünyada auth bypass'ların çoğu logic bug + trust issue + missing check kombinasyonudur.
Örnekler:
a. Email Change Without Re-Auth:
http
POST /api/user/email
{
"new_email": "[email protected]"
}
# ❌ Şifre veya 2FA onayı yok
b. Password Reset Without Ownership Check:
http
POST /api/password/reset
{
"email": "[email protected]",
"new_password": "saldirgan123"
}
# ❌ E-posta sahipliği doğrulanmıyor
c. Role Upgrade Flow Missing Validation:
http
POST /api/user/upgrade
{
"user_id": 123,
"role": "admin"
}
# ❌ Sadece UI'da kontrol, backend'de eksik
d. "Login doğru ama session yanlış bağlanmış":
http
POST /login
{
"username": "kurban",
"password": "dogru"
}
# ✅ Login başarılı
# ❌ Session farklı kullanıcıya bağlanıyor
e. "2FA var ama sadece UI'da kontrol ediliyor":
http
# Frontend: 2FA geçildi ✅
POST /api/sensitive-action
{
"action": "transfer",
"amount": 1000
}
# Backend: 2FA kontrolü YOK ❌
Koruma:
python
def change_email(user_id, new_email, password):
# 1. Re-auth kontrolü
if not verify_password(user_id, password):
raise Exception("Invalid password")
# 2. Email sahipliği kontrolü
if not verify_email_ownership(user_id, new_email):
raise Exception("Email ownership verification required")
# 3. 2FA kontrolü (opsiyonel)
if not verify_2fa(user_id):
raise Exception("2FA verification required")
# 4. Email değiştir
update_email(user_id, new_email)
2. Business Logic Authentication Bypass
En kritik eksik kategori. Bu, bug bounty'lerde en sık görülen auth bypass türüdür.
Örnekler:
a. Multi-step Flow Bypass:
http
# Step 1: Email doğrulama
POST /verify/email → { "verified": true }
# Step 2: Password reset
POST /reset/password → { "success": true }
# ❌ Step 1 bypass edilebilir mi?
# Saldırgan direkt Step 2'ye gider
b. "Skip 2FA" Endpoint:
http
POST /api/auth/skip-2fa
{
"user_id": 123,
"skip_reason": "trusted_device"
}
# ❌ İş mantığı hatası
c. Password Change Without Old Password:
http
POST /api/user/password
{
"new_password": "saldirgan123"
}
# ❌ Eski şifre kontrolü yok
Koruma:
python
def multi_step_flow_validator(request):
# Her adımda önceki adım doğrulaması
if not session.get('email_verified'):
raise Exception("Email verification required")
if not session.get('2fa_verified'):
raise Exception("2FA verification required")
# Sonraki adıma geç
process_password_reset()
3. Session / Cookie Hijacking — En Gerçek Saldırı
Modern Gerçek: XSS varsa → auth bypass zaten "game over". HttpOnly sadece cookie theft'i zorlaştırır, XSS'i çözmez.
Gerçek Riskler:
Risk Açıklama
XSS Session cookie çalma veya session action yapma
MITM Ağ üzerinden session ele geçirme (HTTPS zorunlu)
Malware Endpoint compromise
Session Reuse Aynı session farklı cihazlarda kullanım
Koruma:
python
# Session security
session.cookie.httponly = True
session.cookie.secure = True
session.cookie.samesite = 'Strict'
session.timeout = 3600 # 1 saat
# Anomaly detection
def detect_session_anomaly(session, request):
# Impossible travel
if is_impossible_travel(session['last_ip'], request.remote_addr):
kill_session(session)
return False
# Device fingerprint değişimi
if session.get('fingerprint') != generate_fingerprint(request):
# Risk skoru artır, hemen kill yapma
risk_score = calculate_risk_score(session, request)
if risk_score > 0.8:
kill_session(session)
return False
return True
4. Session Fixation — Modern Dünyada Azalan Risk
Çünkü: Framework'ler otomatik rotate ediyor:
Django
Express-session
Spring Security
Gerçek Exploit Condition:
Session rotation yok
Login sonrası session reuse var
Session ID tahmin edilebilir
Koruma:
python
def login_success(user):
# Framework'ün session regenerate fonksiyonu
session.regenerate() # Django, Express, Spring
# Güçlü session ID entropy
session['user_id'] = user.id
session['ip_address'] = request.remote_addr
session['user_agent'] = request.user_agent.string
5. IDOR — Aslında Auth Bypass Değil, AuthZ Bypass
En Önemli Düzeltme:
Konsept Gerçek Adı
IDOR Broken Access Control (BAC)
Auth Bypass Authentication Failure
IDOR ≠ Login Bypass
IDOR = Yetki Bypass
Örnek:
http
# Bu bir auth bypass DEĞİL
GET /api/users/123
# Kullanıcı login yapmış ama başka kullanıcıya erişiyor
# Bu bir auth bypass
GET /api/users
# Kullanıcı login yapmadan verilere erişiyor
Koruma:
python
def get_user_profile(user_id, current_user):
# Authentication
if not current_user.is_authenticated:
abort(401)
# Authorization (IDOR koruması)
if user_id != current_user.id and not current_user.is_admin:
abort(403)
return User.objects.get(id=user_id)
6. JWT Manipulation — Gerçek Dünya Farkı
Yanlış Yaygın Düşünce:
json
{ "alg": "none" }
Modern sistemlerde çoğu library bunu zaten reject eder.
Gerçek Riskler:
Risk Açıklama
Weak Secret Brute force ile secret tahmin etme
Key Reuse Aynı secret farklı servislerde
Token Leakage Log, URL, cache'de token sızıntısı
Missing Audience Check aud claim kontrolü yok
Missing Issuer Check iss claim kontrolü yok
Koruma:
python
def validate_jwt(token):
payload = jwt.decode(
token,
secret,
algorithms=['HS256'],
audience='api.hedef.com', # Audience check
issuer='auth.hedef.com', # Issuer check
options={
'require': ['exp', 'iat', 'sub', 'aud', 'iss']
}
)
return payload
7. 2FA Bypass — En Gerçek Exploit Alanı
En Sık Gerçek Bypass:
text
2FA sadece "frontend step"
Backend "verified=true" trust ediyor
Gerçek Exploit Pattern:
http
# 1. 2FA geç
POST /verify-2fa → { "verified": true }
# 2. Login endpoint role veriyor (2FA kontrolü yok)
POST /api/login → { "role": "admin" }
# ❌ Backend'de 2FA kontrolü eksik
Koruma:
python
def perform_sensitive_action(user_id, action, data):
# 1. Authentication kontrolü
if not is_authenticated(user_id):
abort(401)
# 2. 2FA kontrolü (server-side)
if requires_2fa(action):
if not is_2fa_verified(user_id):
abort(403, "2FA required")
# 3. Yetkilendirme kontrolü
if not has_permission(user_id, action):
abort(403)
# 4. İşlemi gerçekleştir
return execute_action(action, data)
8. OAuth Bypass — En Önemli Modern Issue
Kritik Gerçekler:
Yanlış Odak Gerçek Exploit
Redirect URI manipulation her zaman çalışır Missing PKCE, Missing State Validation, Token Reuse
Gerçek OAuth Exploit'leri:
a. Missing PKCE:
http
# PKCE olmadan code interception riski
GET /authorize?client_id=app&redirect_uri=https://hedef.com/callback
b. Missing State Validation:
http
# CSRF on OAuth
GET /authorize?state=weak_guessable
c. Token Reuse (Code Replay):
http
# Aynı authorization code tekrar kullanımı
POST /token?code=abc123 # İlk kullanım
POST /token?code=abc123 # Tekrar kullanım ❌
d. Misconfigured Audience:
json
{
"aud": "https://api.hedef.com" # Doğru değil
}
Koruma:
python
# OAuth State Validasyonu
state = secrets.token_urlsafe(32)
session['oauth_state'] = state
# PKCE
code_verifier = secrets.token_urlsafe(64)
code_challenge = hashlib.sha256(code_verifier.encode()).hexdigest()
# Token Reuse Detection
redis.setex(f"code_used:{code}", 3600, 'used')
9. API Auth Bypass — Gerçek Dünya Farkı
En Önemli Gerçek: Header spoofing tek başına çalışmaz.
http
X-Forwarded-For: 127.0.0.1
Sadece şu durumda çalışır: Backend proxy trust ediyorsa.
Gerçek Bug: Trust Boundary Misconfiguration
Koruma:
python
def get_client_ip(request):
# Sadece trusted proxy'lerden gelen header'ları kabul et
TRUSTED_PROXIES = ['10.0.0.1', '10.0.0.2']
if request.remote_addr in TRUSTED_PROXIES:
return request.headers.get('X-Forwarded-For', request.remote_addr)
return request.remote_addr
10. GraphQL Auth Bypass — Modern Gerçek
Yanlış: "GraphQL query = bypass"
Gerçek Exploit:
Resolver-level auth missing
Field-level authorization missing
Örnek:
graphql
# user endpoint secure
query {
user(id: 123) {
name
# ❌ email field exposed without auth
}
}
Koruma:
python
def resolve_user(self, info, user_id):
# Authentication kontrolü
if not info.context.get('user'):
raise Exception("Authentication required")
# Authorization kontrolü
user = User.objects.get(id=user_id)
if user.id != info.context['user'].id and not is_admin(info.context['user']):
raise Exception("Not authorized")
return user
# Field-level authorization
def resolve_email(self, info, user):
# Sadece kendi email'ini görebilir
if user.id != info.context['user'].id:
return None
return user.email
11. Injection Tabanlı Bypass (SQL / NoSQL)
Doğru Yaklaşım:
Prepared statements
ORM param binding
Kritik Yanlış Düşünce: "SQL injection = login bypass"
Gerçek:
Modern sistemlerde SQLi → daha çok data exfiltration
Login bypass sadece zayıf legacy sistemlerde
Koruma:
python
# SQL injection koruması
cursor.execute(
"SELECT * FROM users WHERE username = %s AND password = %s",
(username, password) # Param binding
)
# NoSQL injection koruması
User.objects.filter(username=username, password=password) # Django ORM
Authentication Bypass Haritası:
text
[Client Trust Issues]
↓
Frontend validation bypass
[Session Issues]
↓
fixation / reuse / weak binding
[Backend Logic]
↓
missing auth checks
[Authorization layer]
↓
IDOR / role escalation
[Injection layer]
↓
SQL / NoSQL injection
Production-Grade Protection (Minimum Secure Auth Stack):
yaml
1. Server-side session validation:
- HttpOnly, Secure, SameSite cookies
- Session ID regenerate on login
- Session timeout (15-30 min inactivity)
2. Strict RBAC on every request:
- Role check on every endpoint
- Permission-based access control
- No client-side role trust
3. No client-side role trust:
- Frontend'de role değil, sadece UI kontrol
- Backend'de her istekte rol kontrolü
4. 2FA server enforced:
- 2FA kontrolü server-side
- Sadece UI kontrolü değil
5. JWT with iss + aud + exp validation:
- Audience check
- Issuer check
- Expiration validation
6. Secure password reset flow:
- Token-based reset
- Email ownership check
- Rate limiting
7. Email change requires re-auth:
- Şifre onayı
- 2FA onayı (opsiyonel)
8. Session anomaly detection:
- Impossible travel
- Device fingerprint
- Behavioral signals
En Kritik Takeaway:
Authentication bypass neredeyse hiçbir zaman "tek payload" değildir. Gerçek dünya: logic bug + trust issue + missing check. Injection sadece bir "entry point" 'tir.
🔒 Bu içeriği görmek için giriş yapın