Skip to content

netlify: document deploy-preview security for forked pull requests#2166

Open
wallrj-cyberark wants to merge 1 commit into
cert-manager:masterfrom
wallrj-cyberark:netlify-fork-deploy-preview-security
Open

netlify: document deploy-preview security for forked pull requests#2166
wallrj-cyberark wants to merge 1 commit into
cert-manager:masterfrom
wallrj-cyberark:netlify-fork-deploy-preview-security

Conversation

@wallrj-cyberark

@wallrj-cyberark wallrj-cyberark commented Jun 19, 2026

Copy link
Copy Markdown
Member

Motivation

A security review flagged that Netlify builds deploy previews for pull requests from public forks automatically (CWE-829): next build runs the fork's next.config.js, package.json scripts and bundled JavaScript on Netlify's build infrastructure before any maintainer reviews the diff. Because a fork pull request controls the whole checkout — including netlify.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:

  • A comment in netlify.toml explaining that fork deploy previews run untrusted code and must therefore only ever receive public values.
  • An explicit (intentionally empty) [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.
  • A link to the relevant Netlify documentation (sensitive-variable policy).

The protection itself lives in the site's Netlify settings, which were verified as part of this work:

  • The sensitive-variable policy withholds sensitive variables from untrusted (fork) deploys.
  • No secret variable is scoped to the deploy-preview context; the only variables present are public (NEXT_PUBLIC_*, NODE_VERSION, NETLIFY_NEXT_PLUGIN_SKIP).
  • The fork build cache is isolated from production.

Testing

  • netlify.toml parses cleanly (validated with a TOML parser).
  • The documentation link was checked and resolves.
  • No functional change to the build; the deploy preview generated for this pull request exercises the new [context.deploy-preview.environment] block.

@cert-manager-prow cert-manager-prow Bot added the dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. label Jun 19, 2026
@cert-manager-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign joshvanl for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cert-manager-prow cert-manager-prow Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 19, 2026
@netlify

netlify Bot commented Jun 19, 2026

Copy link
Copy Markdown

Deploy Preview for cert-manager ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 48707fe
🔍 Latest deploy log https://app.netlify.com/projects/cert-manager/deploys/6a3518927f8089000893dffb
😎 Deploy Preview https://deploy-preview-2166--cert-manager.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@wallrj-cyberark wallrj-cyberark force-pushed the netlify-fork-deploy-preview-security branch from fd4c1f1 to 4870129 Compare June 19, 2026 10:04
@cert-manager-prow cert-manager-prow Bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 19, 2026
@wallrj-cyberark wallrj-cyberark requested a review from Copilot June 19, 2026 10:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread netlify.toml
Comment thread netlify.toml
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>
@wallrj-cyberark wallrj-cyberark force-pushed the netlify-fork-deploy-preview-security branch from 4870129 to 48707fe Compare June 19, 2026 10:23
@cert-manager-prow cert-manager-prow Bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants