Skip to content

Security: vinhnx/vtchat

Security

docs/SECURITY.md

VT (VTChat) Security Overview

VT implements security measures to protect users, data, and infrastructure from various threats. Our multi-layered security approach combines privacy-first architecture with advanced application security and Better Auth.

πŸ›‘οΈ Security Architecture

Core Security Principles

  1. Privacy-First Design: Local data storage, zero server persistence of conversations
  2. Defense in Depth: Multiple security layers protecting different attack vectors
  3. Zero Trust: All requests are validated and protected regardless of source
  4. User-Centric Protection: Security measures that enhance rather than hinder user experience

πŸ”’ Application Security (Bot Detection)

VTChat implements bot detection and secure authentication focused on privacy and user protection.

Protection Features

πŸ€– Bot Protection

  • Authentication Bot Detection: Identifies and blocks automated traffic on authentication endpoints
  • Industry-Standard Detection: Uses the isbot library for reliable bot identification
  • Focused Protection: Targeted protection for login and registration endpoints
  • Privacy-First Approach: Minimal data collection while maintaining security

πŸ” Better Auth Security

  • Modern Session Management: Secure session handling with automatic expiration
  • OAuth Integration: Secure authentication with Google, GitHub, and other providers
  • Session Isolation: Per-user authentication with proper thread isolation
  • Account Linking: Secure linking of multiple OAuth providers to single account

Route-Specific Protection

Authentication Routes (/api/auth/*)

// Enhanced Better Auth integration
- Bot detection for authentication endpoints
- Secure OAuth integration with Google and GitHub
- Session management with automatic expiration
- CORS headers for cross-origin protection

API Routes (General)

// Basic protection for all routes
- HTTPS enforcement for all communications
- Secure session management through Better Auth
- Privacy-first data handling
- User ID + IP tracking

Feedback Routes (/api/feedback)

// Form submission protection
- Authentication required
- User-specific submission tracking
- Basic rate limiting through application logic

πŸ” Privacy-First Architecture

Local Data Storage

  • IndexedDB Storage: All conversations stored locally in browser
  • Zero Server Persistence: Chat history never leaves user's device
  • Multi-User Isolation: Complete data separation on shared devices
  • Client-Side Encryption: Sensitive data encrypted in browser storage

Authentication Security

  • Better Auth Integration: Modern, secure session management
  • Secure Headers: CORS, security headers properly configured
  • Session Isolation: Per-user authentication with proper isolation
  • Graceful Degradation: Continues operation if auth services fail

🚨 Threat Mitigation

Automated Attack Prevention

  • Brute Force Protection: Better Auth built-in rate limiting
  • Bot Prevention: Detection and blocking of automated requests on auth endpoints
  • Privacy Protection: No server-side storage of sensitive conversation data
  • Secure Communication: HTTPS enforcement and secure headers

Content Security

  • Input Validation: All user inputs validated and sanitized
  • Output Encoding: Proper encoding to prevent XSS attacks
  • SQL Injection Prevention: Parameterized queries and ORM protection
  • File Upload Security: Restricted file types and size limits

Infrastructure Security

  • Secure Deployment: Fly.io with proper security configurations
  • Environment Isolation: Separate development, staging, production
  • Secret Management: Secure handling of API keys and credentials
  • Monitoring Integration: Real-time security event monitoring

πŸ“Š Security Monitoring

Real-Time Protection

  • Application Monitoring: Basic security event logging
  • Error Tracking: Monitoring authentication and access patterns
  • Performance Metrics: Security impact on application performance
  • Privacy-First Logging: Minimal data collection focused on security

Security Analytics

  • Basic Analytics: Understanding general usage patterns
  • Privacy-Focused Monitoring: No personal data collection
  • Error Analysis: Identifying potential security issues
  • Trend Analysis: Long-term security trend monitoring

πŸ§ͺ Security Testing

Automated Testing

# Security test suite
bun test apps/web/tests/              # Authentication and security tests
bun run build                         # Build verification

Manual Security Testing

# Bot detection testing on auth endpoints
curl -X POST http://localhost:3000/api/auth/sign-up \
  -H "Content-Type: application/json" \
  -H "User-Agent: bot-detection-test" \
  -d '{"email":"[email protected]","password":"test123"}'

# Authentication testing
curl -I http://localhost:3000/api/feedback

πŸ”§ Security Configuration

Environment Setup

# Required security configuration
DATABASE_URL=your_secure_db_url        # Encrypted database connection
BETTER_AUTH_SECRET=your_session_secret # Session security
NEXT_PUBLIC_BASE_URL=your_app_url      # Application base URL

Security Headers

  • CORS Configuration: Proper cross-origin resource sharing
  • Content Security Policy: XSS and injection prevention
  • Security Headers: HSTS, X-Frame-Options, etc.
  • API Security: Rate limiting and authentication headers

πŸ“‹ Security Compliance

Data Protection

  • GDPR Compliance: User data rights and privacy protection
  • Data Minimization: Only collect necessary information
  • Consent Management: Clear user consent for data usage
  • Right to Deletion: User data removal capabilities

Security Standards

  • OWASP Guidelines: Following web application security best practices
  • Secure Development: Security-first development methodology
  • Regular Updates: Continuous security dependency updates
  • Vulnerability Management: Proactive security issue resolution

πŸš€ Security in Production

Deployment Security

  • Secure CI/CD: Protected deployment pipelines
  • Environment Separation: Isolated production environment
  • Secret Rotation: Regular API key and credential rotation
  • Backup Security: Encrypted backups with access controls

Incident Response

  • Security Monitoring: 24/7 automated threat detection
  • Incident Procedures: Defined response protocols
  • Recovery Plans: Comprehensive disaster recovery
  • Communication: User notification for security events

πŸ“š Additional Resources


Security Contact: For security concerns or vulnerability reports, please contact our security team through the appropriate channels outlined in our security policy.

Last Updated: June 30, 2025

There aren’t any published security advisories