Security Guide#
This document describes the security features and best practices for Cloud Native MCP Server.
Table of Contents#
- Authentication
- Secret Management
- Input Sanitization
- Audit Logging
- Security Best Practices
- Security Headers
- Reporting Security Issues
Authentication#
API Key Authentication#
API keys must meet the following complexity requirements:
- Minimum Length: 16 characters
- Character Types: Must include at least 3 of the following 4 types:
- Uppercase letters (A-Z)
- Lowercase letters (a-z)
- Numbers (0-9)
- Special characters (!@#$%^&*()_+-=[]{}|;:,.<>?)
Valid Examples:
Abc123!@#Xyz789!@#(uppercase, lowercase, numbers, special characters)Abc123Xyz789Abc123(uppercase, lowercase, numbers)ABC123!@#XYZ789!@#(uppercase, numbers, special characters)
Invalid Examples:
Abc123!@#(less than 16 characters)abcdefgh12345678(only lowercase and numbers, doesn’t meet 3 character types)ABCDEFGHIJKLMNOPQRSTUVWXYZ(only uppercase)
Bearer Token Authentication#
Bearer tokens must follow JWT structure:
- Format:
header.payload.signature - Minimum Length: 32 characters
- Encoding: Base64URL encoded parts
- Validation: Each part must contain only valid base64url characters (A-Z, a-z, 0-9, -, _, +)
Valid Example:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5cInvalid Examples:
abcdefgh12345678abcdefgh12345678(no JWT structure)eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ(less than 32 characters)eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c$(invalid character at end)
Basic Authentication#
Basic authentication uses username and password:
- Username: Non-empty string
- Password: Non-empty string
Example:
| |
Configuring Authentication#
Enable authentication in the configuration file:
| |
Authentication via Environment Variables#
Configure authentication using environment variables:
| |
Secret Management#
The server includes a secret management module for securely storing credentials.
Features#
- Secure Storage: In-memory storage with expiration support
- Key Rotation: Automatic rotation for API keys and bearer tokens
- Key Generation: Built-in generators for complex API keys and JWT-style tokens
- Environment Variables: Support for loading secrets from environment variables
- Secret Types: API keys, bearer tokens, basic auth credentials
Using the Secret Manager#
| |
Secret Expiration#
Secrets can have expiration times:
| |
Expired secrets are automatically excluded from the list and cannot be retrieved.
Key Rotation Strategy#
Regularly rotating keys is a security best practice:
| |
Input Sanitization#
All user input is sanitized to prevent injection attacks.
Sanitization Features#
- Filter Values: Removes dangerous characters (SQL injection, XSS, command injection)
- URL Validation: Only allows http/https protocols for web fetching
- Length Limits: Maximum string length enforced (1000 characters)
- Special Character Removal: Removes semicolons, quotes, and other injection vectors
Sanitization Rules#
The following characters are removed from user input:
- SQL Injection:
;,',",--,/*,*/ - Command Injection:
|,&,$,(,),<,>,\``,` - XSS:
<script>,javascript:,onload=,onerror=
Examples#
| |
Configuring Input Sanitization#
| |
Audit Logging#
Audit logs track all operations for security monitoring and compliance.
Enabling Audit Logging#
| |
Audit Events#
The following events are logged:
- Authentication success/failure
- Tool calls
- Configuration changes
- Errors and exceptions
- Access denials
Audit Log Format#
| |
Querying Audit Logs#
| |
Security Best Practices#
1. Use Strong Authentication#
- Always use API keys that meet complexity requirements
- Rotate API keys regularly
- Use bearer tokens for JWT-based authentication
- Never commit credentials to version control
2. Enable Audit Logging#
| |
3. Use HTTPS in Production#
Always use HTTPS when deploying in production:
| |
4. Restrict Access#
- Use firewall rules to limit access to the server
- Implement network policies in Kubernetes
- Use RBAC to control access to Kubernetes resources
- Implement rate limiting to prevent brute force attacks
| |
5. Monitor Suspicious Activity#
- Enable metrics and monitoring
- Set up alerts for failed authentication attempts
- Regularly review audit logs
- Implement anomaly detection
| |
6. Keep Dependencies Updated#
Regularly update dependencies to patch security vulnerabilities:
| |
7. Use Kubernetes Secrets#
Never hardcode sensitive information in configuration files:
| |
Create a Kubernetes Secret:
| |
Reference in deployment:
| |
8. Implement Least Privilege Principle#
- Grant only necessary permissions
- Use RBAC to limit Kubernetes access
- Regularly review and update permissions
- Use service accounts for isolation
| |
9. Network Isolation#
- Use network policies to restrict pod-to-pod communication
- Isolate services in different namespaces
- Use ingress controllers for external access management
- Consider using service mesh for mTLS
| |
10. Container Security#
- Run containers as non-root user
- Use read-only filesystems
- Remove unnecessary privileges
- Scan images for vulnerabilities
| |
Security Headers#
The server automatically filters sensitive headers in debug logs:
AuthorizationCookieX-API-KeyX-Api-Keyx-api-key
These headers are never logged in plaintext.
Custom Security Headers#
| |
TLS/SSL Configuration#
Use TLS/SSL for encrypted communication in production environments:
Basic TLS Configuration#
| |
mTLS Configuration#
| |
Let’s Encrypt Integration#
| |
Rate Limiting#
Prevent brute force attacks and abuse:
| |
Reporting Security Issues#
If you discover a security vulnerability, please report it privately:
- Email: security@example.com
- GitHub Security Advisories: https://github.com/mahmut-Abi/cloud-native-mcp-server/security/advisories
Please do not create public issues for security vulnerabilities.
Security Disclosure Process#
- Report vulnerability through private channels
- We will acknowledge receipt within 48 hours
- Assess severity and impact of the vulnerability
- Develop and test the fix
- Coordinate disclosure timeline before release
- Release security update
Acknowledgments#
We will credit all researchers who responsibly report security issues.
Compliance#
GDPR Compliance#
- Data protection
- Access control
- Audit logging
- Data deletion
SOC 2 Compliance#
- Security monitoring
- Access management
- Change management
- Incident response
HIPAA Compliance#
- PHI protection
- Access auditing
- Encrypted transmission
- Business continuity