Security
The Ellemment Stack implements comprehensive security measures to protect your application and users. Here's a detailed overview of the security features and their implementation.
Content Security Policy (CSP)
A strict Content Security Policy ensures only trusted resources load in your application.
Configuration
// server/index.ts app.use(helmet({ contentSecurityPolicy: { directives: { defaultSrc: ["'self'"], scriptSrc: ["'self'"], styleSrc: ["'self'"], imgSrc: ["'self'", "data:", "https:"], connectSrc: ["'self'"], // Add additional directives as needed } } }))
By default, CSP runs in report-only
mode. Enable enforcement by removing reportOnly: true
.
Network Security
Internal Network Architecture
When using Fly.io for hosting, instances communicate securely via internal network:
-
Instance Communication
- Inter-service connections
- Private network access
- Organization-level isolation
-
Cache Updates
// Internal request validation if (!isInternalRequest(request)) { throw new Error('Unauthorized') }
Cross-Site Scripting (XSS) Protection
Built-in React XSS protection through automatic escaping:
// Safe by default const SafeComponent = () => <div>{userInput}</div>
// Requires explicit opt-in for HTML const DangerousComponent = () => ( <div dangerouslySetInnerHTML={{ __html: sanitizedHtml }} /> )
Rate Limiting
Configurable rate limiting using express-rate-limit
:
import rateLimit from 'express-rate-limit' ,[object Object],
app.use('/api/', limiter)
Honeypot Protection
Form spam prevention using honeypot fields:
import { Honeypot } from 'remix-utils/honeypot/react'
function ContactForm() { return ( <Form> <Honeypot /> {/* Regular form fields */} </Form> ) }
Authentication Security
-
Password Storage
- Secure hashing with bcrypt
- Salt generation
- Configurable work factors
-
Session Management
- Secure cookie settings
- Session timeout
- CSRF protection
-
Two-Factor Authentication
- Time-based OTP
- Recovery codes
- Device verification
API Security
Request Validation
const schema = z.object({ username: z.string().min(3), email: z.string().email(), })
function validateRequest(data: unknown) { return schema.parse(data) }
Response Headers
app.use((req, res, next) => { res.setHeader('X-Content-Type-Options', 'nosniff') res.setHeader('X-Frame-Options', 'DENY') res.setHeader('X-XSS-Protection', '1; mode=block') next() })
Best Practices
Secret Management
- Use environment variables
- Implement secret rotation
- Audit access logs
- Encrypt sensitive data
Code Security
- Regular dependency updates
- Security linting rules
- Code review practices
- Automated scanning
Deployment Security
- HTTPS enforcement
- SSL/TLS configuration
- Network isolation
- Access controls
Monitoring
- Error tracking
- Security logging
- Incident response
- Performance monitoring
For more information about handling environment variables, see the secrets documentation. For deployment security configuration, refer to the deployment documentation.