Auditing Netlify
Netlify publishes static sites and functions from a repository: every push triggers a build, and every pull request gets a preview URL. The risks are the same as in Vercel, under different names:
- secret variables that end up in the JavaScript anyone can download;
- public previews of branches that shouldn’t be visible;
- teams with dashboard access and no SSO or 2FA.
Netlify also adds a secret scanner that stops the build. This card uses the build engine itself to show what it detects and what it doesn’t.
Responsibility model
Section titled “Responsibility model”Netlify runs the CDN, the builds and the functions. The customer decides:
- which variables exist, in which contexts, and whether they are marked as secret;
- which deploys are public and which are protected;
- who is on the team and how they sign in;
- which security headers the site serves;
- where the build hooks and API tokens live.
flowchart LR
G["Repository"] -->|"push / PR"| B["Netlify build<br/>variables per context"]
B -->|"secret scanning"| D{"secret in the output?"}
D -->|"yes"| F["Failed build"]
D -->|"no"| P["Production deploy"]
B --> V["Deploy Previews and<br/>branch deploys"]
V -->|"unprotected"| X["Anyone with the URL"]
H["Build hook<br/>secret URL"] --> B
T["Team: strict SSO, 2FA"] --> B
Environment variables and Secrets Controller
Section titled “Environment variables and Secrets Controller”Each variable has:
- a scope: Builds, Functions, Runtime, Post processing;
- a value per deploy context: production, Deploy Previews, branch deploys,
dev.
If Contains secret values is checked, the secrets policy applies:
- only code running on Netlify receives the real value;
- the UI, CLI and API don’t return the unmasked value except in the
devcontext; - values are masked in build logs;
- secret scanning looks for those values in the build output and in the repository, and stops publishing if it finds them.
There is also smart detection: it looks for strings with typical key prefixes even if they aren’t marked as secret. It is turned off with SECRETS_SCAN_SMART_DETECTION_ENABLED=false, and all scanning with SECRETS_SCAN_ENABLED=false. During the audit, these variables, SECRETS_SCAN_OMIT_KEYS and SECRETS_SCAN_OMIT_PATHS are reviewed one by one: every exclusion is a hole someone opened to get the build to pass.
Lab: what the scanner detects
Section titled “Lab: what the scanner detects”Using netlify-cli 27.20.1 (which ships @netlify/build 37.7.6), a site with the classic mistake is built locally: the build embeds in dist/app.js a Stripe key that should have stayed on the server.
const fs = require("fs");fs.mkdirSync("dist", { recursive: true });fs.writeFileSync("dist/app.js", `const config = { stripeKey: "${process.env.STRIPE_SECRET_KEY}" };\n`);fs.writeFileSync("dist/index.html", "<script src=app.js></script>\n");1. Variable marked as secret. In the lab, the mark is simulated with the --explicitSecretKeys option, which is how the build engine receives the list of secret variables. On Netlify that list is supplied by the platform; that part could not be observed from outside. Real output:
Secrets scanning found 1 instance(s) of secrets in build output or repo code.Secret env var "STRIPE_SECRET_KEY"'s value detected: found value at line 1 in dist/app.js found value at line 7 in netlify.tomlTo prevent exposing secrets, the build will fail until these secret values are not found in build output or repo files.It finds the value in the output and also in netlify.toml, where it had been defined for the lab.
2. Unmarked variable, smart detection only (--enhancedSecretScan). With an sk_live_51… key of 46 random characters, the build finishes fine:
Secrets scanning complete. 5 file(s) scanned. No secrets detected in build output or repo code!The reason is in the scanner’s own code (plugins_core/secrets_scanning/utils.js). The regular expression requires that only letters, digits or hyphens follow the prefix, and that the string has an entropy of at least 4.5 bits per character. Testing the findLikelySecrets function with real formats:
sk_live_ NOT detectedrk_live_ NOT detectedghp_A4KF detected (prefix ghp_)AKIAWD7O NOT detectedxoxb-7XM detected (prefix xoxb-)shpat_Bi detected (prefix shpat_)- Stripe keys start with the
sk_prefix from the list, but the underscore inlive_breaks the match. AKIA(AWS access key IDs) is not in this version’s prefix list.
Who sees each deploy
Section titled “Who sees each deploy”Deploy Previews and branch deploys have their own URLs and are public by default. They contain code that isn’t in production yet: new features, test data, sometimes variables from another context.
| Option | What it does |
|---|---|
| Basic password protection | One shared password for all visitors |
| Team login protection | Only Netlify team members; supports SSO if the team enforces it in strict mode |
| “Previews only” scope | Protects previews and leaves production open |
| All deploys scope | Protects production as well |
Two common mix-ups that Netlify’s own documentation clears up:
- Team SSO controls who gets into the dashboard, not who sees the site. Requiring SSO to view a deploy also needs team login protection.
- Netlify Identity is user login inside the application, not a barrier in front of the site.
Team, tokens and hooks
Section titled “Team, tokens and hooks”- Strict SSO. Netlify’s security scorecard recommends strict mode: without it, SSO is just one more option nobody is forced to use.
- Mandatory 2FA, preferably FIDO2, even without SSO.
- Personal API tokens. They carry their owner’s permissions. Inventory them and revoke those belonging to people who have left.
- Build hooks. URLs that trigger a build with no further authentication. Treat them as secrets and keep them out of repositories.
- Headers.
_headersor[[headers]]innetlify.tomlfor CSP, HSTS and the rest (see headers). - Functions. Their variables have the Functions scope; a Builds-scoped variable read at build time and embedded in JavaScript ends up in the browser.
Real cases
Section titled “Real cases”- Keys in the generated bundle. Netlify’s forums collect builds stopped because the scanner found in
dist/assets/*.jsthe value of variables such asVITE_SUPABASE_KEYor aSPOTIFY_CLIENT_SECRET. With aVITE_,NEXT_PUBLIC_or similar prefix, the framework embeds the variable in client code on purpose. If the value is a secret, the scanner is right to stop the build. - Secret scanning versus false positives. There are also threads from users who turn off scanning entirely because of false positives. That is exactly the setting to look for during the audit.
Checklist
Section titled “Checklist”- Sensitive variables marked as Contains secret values, with minimal scope and context
- No secret variable with a public framework prefix (
VITE_,NEXT_PUBLIC_,PUBLIC_…) -
SECRETS_SCAN_ENABLED,SECRETS_SCAN_SMART_DETECTION_ENABLED,SECRETS_SCAN_OMIT_KEYSandSECRETS_SCAN_OMIT_PATHSreviewed and justified - Own secret scanner in the repository, not relying only on Netlify’s
- Deploy Previews and branch deploys protected (password or team login)
- Strict-mode SSO and mandatory 2FA for the team; members reviewed
- Personal API tokens and build hooks inventoried; unneeded ones revoked
- Security headers defined in
_headersornetlify.toml