Vercel Security Guide

Frontend cloud platform

medium risk level

Vercel deploys frontend apps and serverless functions. Security risks center around environment variable exposure, misconfigured serverless functions, and edge middleware bypasses in Next.js apps.

Common Vulnerabilities

critical

Environment variables leaked to client

Variables prefixed with NEXT_PUBLIC_ are bundled into client JavaScript. Developers accidentally expose secrets this way.

Only prefix truly public values with NEXT_PUBLIC_. Keep secrets server-side only.

high

Unprotected API routes

Next.js API routes deployed on Vercel often lack authentication checks.

Add auth middleware to all API routes. Verify JWT tokens server-side.

high

Middleware bypass via direct function URL

Edge middleware can be bypassed by calling serverless function URLs directly.

Always validate auth in the API route itself, not just in middleware.

medium

Preview deployments expose staging data

Preview URLs are publicly accessible and may connect to production databases.

Use separate environment variables for preview deployments. Add password protection.

medium

Missing security headers

Default deployments lack CSP, HSTS, and other security headers.

Configure security headers in vercel.json or next.config.js.

Pre-Launch Security Checklist

Verify no secrets use NEXT_PUBLIC_ prefixRequired
Add authentication to all API routesRequired
Don't rely solely on middleware for authRequired
Protect preview deployments with passwords
Configure security headers in vercel.json
Review serverless function timeout settings
Enable Vercel's DDoS protection
Check that source maps are not publicly accessibleRequired
Audit third-party integrations and webhooks
Use Vercel's built-in analytics to monitor for anomalies

Security Tips

1.

Use Vercel's Environment Variable UI to separate production, preview, and development secrets.

2.

Always validate authentication in the API route handler, not just in middleware.

3.

Run Erzo's Header Checker on your Vercel deployment to verify security headers.

Scan your Vercel app now

Erzo automatically detects these vulnerabilities and gives you actionable fixes.

    Erzo — AI Code Security Scanner | Error Zero