A demo web application featuring the dark creatures of Hyrule Kingdom, built with secure coding practices.
- Legend of Zelda themed interface with dark, monster-filled design
- Interactive monster gallery with boss monsters and regular creatures
- Search functionality with secure parameterized queries
- Security best practices demonstrated throughout the codebase
- ASCII art deployment script featuring Dark Link
๐ธ ALL SECURITY VULNERABILITIES FIXED! ๐ธ
This application demonstrates security best practices:
-
SQL Injection Prevention
- Fixed:
/api/searchand/api/monster/:idendpoints - Solution: Parameterized queries with placeholders
- Impact: Database is now protected from injection attacks
- Code: All user inputs are passed as parameters, never concatenated
- Fixed:
-
Cross-Site Scripting (XSS) Prevention
- Fixed: Search results display in frontend
- Solution: HTML entity encoding for all dynamic content
- Impact: Malicious scripts can no longer execute in browsers
- Code: All server data is escaped before DOM insertion
-
Information Disclosure Prevention
- Fixed: Error messages and debug endpoints
- Solution: Generic error messages, debug endpoint removed
- Impact: System information no longer exposed to attackers
- Code: No stack traces or query details in responses
-
Input Validation
- Added: Length validation and type checking
- Solution: Server-side validation for all inputs
- Impact: Prevents various injection and malformed requests
- Code: Query length limits, ID type validation
-
Rate Limiting
- Added: Search endpoint rate limiting
- Solution: 10 requests per minute per IP
- Impact: Prevents brute force and DoS attacks
- Code: Express rate limiting middleware
๐ธ SECURE AND READY FOR PRODUCTION! ๐
- Node.js (v18 or higher)
- npm
-
Clone and navigate to the repository:
git clone <repository-url> cd breath-of-copilot-universe-2025
-
Install dependencies:
npm install
-
Start the development server:
npm start # or for development with auto-reload: npm run dev # if there's a process already running on port 3000 lsof -i tcp:3000 kill -9 <PID>
-
Open your browser and visit:
http://localhost:3000
The app is automatically deployed to GitHub Pages using GitHub Actions whenever changes are pushed to the main branch.
The deployment process:
- Builds the application on multiple platforms (Ubuntu, Windows) with different Node.js versions (18, 20, 22)
- Installs dependencies
- Builds the application from the
src/folder - Creates artifact attestations for security and provenance
- Deploys static files to GitHub Pages
To build the application manually:
npm run buildThis will create a dist/ folder with all the built files ready for deployment.
- All Monsters: View all creatures in the database
- Boss Monsters: Filter to show only boss-level creatures
- Search Database: Search for specific monsters using the secure search endpoint
-
Secure Search:
- All queries use parameterized statements
- Input validation prevents malicious queries
- Try searching for "Ganon", "Dark Link", or "Lynel"
-
Protected Endpoints:
- All API endpoints use secure coding practices
- Rate limiting prevents abuse
- Generic error messages protect system information
-
XSS Protection:
- All dynamic content is HTML-escaped
- User input is sanitized before display
- Server responses are validated
- Try the Konami Code: โโโโโโโโBA
- Click on monster cards for details
- Watch for floating triforce elements
โโโ src/
โ โโโ index.html # Main web page
โ โโโ style.css # Zelda-themed styling
โ โโโ script.js # Frontend JavaScript (XSS protection with HTML escaping)
โ โโโ server.js # Node.js backend (secure with parameterized queries)
โโโ .github/
โ โโโ workflows/
โ โโโ deploy.yml # GitHub Actions deployment workflow
โโโ package.json # Dependencies and scripts
โโโ monsters.db # SQLite database (generated automatically)
โโโ README.md # This file
- SQLite database with monster information
- Secure search endpoints with parameterized queries
- Input validation on all user inputs
- Rate limiting to prevent abuse
- Generic error messages to prevent information disclosure
- Responsive Zelda-themed design
- Interactive monster cards
- Secure search results display with HTML escaping
- XSS protection through proper output encoding
- Konami code easter egg
| Security Feature | Implementation | Location | Benefit |
|---|---|---|---|
| SQL Injection Prevention | Parameterized queries | src/server.js |
Prevents database attacks |
| XSS Prevention | HTML entity encoding | src/script.js |
Prevents script injection |
| Input Validation | Length & type checks | src/server.js |
Prevents malformed requests |
| Information Disclosure Prevention | Generic errors | src/server.js |
Protects system information |
| Rate Limiting | Express middleware | src/server.js |
Prevents DoS attacks |
This application demonstrates:
- Parameterized SQL queries to prevent injection attacks
- HTML entity encoding to prevent XSS attacks
- Input validation and sanitization
- Generic error messages to prevent information disclosure
- Rate limiting to prevent abuse and DoS attacks
- Secure coding practices throughout the codebase
Before (Vulnerable):
const query = `SELECT * FROM monsters WHERE name LIKE '%${userInput}%'`;
db.all(query, callback);After (Secure):
const query = `SELECT * FROM monsters WHERE name LIKE ?`;
db.all(query, [`%${userInput}%`], callback);Before (Vulnerable):
searchResults.innerHTML = `<div>${serverData.name}</div>`;After (Secure):
function escapeHtml(str) {
return str.replace(/[&<>"']/g, (char) => ({
'&': '&', '<': '<', '>': '>',
'"': '"', "'": '''
})[char]);
}
searchResults.innerHTML = `<div>${escapeHtml(serverData.name)}</div>`;// Validate query length
if (query.length > 100) {
return res.status(400).json({ error: 'Query too long' });
}
// Validate ID is a number
const id = parseInt(req.params.id, 10);
if (isNaN(id) || id < 1) {
return res.status(400).json({ error: 'Invalid ID' });
}Before (Vulnerable):
res.status(500).json({ error: err.message, stack: err.stack });After (Secure):
console.error(err); // Log internally only
res.status(500).json({ error: 'An error occurred. Please try again.' });MIT License - See LICENSE file for details.
This is a secure web application project. Feel free to:
- Add more monsters to the database
- Enhance the Zelda theme
- Improve security features
- Add additional security best practices examples
Please ensure all contributions maintain the security standards demonstrated in this codebase.
๐ธ "Every bug caught is a step closer to a safer pond!" ๐
Secured by FrogSecFixer with ribbiting attention to detail! ๐ก๏ธ