Security Guides

Vercel Deployment Security: 6 Settings Developers Always Miss

SecuriSky TeamApril 9, 202612 min read

Introduction to Vercel Deployment Security

When deploying applications on Vercel, developers often overlook critical security settings, leaving their apps vulnerable to attacks. The main question is: what are the most commonly missed Vercel deployment security settings? The answer lies in six key areas: environment variables, HTTP headers, SSL/TLS certificates, CORS configuration, rate limiting, and logging.

Environment Variables

Environment variables are used to store sensitive data such as API keys, database credentials, and encryption keys. However, if not configured properly, they can be exposed to unauthorized parties. For example, in a vercel.json file, you might have:

{
  "env": {
    "DATABASE_URL": "@database_url"
  }

}

In this example, the DATABASE_URL environment variable is stored securely using Vercel's built-in secrets management.

HTTP Headers

HTTP headers play a crucial role in securing web applications. They can be used to enable security features such as Content Security Policy (CSP), Cross-Origin Resource Sharing (CORS), and HTTP Strict Transport Security (HSTS). For instance, to enable CSP, you can add the following header to your vercel.json file:

{
  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        {
          "key": "Content-Security-Policy",
          "value": "default-src 'self'; script-src 'self' https://cdn.example.com;"
        }
      ]
    }
  ]

}

This example enables CSP and defines a policy that only allows scripts to be loaded from the same origin and a specified CDN.

SSL/TLS Certificates

SSL/TLS certificates are essential for encrypting data in transit between the client and server. Vercel provides built-in support for SSL/TLS certificates, but you need to configure them correctly. For example, to enable SSL/TLS certificates for a custom domain, you can use the following code:

vercel cert issue example.com

This command issues an SSL/TLS certificate for the example.com domain.

CORS Configuration

CORS configuration is critical for securing web applications that make cross-origin requests. Vercel provides a built-in CORS configuration feature that can be enabled using the vercel.json file. For example:

{
  "cors": {
    "allowedOrigins": ["https://example.com"],
    "allowedMethods": ["GET", "POST"],
    "allowedHeaders": ["Content-Type", "Authorization"]
  }

}

This example enables CORS for the https://example.com origin and allows GET and POST requests with the Content-Type and Authorization headers.

Rate Limiting

Rate limiting is essential for preventing brute-force attacks and denial-of-service (DoS) attacks. Vercel provides a built-in rate limiting feature that can be enabled using the vercel.json file. For example:

{
  "rateLimit": {
    "maxRequests": 100,
    "timeWindow": 60
  }

}

This example enables rate limiting with a maximum of 100 requests per 60 seconds.

Logging

Logging is critical for detecting security incidents and debugging issues. Vercel provides a built-in logging feature that can be enabled using the vercel.json file. For example:

{
  "logs": {
    "enabled": true,
    "level": "info"
  }

}

This example enables logging with an info level.

To detect these security issues automatically, you can use tools like SecuriSky, which provides a comprehensive security scanner for Vercel deployments. By using SecuriSky, you can identify and fix security vulnerabilities before they are exploited by attackers.

Quick Fix Checklist

  • [ ] Review environment variables for sensitive data
  • [ ] Enable HTTP headers for security features like CSP and CORS
  • [ ] Configure SSL/TLS certificates for custom domains
  • [ ] Enable CORS configuration for cross-origin requests
  • [ ] Implement rate limiting to prevent brute-force attacks
  • [ ] Enable logging for security incident detection and debugging
  • Vercel Security Settings — SecuriSky Blog