This document provides a comprehensive overview of the security features implemented in the EU-Compliant Document Chat system.
The system was designed with security in mind at every level:
-
Perimeter Security
- Nginx reverse proxy with security headers
- Rate limiting at multiple levels
- Input validation and sanitization
-
Authentication & Authorization
- Web interface authentication with bcrypt password hashing
- API key-based authorization for API endpoints
- Docker Secrets for credential management
-
Network Security
- Isolation between frontend and backend networks
- Internal components not exposed to public internet
- Secure communication between components
-
Application Security
- Comprehensive request validation
- Protection against injection attacks (SQL, XSS, command)
- Content filtering for uploaded documents
-
Container Security
- Non-root user execution
- Principle of least privilege
- No-new-privileges restrictions
-
Data Protection
- GDPR-compliant processing
- Anonymization of personal identifiers
- Automatic log rotation and deletion
The web interface implements password-based authentication:
- Password hashing with bcrypt
- Session management
- Failed login attempt tracking
All input is validated to prevent:
- Cross-site scripting (XSS)
- SQL injection
- Command injection
- Format string attacks
- Path traversal
API endpoints are protected with:
- API key validation
- Rate limiting by IP and overall requests
- Token budget enforcement
- Request validation
- Error handling that doesn't leak implementation details
The system uses Docker Secrets for secure credential storage:
- Mistral API key
- Internal API key
- Automatic age checking for key rotation
Multiple layers of rate limiting prevent abuse:
- IP-based rate limiting at the HTTP middleware level
- Global rate limiting for API requests
- Token budget limitations for external API calls
Container security is enhanced through:
- Non-root user execution
- No-new-privileges flag
- Network isolation
- Volume mounting restrictions
GDPR compliance is ensured through:
- Privacy-by-design principles
- Anonymization of user identifiers
- Configurable retention policies
- Explicit consent notifications
The following security headers are configured in the Nginx reverse proxy:
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:;
Referrer-Policy: strict-origin-when-cross-origin
The system implements a comprehensive authentication system that secures both the API and web interfaces using industry-standard security practices.
- JWT-based Authentication: JSON Web Tokens provide stateless authentication
- Password Security: Bcrypt hashing with appropriate work factors
- Token Expiration: Time-limited tokens with automatic expiration (30 minutes by default)
- User Management: Command-line tool for user administration
- Role-Based Access: Support for admin and regular user roles
Passwords are never stored in plain text. The system uses bcrypt with the following security features:
- Salted hashes unique to each user
- Configurable work factor (default: 12 rounds)
- Protection against timing attacks
- Automatic hashing of new passwords
JWT tokens are secured with:
- HS256 encryption algorithm
- Secure random-generated signing key
- Short expiration timeframes
- Token invalidation on password change
The user management script enforces:
- Strong password requirements by default
- Proper permission controls
- Secure handling of generated passwords
- Immutable authentication logs
To maintain authentication security:
- Rotate JWT Secret: Periodically change the JWT signing secret
- Regular Password Changes: Enforce password changes every 90 days
- Strong Passwords: Use the
--generate-passwordflag to create strong passwords - Minimum Access: Only grant admin access where necessary
- Account Deactivation: Use
manage_users.py disablerather than deleting accounts - Audit User List: Regularly review the active users with
manage_users.py list
- Client submits credentials to
/loginor/tokenendpoint - Server validates credentials against
users.json - If valid, server generates a JWT token and returns it
- Client includes token in
Authorization: Bearer <token>header - Protected endpoints validate token via dependency injection
- User enters credentials in login form
- Frontend sends credentials to API login endpoint
- On success, token is stored in browser localStorage
- Vue Router navigation guards protect routes
- Automatic redirection to login page when token expires
- Password Brute Force: No rate limiting implemented yet (planned for future)
- User Enumeration: Generic error messages don't reveal valid usernames
- Token Theft: Short expiration time limits exposure if tokens are compromised
- CSRF: Tokens in Authorization header are immune to CSRF attacks
When deploying and maintaining this system:
- Regularly rotate API keys (system reminds after 90 days)
- Keep all components updated
- Monitor logs for suspicious activity
- Use strong passwords for web interface
- Place the system behind a firewall
- Regularly perform security audits
- Follow principle of least privilege for all accounts
For even stronger security, consider:
- Implementing multi-factor authentication
- Adding an intrusion detection system
- Regular penetration testing
- Enabling Docker Content Trust for image verification
- Implementing a Web Application Firewall (WAF)
- Using TLS certificates for all communications
- Implementing a more robust authentication system for production