netlify: document deploy-preview security for forked pull requests#2166
netlify: document deploy-preview security for forked pull requests#2166wallrj-cyberark wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Deploy Preview for cert-manager ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
fd4c1f1 to
4870129
Compare
There was a problem hiding this comment.
Pull request overview
Documents the security posture around Netlify deploy previews for forked pull requests, clarifying that untrusted fork code can run on Netlify build infrastructure and that deploy-preview (and global build) environments must only contain public values.
Changes:
- Adds an in-file security note explaining why secrets must not be placed in deploy-preview or global build environments.
- Introduces an explicit
[context.deploy-preview.environment]block to make the deploy-preview environment scope visible/auditable.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
A security review noted that Netlify builds deploy previews for pull requests from public forks automatically, which runs contributor code (next.config.js, package.json scripts and bundled JavaScript) on Netlify's build infrastructure before any maintainer review (CWE-829). The site is already configured so those builds only ever receive public values: the sensitive-variable policy withholds sensitive variables from untrusted deploys, and no secret variable is scoped to the deploy-preview context. This records that posture in netlify.toml and adds an explicit [context.deploy-preview.environment] block, so future changes do not inadvertently expose secrets to fork previews. Signed-off-by: Richard Wall <richard.wall@cyberark.com>
4870129 to
48707fe
Compare
Motivation
A security review flagged that Netlify builds deploy previews for pull requests from public forks automatically (CWE-829):
next buildruns the fork'snext.config.js,package.jsonscripts and bundled JavaScript on Netlify's build infrastructure before any maintainer reviews the diff. Because a fork pull request controls the whole checkout — includingnetlify.toml— no configuration committed here can block that build on its own.What this changes
This makes no change to build behaviour. It records, in source, the security posture that already protects the site, and guards against a future regression:
netlify.tomlexplaining that fork deploy previews run untrusted code and must therefore only ever receive public values.[context.deploy-preview.environment]block and a note asking contributors not to add secrets to it or to[build.environment]. Secrets belong in[context.production.environment]or a production-scoped Netlify UI variable, so fork previews never receive them.The protection itself lives in the site's Netlify settings, which were verified as part of this work:
NEXT_PUBLIC_*,NODE_VERSION,NETLIFY_NEXT_PLUGIN_SKIP).Testing
netlify.tomlparses cleanly (validated with a TOML parser).[context.deploy-preview.environment]block.