Skip to content

Security: keremoktener/FileSharingCollab

Security

SECURITY.md

Security Measures for File Sharing Application

This document outlines the security measures implemented in the File Sharing Application to ensure that user data and files remain secure.

Authentication & Authorization

  • JWT Authentication: The application uses JSON Web Tokens (JWT) for authentication, with tokens that expire after 24 hours.
  • Enhanced JWT Claims: Each token includes a unique ID and user roles for better validation and tracking.
  • Strong Password Hashing: User passwords are hashed using BCrypt with appropriate work factors.
  • Role-Based Access Control: Files can only be viewed, downloaded, or modified by their owners.

Data Protection

  • File Soft-Delete: Files are never permanently deleted immediately; they are marked as deleted and can be recovered if needed.
  • Secure File Access: Files can only be accessed through authenticated API endpoints that validate the user's identity.
  • Content-Type Validation: The application validates and restricts file types to prevent malicious file uploads.

API Security

  • CSRF Protection: Cross-Site Request Forgery protection is enabled for all endpoints except file uploads and authentication.
  • CORS Configuration: Cross-Origin Resource Sharing is configured to allow only specific trusted origins.
  • Content Security Policy: Strict CSP rules are defined to prevent XSS attacks.
  • Secure Headers: HTTP security headers are set including:
    • X-Content-Type-Options: nosniff
    • X-XSS-Protection
    • Cache-Control: no-cache, no-store
    • Strict-Transport-Security

Deployment Security

  • HTTPS Only: In production, all communication is encrypted using HTTPS.
  • Environment Variables: Sensitive configuration like JWT secrets and database credentials are stored as environment variables.
  • Cookie Security: Cookies are marked as secure, HttpOnly, and SameSite=Strict.
  • Production-Specific Configuration: A separate application-prod.properties file enables additional security features in production.

Secure File Viewing

  • Authenticated Blob URLs: For file previews, we use authenticated API calls to fetch file data and create local blob URLs rather than exposing direct file links.
  • Memory Management: Blob URLs are properly revoked after use to prevent memory leaks.

Recommendations for Deployment

  1. Use Environment Variables: All sensitive configuration should be set using environment variables.
  2. Set Up HTTPS: Configure a valid SSL certificate for your domain.
  3. Regular Updates: Keep all dependencies updated to minimize vulnerability risks.
  4. Security Monitoring: Implement logging and monitoring to detect unusual access patterns.
  5. Backup Strategy: Implement regular database and file backups.

Security Limitations and Future Improvements

  • File Encryption: Currently, files are stored unencrypted. Future versions will implement at-rest encryption.
  • Rate Limiting: API rate limiting should be implemented to prevent brute force attacks.
  • Multi-Factor Authentication: Future versions will support MFA for additional security.
  • Audit Logging: More comprehensive audit logging for security events.

There aren't any published security advisories