Safeguard
Security Guides•

Do fork pull requests get your repository secrets?

On GitHub, a fork pull request workflow gets no repository secrets except a read-only GITHUB_TOKEN. What that means and where it can go wrong.

Safeguard Security Team
4 min read

By default, no. On GitHub, when a workflow is triggered from a forked repository, secrets are not passed to the runner, with the exception of GITHUB_TOKEN, and that token has read-only permissions in pull requests from forks. The exceptions are triggers you choose to configure, such as pull_request_target.

The short version in a table

TriggerRuns workflow code fromSecrets availableToken permissions
pull_request from a forkThe pull request merge refNo (GITHUB_TOKEN alone)Read-only
pull_request_targetThe base branchYesCan be write
workflow_runThe default branchYesCan be write

The first row is the safe default. The second and third rows are privileged triggers, and GitHub's own security guidance warns that using them together with a checkout of untrusted pull request code exposes the repository to compromise.

Why the default is safe

A fork pull request is code from someone you may not know. If that code could read your deploy key, a one-line change to a test script would send it to an attacker. GitHub removes the secrets from the runner for fork pull requests so that a malicious change cannot read them. A first-time contributor's workflows may also wait for a maintainer to approve them before anything runs.

Two related facts help here. Workflows do not run in a forked repository until its owner enables Actions. And Dependabot pull requests are treated as though they come from a fork, so they get the same restrictions.

Where teams lose the protection

The default breaks when someone wants a fork pull request to do something that needs a secret. Typical examples are posting a comment, uploading a scan result to a service, or running an integration test against a cloud account.

The shortcut is to switch the trigger to pull_request_target and check out the pull request head so the tests still run. That combination runs attacker-controlled code with your secrets in reach. Do not do it. The safer options are:

  1. Run tests on pull_request with no secrets, and accept that integration tests needing credentials run after merge or after a maintainer approval.
  2. Split the work into two workflows. The first builds and tests with no secrets and uploads results as an artifact. The second, triggered by workflow_run, reads the results alone and does the privileged step. Treat the artifact as untrusted data and never execute it.
  3. Put credentials in an environment with required reviewers, so a person approves before a job can read them.

A quick audit you can do today

  • List every workflow that uses pull_request_target or workflow_run.
  • For each, search for a checkout step that names the pull request head ref or SHA. If it exists, treat it as a finding.
  • Check that the default GITHUB_TOKEN permission is read-only for repository contents, and raise it per job.
  • Look at what secrets exist at repository and organization level, and remove any that no workflow needs.

Try it yourself

Click through it at your own pace, or open it full screen.

Watch how a gate runs on the pull request itself and decides before merge, with no credentials passed to the contributor's code.

Where Safeguard fits

Safeguard applies policies and gates to pull requests, so a dependency or finding policy is decided on the change itself. You can also run a free scan of a project to see what a gate would flag.

Quick check

Does a fork pull request ever get secrets by default?

No. Apart from GITHUB_TOKEN, which is read-only for fork pull requests, secrets are not passed to the runner.

Is pull_request_target always unsafe?

No. It is safe when the workflow does not check out or run untrusted pull request code. The risk comes from combining it with that checkout.

Do Dependabot pull requests get repository secrets?

They are treated like fork pull requests. GitHub Actions secrets are not available, and Dependabot secrets are used instead.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.