Skip to content

Security: ChrisFrontDev/devices-api

Security

SECURITY.md

Security Guidelines

πŸ”’ Sensitive Data Protection

Never Commit:

  • ❌ .env files with real credentials
  • ❌ Private keys (.pem, .key, .crt)
  • ❌ Database passwords
  • ❌ API keys or tokens
  • ❌ SSL certificates

Always Use:

  • βœ… Environment variables for secrets
  • βœ… .gitignore for sensitive files
  • βœ… env.sample as template (with fake data)
  • βœ… Secrets managers in production (AWS Secrets Manager, HashiCorp Vault)

πŸ›‘οΈ Security Best Practices

Passwords

  • Development: Any password (auto-generated recommended)
  • Staging: Strong password (16+ chars, mixed case, numbers, symbols)
  • Production:
    • Minimum 32 characters
    • Generated by password manager
    • Rotated regularly
    • Never reused

Database Connections

  • Local Dev: sslmode=disable (acceptable)
  • Staging: sslmode=require (mandatory)
  • Production: sslmode=verify-full (mandatory)

Docker Compose

  • POSTGRES_PASSWORD must be set via environment
  • Running without it will fail with clear error message
  • Use: POSTGRES_PASSWORD=yourpassword docker-compose up -d

API Security

  • βœ… Non-root user in Docker (nonroot:nonroot)
  • βœ… Input validation at domain layer
  • βœ… SQL injection protection (parameterized queries)
  • βœ… Error handling (no sensitive data in responses)
  • ⚠️ TODO: Add rate limiting
  • ⚠️ TODO: Add authentication/authorization
  • ⚠️ TODO: Add request logging

🚨 If Credentials are Leaked

  1. Immediately rotate all passwords
  2. Revoke compromised API keys
  3. Review git history: git log --all -- .env
  4. Use BFG Repo-Cleaner if needed
  5. Force push cleaned history
  6. Notify team members

πŸ“ Environment Variables Checklist

Before deploying:

  • POSTGRES_PASSWORD is set (not using default)
  • DATABASE_URL uses SSL (sslmode=require)
  • All .env* files are in .gitignore
  • No hardcoded credentials in code
  • Secrets are stored in secrets manager
  • Passwords are strong and unique

πŸ” Security Scanning

# Check for committed secrets
git log --all -- .env .env.* *.pem *.key

# Scan for hardcoded secrets (install gitleaks first)
gitleaks detect --source . --verbose

# Check dependencies for vulnerabilities
go list -json -m all | nancy sleuth

πŸ“ž Reporting Security Issues

If you discover a security vulnerability:

  1. DO NOT open a public GitHub issue
  2. Email: security@yourcompany.com
  3. Include: description, steps to reproduce, impact
  4. Allow time for fix before public disclosure

🎯 Security Layers

  1. Application Layer: Input validation, business rules
  2. Transport Layer: HTTPS/TLS, no sensitive data in URLs
  3. Database Layer: Encrypted connections, least privilege
  4. Infrastructure: Firewall rules, VPC, security groups
  5. Secrets Management: External secrets manager

Last Updated: 2026-01-10
Security Contact: TBD

There aren't any published security advisories