Sample alert How it works Coverage PENTEST METHODOLOGY DOCS PRICING FAQ MCP CONTACT LOG IN SCAN MY APP →

Is Netlify Safe from Hackers? Logs, Functions & Redirects

Netlify handles HTTPS, deploys, and edge. Your app still owns auth, env exposure, and function security - the places AI-generated sites commonly leak.

SCAN YOUR NETLIFY SITE NOW

Enter your Netlify URL - we check for exposed env in the bundle, open functions, and auth gaps on the live site.

JAMstack Security Model

Netlify pre-builds static assets, so a static site has no long-running app server to attack. SSRF against an app server, SQL injection through a runtime form handler and RCE in a backend do not apply. Once you add Functions, Forms, Identity or Edge Functions, you are in the same threat model as any serverless platform, with Netlify-specific defaults.

Four leaks cover most Netlify misconfigurations: env vars printed in build logs, open redirect rules in _redirects, Functions deployed without auth, and Edge Functions that mutate headers in ways that bypass downstream checks. None are platform bugs. All four are configuration choices that look fine on a first read.

Netlify owns the CDN and TLS layer. You own the trust boundary of every request that hits a Function, Form endpoint or rewrite. AI generators (Lovable, Cursor, Claude Code, Bolt templates) produce a working netlify.toml and Functions that “work in preview,” but often leave out the auth middleware, env context scoping and redirect allowlist that production needs.

Security Considerations

Netlify Functions

Netlify Functions run on AWS Lambda. The runtime is isolated, but the handler is whatever you wrote. Common failures:

  • The function trusts event.headers['x-forwarded-for'] for rate limiting. Spoof the header, bypass the limit. Use context.ip from the new Functions API (or event.headers['x-nf-client-connection-ip'] on older runtimes).
  • A “test” endpoint (/.netlify/functions/debug) dumps env vars or runs arbitrary SQL, then gets indexed by Google.
  • An error path returns JSON.stringify(process.env) because the developer wanted to see what went wrong in prod.
  • Scheduled or Background Functions sit behind a guessable path with no shared secret, so anyone can enqueue expensive work.
  • A function takes a URL parameter and fetches it server-side (SSRF into internal metadata or third-party APIs billed to you).
// netlify/functions/get-user.js - wrong
exports.handler = async (event) => {
  const id = event.queryStringParameters.id;
  const user = await db.query(`SELECT * FROM users WHERE id = ${id}`);
  return { statusCode: 200, body: JSON.stringify(user) };
};

// right
exports.handler = async (event, context) => {
  const session = await getSession(event);
  if (!session) return { statusCode: 401, body: '' };
  const id = event.queryStringParameters.id;
  if (!/^[0-9a-f-]{36}$/.test(id)) return { statusCode: 400, body: '' };
  const user = await db.query('SELECT id, email FROM users WHERE id = $1', [id]);
  // ownership - auth alone is not enough
  if (user?.owner_id !== session.userId) return { statusCode: 403, body: '' };
  return { statusCode: 200, body: JSON.stringify(user) };
};

List every path under netlify/functions/ and netlify/edge-functions/ before launch. For each, note who can call it, what env it needs and what it returns on error. “Anyone with the URL” blocks the launch unless the handler is intentionally public and rate-limited.

Form Submissions

Netlify Forms spam protection is opt-in. Without a honeypot or reCAPTCHA, a public form collects spam and can hit the submission rate limit. If you forward submissions to email or Slack, attacker payloads land in a UI that may render them.

<form name="contact" method="POST" data-netlify="true" data-netlify-honeypot="bot-field">
  <input type="hidden" name="form-name" value="contact" />
  <p hidden><label>Don't fill this out: <input name="bot-field" /></label></p>
  <input type="email" name="email" required />
  <textarea name="message" required></textarea>
  <button type="submit">Send</button>
</form>

Treat form submissions as untrusted input, including after they reach Slack. If you pipe form webhooks into Zapier or Make, assume the payload can contain HTML, JS and CSV formula injection (=HYPERLINK(...) executes when the spreadsheet opens). Strip or quote leading =, +, -, @ before any spreadsheet sink.

Keep notification email subjects static. A user-controlled subject allows mail-header injection or fake internal alerts. Put user content in the escaped body only.

Environment Variables

Netlify env vars can be scoped per context (production, deploy-preview, branch-deploy) and per branch. The default UI nudges you toward “All scopes,” which puts your Stripe live key in every Pull Request preview. Anyone with the deploy URL can hit the function and use the production key.

# Scope a secret to production only
netlify env:set STRIPE_SECRET_KEY sk_live_xxx --context production
netlify env:list

Variables with a framework public prefix (NEXT_PUBLIC_, VITE_, PUBLIC_, GATSBY_) are bundled into the client. Treat them as public.

Variable type Context Notes
STRIPE_SECRET_KEY, DB URLs, service roles production only Never All scopes
Test Stripe / sandbox DB deploy-preview, branch-deploy Separate accounts
NEXT_PUBLIC_* / VITE_* publishable keys All contexts OK Must be safe if leaked
Analytics write keys Prefer production; check product docs Some “public” keys still allow data pollution

On team sites, check Linked branch env and Shared environment variables: a cloned site can inherit more secrets than the UI suggests. After a contractor leaves, rotate every secret that ever lived in All scopes.

Build Logs

Build logs are visible to every team member and persist after deploys. A printenv or env line in a build script writes every secret to the log in plaintext. Audit build commands and custom plugins for printenv, env, set and console.log(process.env.

Less obvious leaks:

  • npm install scripts that echo configuration for debugging.
  • Webpack/Vite plugins that dump process.env into a stats.json artifact.
  • Failed builds that re-print the full command line, including inline secrets (API_KEY=... npm run build).
  • Marketplace build plugins that request broad env access.

If a secret ever appeared in a build log, rotate it. Deleting the line does not help anyone who already copied the log.

Deploy Previews

Deploy previews are public by default. The URL pattern is guessable per PR, and Netlify’s GitHub integration posts the link as a PR comment, so anyone watching a public repo sees it. Use Password Protection (Pro+) or Role-based access control (Enterprise) for projects with sensitive features.

Previews expose the same Function paths as production (/.netlify/functions/*). If a preview carries production Stripe or OpenAI keys, it is a free abuse endpoint until the PR closes. Prefer:

  1. Preview-scoped secrets only.
  2. Password protection on private product work.
  3. Shorter retention or auto-delete of old deploy previews.
  4. No production data fixtures in the static build that ships to previews.

Redirect Rules

_redirects and netlify.toml redirects are an easy way to ship an open redirect:

# _redirects - open redirect, do not use
/go  /:url  302

A user visits /go?url=https://attacker.example/login and lands on the phishing page with your domain in the referrer. Allowlist destinations:

/go/docs  https://docs.example.com  302
/go/blog  https://blog.example.com  302

Proxy rules have the same problem: /api/* https://:host/:splat 200 is an open SSRF if host is user-controlled.

AI-generated netlify.toml files often copy SPA fallbacks and “proxy to API” blocks from tutorials:

# Dangerous shape - do not ship
[[redirects]]
  from = "/proxy/*"
  to = "https://:splat"
  status = 200
  force = true

A safe proxy fixes the upstream host:

[[redirects]]
  from = "/api/*"
  to = "https://api.internal.example.com/:splat"
  status = 200
  force = true
  headers = {X-From = "netlify"}

The origin must still authenticate the caller. A proxy that forwards Authorization is fine. A proxy that strips auth headers because an Edge Function “normalized” them creates a public API.

Identity, gated sites and soft gates

Netlify Identity and password-protected sites are soft gates for static assets. Anyone with a deploy artifact, an old CDN cache or a leaked preview URL can still read the built HTML and JS. Put real secrets behind Functions with session checks. A Stripe live key in the static bundle behind a “members only” gate is still exposed.

If you use Identity JWTs in Functions, validate the signature and expiry server-side. Never trust a client-supplied user_id claim.

Edge Functions

Edge Functions can rewrite headers and responses before the CDN origin. AI-generated edge code sometimes:

  • Strips Authorization when proxying to an API, making it public.
  • Reflects Origin into Access-Control-Allow-Origin without an allowlist.
  • Adds debug headers that leak internal hostnames.
  • Sets cookies without Secure, HttpOnly or SameSite on auth bridges.
  • Implements “auth” with a shared query param (?key=demo) that ends up in logs and Referers.

An origin allowlist (illustrative):

// netlify/edge-functions/cors.js
const ALLOW = new Set(["https://app.example.com", "https://www.example.com"]);

export default async (request, context) => {
  const origin = request.headers.get("Origin");
  const response = await context.next();
  if (origin && ALLOW.has(origin)) {
    response.headers.set("Access-Control-Allow-Origin", origin);
    response.headers.set("Vary", "Origin");
  }
  return response;
};

Never use Access-Control-Allow-Origin: * with credentialed APIs.

Common Mistakes in Netlify Audits

  • Production secrets duplicated to “All scopes,” exposing them in deploy previews.
  • Function endpoints with no auth check, discoverable by fuzzing /.netlify/functions/.
  • _redirects proxy rules with placeholder hosts that act as open proxies.
  • A misbehaving postinstall script printing env vars into build logs.
  • Forms webhooks that auto-post to Slack without sanitization, enabling markdown/link spam and token phishing.
  • Background Functions used as free compute by unauthenticated callers (a cost attack, not only a data leak).
  • Security headers only on / while /app/* or Function responses omit them.
  • SPA _redirects /* /index.html 200 combined with sensitive JSON files in /public that should have been gitignored.
  • Vite/React apps with VITE_OPENAI_KEY in the client build.
  • console.log(event) left in production Functions, dumping Authorization headers into log drains.
  • A scaffolded netlify.toml that opens /admin → /admin.html without app auth.
  • The same secret deployed as a Netlify env var and as a hard-coded fallback in source “so local works.”

When a generator says it set up Netlify Forms and a contact Function, review both: spam controls on the form, auth and validation on the Function, no shared production secrets on the preview context.

Netlify vs Vercel

  • Netlify’s _redirects is plain text and easy to misread. Vercel’s vercel.json is structured but easier to over-permit.
  • Netlify Forms is built in. Spam protection is opt-in.
  • Vercel’s Deployment Protection is more polished. Netlify’s Site Password is older and clunkier.
  • Both ship NEXT_PUBLIC_* / VITE_* env vars to the browser.
  • Netlify’s function URL layout (/.netlify/functions/name) is a stable recon target. Vercel routes often sit under /api/* but are equally public without auth.
  • Edge middleware on both platforms is a common place for AI code to “fix CORS” by reflecting Origin.

Neither platform wins on defaults. The team that scopes env and authenticates every function does.

Enterprise Considerations

  • SSO: SAML SSO is Enterprise-only. Below that, every team member has a personal account.
  • Audit Logs: Team Audit Log is on Pro+; full deployment and CLI activity is Enterprise.
  • SOC 2 boundary: Netlify covers the platform. Your application’s handling of customer data is yours.
  • Secret rotation: No built-in rotation. Use Doppler, Infisical, or rotate via the Netlify API on a schedule.
  • RBAC: Separate who can edit env vars from who can deploy. A compromised GitHub OAuth session with deploy rights is enough to ship a malicious Function.
  • GitHub/GitLab integration scopes: Review which repos the Netlify app can access; grant least privilege per monorepo.

Security Assessment

Strengths

    • Enterprise-grade CDN and infrastructure
    • Automatic HTTPS with Let’s Encrypt and managed certs
    • SOC 2 Type II compliance
    • Built-in DDoS protection
    • Encrypted environment variables with per-context scoping
    • Deploy previews with optional access controls
    • Forms with built-in (opt-in) spam protection
    • Edge Functions for request-time controls (when written carefully)
    • Strong static-hosting posture vs a DIY VPS

Concerns

    • Netlify Functions security is developer responsibility
    • Default “All scopes” env var setting leaks production secrets to previews
    • _redirects and proxy rules trivially become open redirects / SSRF
    • Build logs can leak secrets and are visible team-wide
    • Form submissions need explicit spam protection
    • Deploy previews are public by default
    • Identity/password gates are not API security

Split of responsibility: Netlify vs you

Layer Netlify owns You own
TLS, CDN, DDoS Yes Config custom domains correctly
Build isolation Yes Don’t print secrets; audit plugins
Function runtime isolation Yes Auth, validation, SSRF, cost controls
Env encryption at rest Yes Scope, rotation, least privilege
Forms storage Yes Spam, webhook trust, rendering
Redirect engine Yes Allowlists, no open proxies
App authorization / BOLA No Entirely yours

Hardening checklist

  1. Scope secrets with netlify env:set ... --context production.
  2. Auth on every Function; validate IDs; parameterized queries; ownership checks.
  3. Allowlist-only redirects; no :url open patterns.
  4. Honeypot + CAPTCHA on Forms; sanitize webhook sinks.
  5. Password-protect previews for sensitive apps.
  6. Security headers via _headers or netlify.toml.
  7. No printenv in build; audit postinstall scripts; rotate anything that leaked to logs.
  8. Edge Functions: allowlist CORS; never strip auth headers by accident.
  9. Inventory /.netlify/functions/* and remove debug handlers.
  10. Scan production URL with VibeEval, Token Leak Checker, Security Headers Checker.

How to verify

netlify env:list
# Inspect context columns - production-only secrets

# Open redirect negative test
curl -sI "https://yoursite.com/go?url=https://evil.test" | grep -i location
# Must not redirect to evil.test

# Function without session
curl -sI "https://yoursite.com/.netlify/functions/get-user?id=1"
# Expect 401

# Headers present on HTML and API
curl -sI "https://yoursite.com/" | grep -iE 'strict-transport|content-security|x-frame'
curl -sI "https://yoursite.com/.netlify/functions/health" | grep -iE 'x-content-type|referrer-policy'

Then open a deploy preview in an anonymous browser and confirm production payment keys are not callable from preview Functions. If a preview can charge live Stripe, your context scoping failed.

The Verdict

Netlify is a safe deployment platform with solid infrastructure security, and the static model removes most server-side attack surface. The risks sit where your config meets Netlify’s defaults: Functions auth, env var scoping, redirect rules and preview exposure.

For AI-assisted sites, treat every generated netlify.toml and Function as untrusted until the ten-item checklist above passes. Netlify will deploy an insecure config that builds cleanly.

How to Secure Netlify

Step-by-step guide covering env var scoping, Functions auth patterns, redirect rule auditing, and Preview protection.

Netlify Security Checklist

Interactive checklist for the four launch-blockers above plus the quarterly review items.

Is Vercel Safe?

Side-by-side comparison of the most common deployment failure modes on the two leading JAMstack platforms.

Security Headers Checker

Grade _headers / netlify.toml output.

_headers baseline for Netlify

/*
  X-Frame-Options: DENY
  X-Content-Type-Options: nosniff
  Referrer-Policy: strict-origin-when-cross-origin
  Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
  Content-Security-Policy: default-src 'self'

Tune CSP for Stripe.js and analytics. Apply similar headers to Function responses that return HTML or JSON browsers might interpret loosely.

Bolt and AI templates on Netlify

Bolt.new and many AI scaffolds default to Netlify. Check for:

  • Functions under /.netlify/functions/* without auth
  • VITE_* secrets in the static build
  • SPA fallback /* /index.html 200 that serves sensitive files from /public
  • Preview deploys with production Stripe when env scope is “All”

Run the same four checks (Functions, env, redirects, previews) after every generator session. See Bolt security and How to Secure Netlify.

Function cost abuse

Unauthenticated Functions that call OpenAI or generate images let attackers script /.netlify/functions/generate until your quota runs out. Mitigate with auth, per-user rate limits, provider spend caps and alerts on invocation count.

Scan Your Netlify Site

Let VibeEval scan your Netlify deployment for open redirects, Functions without auth and exposed env vars.

Common questions

Is Netlify safe for production sites?
Yes for static and JAMstack workloads when Functions are authenticated, env vars are scoped per context, redirects are allowlisted, and deploy previews are protected for sensitive apps. Netlify's CDN and TLS are strong; application and config mistakes are the usual breach path.
Can build logs leak secrets?
Yes. Commands or plugins that print the environment write secrets into build logs visible to team members. Avoid printenv/debug dumps and audit postinstall scripts.
Are Netlify Functions private by default?
No. Functions are publicly reachable at /.netlify/functions/* unless you enforce auth inside the handler or put other access controls in front.
How do open redirects happen on Netlify?
Usually via _redirects or netlify.toml rules that forward to a user-controlled destination. Use fixed destinations only.
Should deploy previews be public?
Only for non-sensitive projects. Previews often share shapes of production UI and sometimes production secrets if env scopes are wrong. Use password protection on Pro+ for private product work.
Is Netlify safer than a traditional VPS?
For static sites, yes - no long-lived app server. Once you add Functions, Forms, and Identity, you share most serverless risks with Vercel and others.
Do Netlify Background Functions change the security model?
They change duration, not trust. Background Functions still need auth on the trigger path, still run with the same env scope, and still must not dump secrets into logs. Long-running work is easier to abuse for cost if the endpoint is public and unthrottled.
Can AI-generated netlify.toml introduce SSRF?
Yes. Proxy rules that interpolate user-controlled hosts (`/api/* https://:host/:splat 200`) turn your site into an open proxy. Treat every rewrite destination as an allowlist, never a free variable.

Secure beyond netlify defaults

Platform security is not app security. Scan the live site for keys, open endpoints, and access-control gaps Netlify cannot fix for you.

14-day free trial · Cancel anytime

SCAN MY NETLIFY SITE →