Authentication anti-patterns
Poor authentication practices lead to credential compromise. Even with strong authentication mechanisms available, mistakes in how you store, transmit, or manage credentials undermine all security protections.
The following patterns cover common practices that significantly increase risk. These patterns appear frequently in compromised integrations. Avoid these patterns.
Poor authentication practices make credential compromise easy for attackers and incidents expensive to remediate. The following practices increase risk:
- Never embed Auth Tokens, Main API Keys, or Restricted API Keys in browser code or mobile apps.
- Never hardcode credentials in source files including temporary commits you plan to remove.
- Never hardcode credentials in infrastructure templates, configuration files, or Docker images.
- Never commit credentials to version control repositories or CI/CD systems.
- Never store credentials in plain-text files on disk.
- Never store credentials in unencrypted local storage like browsers or mobile devices.
- Never log full authorization headers, request bodies containing secrets, or environment variables.
- Never transmit credentials through email, chat systems, screenshots, or issue trackers.
- Never treat a private network connection (VPN, private subnet, firewalls) as a replacement for authentication.
- Never assume internal only means you don't need to protect credentials.
- Never substitute network security for app security.
- Never ignore security advisories for Twilio SDKs, dependencies, frameworks, or infrastructure.
- Never delay applying security patches to systems that can access Twilio APIs.
- Never use deprecated or end-of-life versions of authentication libraries.
Anti-patterns simplify initial development through the following poor practices:
- Embedding credentials speeds prototyping.
- Hardcoding involves less work than integrating a secrets manager.
- Sharing credentials avoids waiting for access approvals.
- Skipping secrets management feels like progress until an incident occurs.
The development time saved gets lost in incident response, emergency credential rotation, and security audits.
These mistakes lead to the following consequences:
- Credentials exposure in GitHub, Docker registries, or AWS Simple Storage Service (S3) buckets
- Automated attackers discovering exposed credentials within minutes
- Unauthorized API usage, SMS pumping, or identity theft
- Incidents affecting your customer data and trust
- Regulatory fines and compliance violations
- Emergency incident response and credential rotation
- Audit failures and remediation work
Implement secure credential practices:
- Secrets management — storing and protecting credentials securely
- Secure authentication — choosing the right authentication method
- Defense-in-depth strategy — comprehensive security layers
- Incident response — responding to exposed credentials
- GitHub secret scanning documentation