Prerequisites
- A Replit account
- Basic understanding of your preferred programming language
- Familiarity with the Project Editor
- An application you’re building on Replit
Front-end security
HTTPS everywhere
HTTPS everywhere
Replit uses HTTPS by default for all applications. So you don’t need to worry about it!
Input validation and sanitization
Input validation and sanitization
Always validate and sanitize user input to prevent cross-site scripting (XSS) attacks:Switch to Lite mode and ask Agent:
Keep sensitive data out of the browser
Keep sensitive data out of the browser
You should use Replit Secrets to store sensitive information like API keys.Be sure you don’t pass secrets to the client side or put them in the following places:
- Local storage
- Session storage
- Client-side JavaScript
- Cookies without proper security attributes
CSRF protection
CSRF protection
Back-end security
Authentication fundamentals
Authentication fundamentals
When implementing authentication:
- Use Replit Auth when possible
- If building custom auth, use established libraries
- Never store plain text passwords
API endpoint protection
API endpoint protection
Secure your API endpoints:
- Add authentication to sensitive endpoints
- Implement proper CORS settings
- Consider rate limiting
SQL injection prevention
SQL injection prevention
Agent uses ORMs by default, which helps prevent SQL injection. If writing custom database queries:
Security headers
Security headers
Add important security headers to your application:You can scan your site at securityheaders.com for recommendations.Switch to Lite mode and ask Agent:
Ongoing security practices
Keep dependencies updated
Keep dependencies updated
Regularly check for outdated packages that might have vulnerabilities:
Proper error handling
Proper error handling
Don’t expose sensitive information in error messages:Ask Agent:
File upload security
File upload security
If your application allows file uploads:
- Restrict file types and sizes
- Scan for malware if possible
- Store files in Replit’s object storage
- Generate new filenames rather than using user-provided ones
Rate limiting
Rate limiting
Implement rate limiting for API endpoints, especially authentication-related ones:Ask Agent: