This page contains intentional security vulnerabilities for testing and educational purposes only. These examples demonstrate common security mistakes that should NEVER be implemented in production code. Always follow security best practices and OWASP guidelines.
Security Vulnerabilities
The following examples demonstrate common security vulnerabilities:
1. Cross-Site Scripting (XSS) - Reflected
User input is directly inserted into HTML without sanitization:
// VIOLATION: Directly inserting user input
document.getElementById('output').innerHTML = userInput;
Output will appear here...
2. Cross-Site Scripting (XSS) - Stored
User input stored and displayed without sanitization:
3. SQL Injection
User input directly concatenated into SQL queries:
// VIOLATION: SQL Injection
const query = "SELECT * FROM users WHERE username = '" + username + "' AND password = '" + password + "'";
// Try: username = "admin' OR '1'='1"
4. Exposed API Keys and Credentials
API keys and credentials hardcoded in client-side code:
// VIOLATION: Missing security headers
// No Content-Security-Policy
// No X-Frame-Options
// No X-Content-Type-Options
// No Strict-Transport-Security
// No Referrer-Policy
6. Insecure Cookies
Cookies set without Secure, HttpOnly, or SameSite attributes:
// VIOLATION: No file type/size validation
const file = document.getElementById('file-upload').files[0];
// No check for file type, size, or malicious content
10. Exposed Sensitive Information in Error Messages
Error messages reveal system information:
Database Error:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'production.users' doesn't exist
Stack trace: /var/www/html/database.php:45
Database: production_db
User: db_admin
Connection string: mysql://db_admin:password123@localhost:3306/production_db
11. Insecure Direct Object References (IDOR)
Direct access to resources without authorization check:
// VIOLATION: No authorization check
GET /api/users/12345
// Anyone can access any user ID by changing the number
// Compliant: Parameterized queries
const query = "SELECT * FROM users WHERE username = ? AND password = ?";
db.query(query, [username, password]);
3. Secure API Key Management
// Compliant: API keys stored server-side only
// Never expose in client-side code
// Use environment variables or secure key management services
const apiKey = process.env.API_KEY; // Server-side only