Skip to main content

Security

Deployxa implements comprehensive security measures to protect your applications and data. This guide covers authentication, encryption, container isolation, and security best practices.

Overview

Security features include:

  • Authentication: JWT, Firebase, OAuth
  • Encryption: At rest and in transit
  • Container Isolation: Docker security
  • Secrets Management: Encrypted environment variables
  • Network Security: DDoS protection, firewalls
  • Compliance: SOC 2, GDPR, HIPAA

Authentication

JWT Authentication

JSON Web Tokens for API authentication:

How it works:

  1. User logs in with credentials
  2. Server generates JWT token
  3. Token sent to client
  4. Client includes token in requests
  5. Server validates token

Implementation:

// Generate token
const jwt = require('jsonwebtoken');
const token = jwt.sign(
{ userId: user.id, email: user.email },
process.env.JWT_SECRET,
{ expiresIn: '24h' }
);

// Validate token
const decoded = jwt.verify(token, process.env.JWT_SECRET);

Best practices:

  • Use strong secrets (256+ bits)
  • Set appropriate expiration
  • Use HTTPS only
  • Store tokens securely
  • Rotate secrets regularly

Firebase Authentication

Google Firebase for authentication:

Features:

  • Email/password
  • Social login (Google, Facebook, etc.)
  • Phone authentication
  • Anonymous authentication
  • Multi-factor authentication

Implementation:

// Initialize Firebase
const firebase = require('firebase/app');
require('firebase/auth');

firebase.initializeApp({
apiKey: process.env.FIREBASE_API_KEY,
authDomain: process.env.FIREBASE_AUTH_DOMAIN
});

// Sign in
firebase.auth().signInWithEmailAndPassword(email, password);

Best practices:

  • Use Firebase security rules
  • Enable multi-factor authentication
  • Monitor authentication logs
  • Use strong passwords
  • Regular security audits

OAuth 2.0

Third-party authentication:

Supported providers:

  • Google
  • GitHub
  • Facebook
  • Twitter
  • Microsoft

Implementation:

// Express.js with Passport
const passport = require('passport');
const GoogleStrategy = require('passport-google-oauth20').Strategy;

passport.use(new GoogleStrategy({
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: "/auth/google/callback"
}, (accessToken, refreshToken, profile, done) => {
// Find or create user
done(null, profile);
}));

Best practices:

  • Use HTTPS for callbacks
  • Validate state parameter
  • Store tokens securely
  • Request minimal scopes
  • Handle token expiration

Encryption

Encryption at Rest

All data encrypted at rest:

What's encrypted:

  • Environment variables
  • Database data
  • Build artifacts
  • Logs
  • Backups

Encryption methods:

  • AES-256 encryption
  • Key management service
  • Automatic key rotation
  • Hardware security modules

Database encryption:

-- PostgreSQL
CREATE EXTENSION pgcrypto;

-- Encrypt data
INSERT INTO users (email, password)
VALUES (
pgp_sym_encrypt('user@example.com', 'encryption_key'),
pgp_sym_encrypt('password123', 'encryption_key')
);

Encryption in Transit

All data encrypted in transit:

HTTPS/TLS:

  • TLS 1.3
  • Strong cipher suites
  • Certificate pinning
  • HSTS enabled

Internal communication:

  • Encrypted container networking
  • mTLS between services
  • Certificate management
  • Automatic renewal

Configuration:

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
ssl_prefer_server_ciphers off;
add_header Strict-Transport-Security "max-age=63072000" always;

Secret Management

Secure storage for secrets:

Features:

  • Encrypted storage
  • Access control
  • Audit logging
  • Version history
  • Automatic rotation

Best practices:

  • Never commit secrets
  • Use environment variables
  • Rotate secrets regularly
  • Use different secrets per environment
  • Monitor secret access

Container Isolation

Docker Security

Containers are isolated and secure:

Isolation features:

  • Separate namespaces
  • Resource limits
  • Network isolation
  • File system isolation
  • Process isolation

Security measures:

  • Non-root users
  • Read-only file systems
  • Capability dropping
  • Seccomp profiles
  • AppArmor/SELinux

Container configuration:

# Use non-root user
USER node

# Read-only file system
RUN chmod 555 /app

# Drop capabilities
RUN setcap cap_net_bind_service=+ep /usr/local/bin/node

Resource Limits

Containers have resource limits:

CPU limits:

  • Prevent CPU monopolization
  • Fair resource allocation
  • Predictable performance

Memory limits:

  • Prevent memory exhaustion
  • Automatic OOM handling
  • Predictable behavior

Configuration:

{
"resources": {
"limits": {
"cpu": "1000m",
"memory": "512Mi"
},
"requests": {
"cpu": "500m",
"memory": "256Mi"
}
}
}

Network Isolation

Containers have isolated networks:

Features:

  • Private networking
  • Network policies
  • Firewall rules
  • DNS isolation

Security measures:

  • No public IP addresses
  • Internal networking only
  • Encrypted communication
  • Network segmentation

Network Security

DDoS Protection

Automatic DDoS protection:

Protection layers:

  • Layer 3/4 protection
  • Layer 7 protection
  • Rate limiting
  • Traffic analysis

Features:

  • Automatic detection
  • Instant mitigation
  • Global scrubbing centers
  • 24/7 monitoring

Firewall Rules

Configurable firewall rules:

Default rules:

  • Allow HTTPS (443)
  • Allow HTTP (80)
  • Block all other inbound
  • Allow all outbound

Custom rules:

{
"firewall": {
"inbound": [
{
"port": 443,
"protocol": "tcp",
"action": "allow"
},
{
"port": 80,
"protocol": "tcp",
"action": "allow"
}
],
"outbound": [
{
"port": "all",
"protocol": "all",
"action": "allow"
}
]
}
}

IP Whitelisting

Restrict access by IP:

Use cases:

  • Admin panels
  • Internal APIs
  • Development environments
  • Restricted content

Configuration:

{
"ipWhitelist": [
"192.168.1.0/24",
"10.0.0.0/8",
"203.0.113.50"
]
}

Application Security

Input Validation

Validate all user inputs:

Server-side validation:

// Express.js with Joi
const Joi = require('joi');

const schema = Joi.object({
email: Joi.string().email().required(),
password: Joi.string().min(8).required(),
age: Joi.number().integer().min(18).max(120)
});

app.post('/register', (req, res) => {
const { error } = schema.validate(req.body);
if (error) return res.status(400).json({ error: error.details[0].message });
// Process registration
});

Client-side validation:

// React with Formik
import { Formik, Form, Field } from 'formik';
import * as Yup from 'yup';

const validationSchema = Yup.object({
email: Yup.string().email().required(),
password: Yup.string().min(8).required()
});

<Formik
validationSchema={validationSchema}
onSubmit={handleSubmit}
>
{/* Form fields */}
</Formik>

SQL Injection Protection

Use parameterized queries:

Safe queries:

// PostgreSQL with pg
const { Pool } = require('pg');
const pool = new Pool();

// Parameterized query
const result = await pool.query(
'SELECT * FROM users WHERE email = $1',
[email]
);
# Python with psycopg2
import psycopg2

conn = psycopg2.connect(DATABASE_URL)
cur = conn.cursor()

# Parameterized query
cur.execute(
"SELECT * FROM users WHERE email = %s",
(email,)
)

Unsafe queries (NEVER use):

// ❌ SQL injection vulnerable
const result = await pool.query(
`SELECT * FROM users WHERE email = '${email}'`
);

XSS Protection

Prevent cross-site scripting:

Sanitize output:

// Express.js with helmet
const helmet = require('helmet');
app.use(helmet());

// Sanitize user input
const sanitizeHtml = require('sanitize-html');
const clean = sanitizeHtml(dirty);
<!-- Use text content instead of innerHTML -->
<div id="output"></div>
<script>
document.getElementById('output').textContent = userInput;
</script>

Content Security Policy:

app.use(helmet.contentSecurityPolicy({
directives: {
defaultSrc: ["'self'"],
scriptSrc: ["'self'", "'unsafe-inline'"],
styleSrc: ["'self'", "'unsafe-inline'"],
imgSrc: ["'self'", "data:", "https:"],
}
}));

CSRF Protection

Prevent cross-site request forgery:

Implementation:

// Express.js with csurf
const csurf = require('csurf');
const csrfProtection = csurf({ cookie: true });

app.get('/form', csrfProtection, (req, res) => {
res.render('form', { csrfToken: req.csrfToken() });
});

app.post('/process', csrfProtection, (req, res) => {
// Process form
});
<!-- Include CSRF token in forms -->
<form method="POST" action="/process">
<input type="hidden" name="_csrf" value="{{csrfToken}}">
<!-- Form fields -->
</form>

Compliance

SOC 2

Service Organization Control 2:

Trust Service Criteria:

  • Security
  • Availability
  • Processing Integrity
  • Confidentiality
  • Privacy

Deployxa compliance:

  • Annual audits
  • Continuous monitoring
  • documented policies
  • Employee training
  • Incident response

GDPR

General Data Protection Regulation:

GDPR principles:

  • Lawfulness, fairness, transparency
  • Purpose limitation
  • Data minimization
  • Accuracy
  • Storage limitation
  • Integrity and confidentiality

Deployxa features:

  • Data processing agreements
  • Right to access
  • Right to erasure
  • Data portability
  • Privacy by design

HIPAA

Health Insurance Portability and Accountability Act:

HIPAA requirements:

  • Administrative safeguards
  • Physical safeguards
  • Technical safeguards
  • Organizational requirements

Deployxa features:

  • Business Associate Agreement (BAA)
  • Encryption at rest and in transit
  • Access controls
  • Audit logs
  • Enterprise plan required

Security Best Practices

For Developers

✅ Validate all inputs ✅ Use parameterized queries ✅ Sanitize output ✅ Implement authentication ✅ Use HTTPS only ✅ Store secrets securely ✅ Keep dependencies updated ✅ Use security headers ✅ Implement rate limiting ✅ Monitor for vulnerabilities

For Organizations

✅ Enable two-factor authentication ✅ Use strong passwords ✅ Regular security audits ✅ Employee security training ✅ Incident response plan ✅ Access control policies ✅ Regular backups ✅ Monitor logs ✅ Update systems regularly ✅ Document security procedures

For Applications

✅ Use HTTPS ✅ Implement authentication ✅ Authorize all requests ✅ Validate inputs ✅ Sanitize outputs ✅ Use security headers ✅ Enable CORS properly ✅ Implement rate limiting ✅ Monitor for attacks ✅ Keep dependencies updated

Security Headers

Content Security Policy:

Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:;

X-Frame-Options:

X-Frame-Options: DENY

X-Content-Type-Options:

X-Content-Type-Options: nosniff

Strict-Transport-Security:

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

X-XSS-Protection:

X-XSS-Protection: 1; mode=block

Referrer-Policy:

Referrer-Policy: strict-origin-when-cross-origin

Implementation

Express.js with Helmet:

const helmet = require('helmet');

app.use(helmet({
contentSecurityPolicy: {
directives: {
defaultSrc: ["'self'"],
scriptSrc: ["'self'", "'unsafe-inline'"],
styleSrc: ["'self'", "'unsafe-inline'"],
imgSrc: ["'self'", "data:", "https:"],
}
},
hsts: {
maxAge: 31536000,
includeSubDomains: true,
preload: true
}
}));

Nginx:

add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline';" always;
add_header X-Frame-Options "DENY" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;

Incident Response

Security Incidents

Types of incidents:

  • Data breaches
  • Unauthorized access
  • Malware infections
  • DDoS attacks
  • Vulnerability exploits

Response Process

  1. Detection: Identify the incident
  2. Containment: Limit the impact
  3. Eradication: Remove the threat
  4. Recovery: Restore systems
  5. Lessons Learned: Improve processes

Reporting Incidents

Contact security team:

Information to provide:

  • Incident description
  • Affected systems
  • Timeline
  • Evidence
  • Contact information

Troubleshooting

Authentication Failed

Problem: Users cannot authenticate

Solution:

  1. Check authentication configuration
  2. Verify credentials
  3. Check token expiration
  4. Review authentication logs
  5. Test authentication flow
  6. Contact support if issue persists

SSL Certificate Issues

Problem: SSL certificate errors

Solution:

  1. Check certificate status
  2. Verify DNS configuration
  3. Check certificate expiration
  4. Clear browser cache
  5. Try different browser
  6. Contact support if issue persists

Security Headers Not Working

Problem: Security headers not applied

Solution:

  1. Check header configuration
  2. Verify server configuration
  3. Check for conflicts
  4. Test with security tools
  5. Review documentation
  6. Contact support if issue persists

Container Security Issues

Problem: Container security vulnerabilities

Solution:

  1. Update base images
  2. Scan for vulnerabilities
  3. Review Dockerfile
  4. Apply security patches
  5. Restart containers
  6. Contact support if issue persists

Resources


Need Help? Contact security@deployxa.com or join our community Discord.