Network-Based Authentication Flaws
CWE-291, CWE-293, CWE-300, CWE-350, CWE-940, CWE-941
Real-World Attack Scenarios
Scenario 1: IP-Based Authentication
System trusts connections from specific IP:
def get_admin_panel():
client_ip = request.remote_addr
# VULNERABLE - Trusts IP!
if client_ip in ['192.168.1.100', '10.0.0.50']:
return render_template('admin.html')
return "Access Denied", 403The attack:
Attacker spoofs source IP or redirects traffic:
# Method 1: IP Spoofing (network level)
# Attacker sends packets with source IP 192.168.1.100
# Method 2: Proxy through trusted IP
# Attacker finds proxy server at 192.168.1.100
# Routes traffic through proxy
# Server sees trusted IP
# Method 3: X-Forwarded-For Header (if vulnerable)
curl http://example.com/admin \
-H "X-Forwarded-For: 192.168.1.100"
# If server trusts header, access grantedResult:
IP-based access control bypassed
Admin access gained
No credentials needed
Finding it: Try spoofing IP. Use X-Forwarded-For header. Test from different IPs.
Scenario 2: Referer Header Authentication
Application uses Referer header to allow requests:
The attack:
Attacker crafts request with spoofed Referer:
Result:
Referer-based auth bypassed
Access to protected data
CSRF-like vulnerability
Finding it: Try requests without Referer. Use proxy to modify Referer. Check if endpoint accessible from different origins.
Scenario 3: Reverse DNS Authentication
System validates reverse DNS:
The attack:
Attacker controls reverse DNS for their IP:
Or DNS spoofing:
Result:
Reverse DNS auth bypassed
Access granted
Server compromised
Finding it: Perform reverse DNS lookup on server. Test from different IPs.
Scenario 4: Channel Accessible by Unintended Endpoint
Internal API only accessible from internal network:
The attack:
Result:
Bypass of intended access controls
Access to internal APIs
Data exposure
Scenario 5: Header-Based Authentication Without Validation
Server relies on custom header for auth:
The attack:
Result:
Authentication bypassed
Any value in header grants access
Mitigation Strategies
Never rely on IP address alone
Use proper authentication:
Don't trust headers for security decisions
Never use Referer for authentication
Don't rely on reverse DNS
Use proper endpoint access control
Implement proper origin validation
Last updated