fix(security): restrict release workflow to same-repo PRs and block env overrides for internal fields by 20000419 · Pull Request #4977 · supabase/cli
What kind of change does this PR introduce?
Bug fix (security)
What is the current behavior?
-
The
fast-forwardworkflow (triggered onpull_request_reviewapproval) fast-forwardsmainto the PR head SHA without checking if the head repository matches the base repository, then calls the release workflow withsecrets: inherit.
→ An approved PR from a fork could execute attacker-controlled code with release tokens (GitHub App, Slack, etc.). -
viper.ExperimentalBindStruct()+AutomaticEnv()inloadFromEnv()binds all struct fields (including internaltoml:"-"fields likeDb.Image,Hostname) toSUPABASE_*environment variables.
→ A malicious.envfile in a repository could override internal Docker image/host settings, leading to arbitrary container execution when runningsupabase start.
What is the new behavior?
-
Added explicit check
github.event.pull_request.head.repo.full_name == github.repositoryinrelease.yml→ release workflow only runs for same-repo PRs. -
Replaced
ExperimentalBindStruct()with a custombindUserConfigEnv()that:- Skips fields tagged
toml:"-"orjson:"-" - Only binds user-configurable fields
- Added test
TestEnvOverridesSkipInternalFields
- Skips fields tagged
Additional context
This PR fixes two High-severity issues discovered during a security review:
- Workflow secret exposure via fast-forward on PR review
- Internal config override via repo-controlled
.envfiles
Both changes are minimal, backward-compatible, and include tests.
Closes the corresponding internal security findings.