AI Chatbot Security: 2FA, OAuth, Headers and More
Citai Team
March 17, 2026 · 9 min read
Why Does Security Matter in AI Chatbots?
AI chatbots handle sensitive information: internal documents, customer data, business configurations. A security breach doesn’t just expose data — it can generate manipulated responses that damage trust in your brand.
Multi-Factor Authentication (2FA/TOTP)
The first line of defense is ensuring that whoever accesses the admin panel is really who they claim to be.
How does TOTP work?
- The user activates 2FA from their account settings
- A TOTP secret is generated and a QR code is displayed
- The user scans the QR with an app like Google Authenticator
- On each login, besides the password, they enter the 6-digit code that changes every 30 seconds
Benefits:
- Protects against stolen or leaked passwords
- Open standard (RFC 6238), compatible with any TOTP app
- Doesn’t depend on SMS (vulnerable to SIM swapping)
Google OAuth: Delegated Authentication
OAuth allows users to sign in with their Google account, eliminating the need to manage passwords:
- Less friction: One click to enter
- Delegated security: Google handles authentication, including its own 2FA
- No passwords to manage: Eliminates risks of weak or reused passwords
HTTP Security Headers
HTTP headers are an invisible but critical layer of protection:
| Header | Function | Example |
|---|---|---|
Strict-Transport-Security |
Forces HTTPS | max-age=31536000; includeSubDomains |
Content-Security-Policy |
Prevents XSS | default-src 'self' |
X-Frame-Options |
Prevents clickjacking | DENY |
X-Content-Type-Options |
Prevents MIME sniffing | nosniff |
Referrer-Policy |
Controls referrer info | strict-origin-when-cross-origin |
Permissions-Policy |
Restricts browser APIs | camera=(), microphone=() |
API Key Hashing (SHA-256)
API keys are the bridge between your application and the chatbot. Citai never stores the key in plain text:
- Generation: A key is created with
sk-prefix + 32 random bytes - Show once: The full key is shown only at creation time
- Storage: The SHA-256 hash of the key is stored in the database
- Validation: Each request computes the hash of the received key and compares it with the stored one
If the database is compromised, the hashes are useless to the attacker — they cannot be reversed to the original key.
Rate Limiting with Redis
Rate limiting prevents abuse and denial-of-service attacks:
- Sliding window with Redis sorted sets — precise and efficient
- Configurable per API key — different limits per plan
- Fail-open design — if Redis goes down, requests pass through (no service blocking)
- Informative headers —
X-RateLimit-RemainingandX-RateLimit-Reset
HMAC Signatures for Webhooks
When Citai sends events to your server (escalations, negative feedback, etc.), each request includes an HMAC-SHA256 signature:
- Your server verifies the signature with the shared secret
- Prevents third parties from forging events
- Includes timestamp to prevent replay attacks
- ✅ Enable 2FA for all administrators
- ✅ Configure OAuth for corporate login
- ✅ Verify security headers with securityheaders.com
- ✅ Rotate API keys periodically
- ✅ Configure rate limiting according to your plan
- ✅ Validate HMAC signatures on webhooks
- ✅ Review audit logs weekly
Conclusion
Security in AI chatbots is not optional — it’s fundamental. Each layer of protection (2FA, OAuth, headers, hashing, rate limiting, HMAC) reduces a different attack vector. Citai implements all these layers so you can focus on what matters: delivering accurate answers to your users.
Protect your chatbot with enterprise security. Get started with Citai →
Try Citai for free
Create your intelligent knowledge base in minutes. No credit card required.
Create free accountRelated articles
GDPR and Privacy in AI Assistants: A Practical Guide
How to comply with GDPR when deploying AI chatbots: data portability, right to erasure, retention, and auditing.
Read article → TechnologyMulti-Tenancy in SaaS: Data Isolation with PostgreSQL
How we implement real multi-tenancy with complete data isolation, hierarchical roles, anti-fraud plan enforcement, and enterprise security.
Read article → TechnologyAudit Logging: Complete Traceability for AI Compliance
How audit logs in Citai enable complete action traceability, regulatory compliance, and forensic analysis.
Read article →