Humanet implements comprehensive security measures to protect against common web application vulnerabilities and ensure data integrity.
- Window: 15 minutes
- Limit: 100 requests per IP
- Purpose: Prevent DoS attacks and abuse
- Window: 15 minutes
- Limit: 5 attempts per IP
- Purpose: Prevent brute force attacks
- Features:
- Automatic blocking after 5 failed attempts
- 30-minute lockout period
- Progressive delays
- Idea Creation: 10 per hour per user
- Comments: 20 per 15 minutes per user
- Upvotes: 30 per minute per user
- Password Reset: 3 per hour per IP
- Uses
express-mongo-sanitizeto remove dangerous operators - Removes
$prefixed keys and.characters - Validates all input with Zod schemas
- Content Security Policy headers
- Input validation for script tags and event handlers
- HTML entity encoding
- Maximum payload size: 10MB
- Parameter limit: 100 per request
- Protection against memory exhaustion
- Content Security Policy: Prevents XSS attacks
- HSTS: Forces HTTPS in production
- X-Frame-Options: Prevents clickjacking
- X-Content-Type-Options: Prevents MIME sniffing
- Referrer Policy: Controls referrer information
- X-XSS-Protection: Browser XSS filtering
- Permissions-Policy: Restricts device access
- Cache-Control: Prevents sensitive data caching
const allowedOrigins = [
'http://localhost:3000',
'http://localhost:3001',
'https://humanet.vercel.app',
'https://www.humanet.com'
];- Credential support enabled
- Specific method allowlist
- Header restrictions
- Configurable via environment variables
- Secure token generation
- HttpOnly cookies for web clients
- Bearer token fallback for APIs
- Automatic token expiration
- bcryptjs hashing (Windows compatible)
- Minimum complexity requirements
- Salt rounds: 12 (configurable)
- Failed authentication attempts
- Suspicious user agents
- Rate limit violations
- Security header violations
const suspiciousAgents = [
'sqlmap', 'nikto', 'nessus', 'openvas',
'nmap', 'masscan', 'zap', 'burp'
];# Rate Limiting
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100
AUTH_RATE_LIMIT_MAX=5
ENABLE_RATE_LIMITING=true
# Security Headers
ENABLE_SECURITY_HEADERS=true
ENABLE_CORS=true
TRUST_PROXY=true
# CORS Origins (comma-separated)
CORS_ALLOWED_ORIGINS=http://localhost:3000,https://myapp.com
# Monitoring
LOG_SECURITY_EVENTS=true
BLOCK_SUSPICIOUS_IPS=false-
Enable HTTPS
- Use SSL/TLS certificates
- Redirect HTTP to HTTPS
- Set
TRUST_PROXY=truebehind load balancers
-
Database Security
- Use MongoDB authentication
- Enable database encryption
- Restrict network access
-
API Keys (Future Implementation)
- Implement API key validation
- Rate limit by API key
- Monitor API usage
-
Monitoring & Alerting
- Set up log aggregation
- Monitor failed requests
- Alert on suspicious patterns
# Install security audit tools
npm audit
# Check for vulnerabilities
pnpm audit
# Use security linting
npx eslint --ext .ts src/ --config .eslintrc.security.js- Rate Limiting: Test with multiple rapid requests
- Input Validation: Test with malicious payloads
- Authentication: Test with invalid credentials
- CORS: Test with unauthorized origins
- Check logs for patterns
- Identify source IP addresses
- Temporary IP blocking if needed
- Scale rate limits if legitimate traffic
- Monitor failed login attempts
- Implement progressive delays
- Notify users of suspicious activity
- Consider CAPTCHA implementation
- Update validation schemas
- Patch security middleware
- Review input sanitization
- Update security tests
- Rate limiting configured and tested
- Security headers implemented
- Input validation on all endpoints
- CORS properly configured
- Authentication properly secured
- Logging and monitoring enabled
- SSL/TLS certificates installed
- Database access restricted
- Regular security audits scheduled
- Incident response plan documented
- Injection: Input validation & sanitization ✅
- Broken Authentication: Secure JWT implementation ✅
- Sensitive Data Exposure: HTTPS & secure headers ✅
- XML External Entities: Not applicable (no XML) ✅
- Broken Access Control: Role-based authorization ✅
- Security Misconfiguration: Secure defaults ✅
- Cross-Site Scripting: CSP headers & validation ✅
- Insecure Deserialization: JSON only, validated ✅
- Known Vulnerabilities: Regular audits ✅
- Insufficient Logging: Comprehensive logging ✅
- Update dependencies monthly
- Review security logs weekly
- Test security measures quarterly
- Update incident response plan annually
npm auditfor dependency vulnerabilities- Custom security event logging
- Rate limit violation tracking
- Failed authentication monitoring
Last Updated: January 2025 Version: 1.0.0