This document outlines security considerations, best practices, and recommendations for deploying and using the Justice Definitions Project browser extension in a secure manner.
The Justice Definitions Project extension is designed with security in mind, but proper configuration and deployment practices are essential for maintaining security in production environments.
- Access Key Authentication: Prevents unauthorized access to your webhook endpoint
- Rate Limiting: Protects against abuse and DoS attacks
- Input Validation: Sanitizes and validates all incoming data
- XSS Protection: Basic protection against cross-site scripting attacks
- Geographic Logging: Optional IP-based tracking for monitoring
- Request Logging: Comprehensive logging for audit trails
SECURITY: {
ENABLE_ACCESS_KEY_VALIDATION: true, // Always enable in production
ACCESS_KEY: 'your_secure_key', // Use a strong, random key
LOG_REQUESTS: true, // Enable for audit trails
LOG_IP_ADDRESSES: true, // Enable for monitoring
LOG_GEOGRAPHY: true // Enable for geographic analysis
}DO:
- Use at least 32 characters
- Include uppercase, lowercase, numbers, and special characters
- Use a cryptographically secure random generator
- Store the key securely (password manager, environment variables)
DON'T:
- Use dictionary words or common phrases
- Use personal information
- Share keys in plain text
- Commit keys to version control
# Using OpenSSL (recommended)
openssl rand -base64 32
# Using Node.js
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
# Using Python
python3 -c "import secrets; print(secrets.token_urlsafe(32))"- Regular Rotation: Change access keys every 90 days
- Emergency Rotation: Change immediately if compromise is suspected
- Update Both Sides: Always update both Apps Script and extension configs simultaneously
- Always use HTTPS for your Google Apps Script deployment
- Verify SSL certificates are valid and up-to-date
- Use secure headers where possible
The extension uses background scripts to bypass CORS restrictions:
- Background scripts have elevated permissions
- Requests are made from the extension context, not the webpage
- This approach is more secure than disabling CORS
RATE_LIMIT_ENABLED: true,
MAX_REQUESTS_PER_HOUR: 1000, // Adjust based on expected usage
MAX_REQUESTS_PER_MINUTE: 30 // Prevent rapid-fire attacks- Monitor Usage Patterns: Adjust limits based on actual usage
- Implement Graduated Responses: Consider different limits for different user types
- Log Rate Limit Violations: Monitor for potential attacks
- Use IP-based Tracking: Combine with user-based tracking for better protection
// Minimal logging (privacy-focused)
SECURITY: {
LOG_REQUESTS: true, // Keep audit trail
LOG_IP_ADDRESSES: false, // Disable for privacy
LOG_GEOGRAPHY: false // Disable for privacy
}
// Full logging (monitoring-focused)
SECURITY: {
LOG_REQUESTS: true, // Full audit trail
LOG_IP_ADDRESSES: true, // Enable for security monitoring
LOG_GEOGRAPHY: true // Enable for usage analytics
}- Google Sheets: Data persists indefinitely by default
- Apps Script Properties: Rate limiting data auto-expires after 2 hours
- Geolocation Cache: Expires after 5 minutes
- IP Address Logging: Can be disabled if privacy is a concern
- Geographic Data: Optional feature for analytics
- Request Content: Terms and URLs are logged for audit purposes
- User Agent: Logged for debugging and analytics
- Regular Log Reviews: Check Google Sheets for unusual patterns
- Failed Authentication Attempts: Monitor for access key guessing
- Rate Limit Violations: Watch for potential attacks
- Geographic Anomalies: Unusual geographic patterns
The system logs:
- Request timestamps
- Source IP addresses (if enabled)
- Geographic location (if enabled)
- Request content (terms and URLs)
- Validation status
- Rate limit status
- Google Sheets: Built-in filtering and sorting
- Google Apps Script Logs: Execution history and errors
- Browser Developer Tools: Client-side debugging
-
Immediate Response:
- Rotate access keys
- Check logs for compromise indicators
- Review recent requests for anomalies
-
Investigation:
- Analyze log patterns
- Check for unauthorized access
- Review rate limiting violations
-
Recovery:
- Update configurations if needed
- Implement additional monitoring
- Document lessons learned
- Access Key Guessing: Mitigated by strong keys and rate limiting
- DoS Attacks: Mitigated by rate limiting and request validation
- Data Injection: Mitigated by input validation and sanitization
- Information Disclosure: Mitigated by proper error handling
-
Enable All Security Features:
SECURITY: { ENABLE_ACCESS_KEY_VALIDATION: true, LOG_REQUESTS: true, LOG_IP_ADDRESSES: true, LOG_GEOGRAPHY: true }
-
Implement Additional Validation:
- Add custom validation rules
- Implement request signing
- Add time-based tokens
-
Monitor and Alert:
- Set up automated monitoring
- Create alerts for suspicious activity
- Regular security reviews
-
Google Account Security:
- Enable 2FA on your Google account
- Use strong passwords
- Regular security checkups
-
Google Apps Script Security:
- Limit script sharing
- Regular permission reviews
- Monitor execution logs
-
Google Sheets Security:
- Limit sheet sharing
- Regular access reviews
- Backup important data
- Generate secure access keys
- Configure rate limiting appropriately
- Enable security logging
- Test all security features
- Review and update all configurations
- Monitor logs regularly
- Check for unusual patterns
- Review access patterns
- Update configurations as needed
- Rotate keys on schedule
- Monthly security reviews
- Quarterly key rotation
- Annual security assessment
- Regular backup verification
- Update documentation
If you discover a security vulnerability:
- DO NOT create a public GitHub issue
- DO contact the maintainers privately
- DO provide detailed information about the vulnerability
- DO allow reasonable time for response before disclosure
- README.md - Main project documentation
- SETUP_GUIDE.md - Detailed setup instructions
- Google Apps Script Security Best Practices
Remember: Security is an ongoing process, not a one-time setup. Regular reviews and updates are essential for maintaining a secure deployment.