Skip to content

ci: run jobs that read secrets in environments - #2019

Merged
kanat merged 5 commits into
acceleratefrom
ci/secrets-in-environments
Nov 15, 2026
Merged

kanat merged 5 commits into
acceleratefrom
ci/secrets-in-environments

Conversation

@kanat

@kanat kanat commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Why

Repo-level secrets are readable by any workflow pushed to any branch. Environments with deployment-branch rules limit them to the branches that need them. This PR makes every job that reads secrets name an environment, so the secrets can move into environments in repo settings. The move is an admin step after merge (below).

The PR alone changes nothing for a push: an environment that is not configured yet has no rules and still sees the repo-level secrets. The one change is on pull requests: integration.yml no longer gives MEM0_API_KEY to a pull request's code, and the mem0 suites skip there, as they already did for forks.

How it works

job names environment E
├─ E is ''                -> no environment, no deployment (probed, below)
├─ E not created yet      -> created with no rules; repo secrets visible
└─ E has branch rules
   ├─ ref matches a rule  -> job gets E's secrets
   └─ ref does not match  -> job is refused before it reaches a runner

push to any branch  -> workflow without E       -> no secrets
push to accelerate  -> ci.yml -> run_tests.yml  -> no environment, no secrets
push to accelerate  -> integration.yml mem0     -> E = integration, MEM0_API_KEY
schedule / dispatch -> daily.yml -> run_tests   -> E = integration, provider keys
pull_request        -> integration.yml mem0     -> E = '', no MEM0_API_KEY
Workflow / job Environment When
run_tests.yml test inputs.environment (new, default '') caller decides
daily.yml -> run_tests.yml integration schedule, dispatch
release.yml integration -> run_tests.yml integration release v*
ci.yml unit -> run_tests.yml none (unchanged) push, PR
integration.yml mem0 matrix entries integration on push, '' on PR push, PR
publish-sdk-kotlin.yml publish, upload release push only (existing if)
release-sdk-js.yml release (npm, OIDC) registry-publish (new) dispatch on accelerate (existing if)
release-sdk-dotnet.yml release (NuGet, OIDC) registry-publish (new) dispatch on accelerate (existing if)
release.yml build-core pypi (unchanged) release v*

The environment goes on the job inside the reusable workflow: the caller's job cannot set one, and secrets: inherit still has to pass the secret (GitHub docs, reuse workflows).

Validation

  • Empty environment name. The docs allow an expression for environment / environment.name with the github, inputs, matrix (and other) contexts, and say nothing about an empty value (workflow syntax). A throwaway branch (deleted since) ran seven jobs: literal environment: '', environment: {name: ''}, an expression that yields '', a matrix expression that yields '' for one entry, and a reusable workflow's environment: ${{ inputs.environment }} with the default and with ''. All seven succeeded, the deployments API showed no deployment for that commit, and no environment was created. A job in pypi does create one (its last deployment has ref v0.6.6), so the check can tell. actionlint refuses the literal '' forms (string should not be empty), so this PR uses only expressions.
  • This PR's CI runs run_tests.yml from ci.yml with the empty default, and integration.yml on pull_request with the expression yielding ''.
  • actionlint on the seven changed files: clean, except one shellcheck warning (SC2046) in release-sdk-js.yml that the base already has.
  • No other workflow publishes. client-sdks.yml runs flutter pub publish --dry-run only, with no id-token and no secret. release.yml build-core (PyPI) is the only other job with id-token: write.

After merge (repo admin)

Do the steps in order. Steps 1-10 come before any secret moves, and no step widens access compared with today.

  1. Merge the main PR, ci: run the jobs that read provider keys in an environment (main) #2020, once its CI is green. The nightly schedule and v* releases run from main: daily.yml resolves run_tests.yml in main's commit, and Python releases are tagged on main. main has diverged for these files, so ci: run the jobs that read provider keys in an environment (main) #2020 holds the same three edits by hand: the environment input and environment: ${{ inputs.environment }} on the test job of run_tests.yml, and environment: integration in daily.yml and in release.yml's integration job. Without it the nightly and the release integration run lose their keys after step 11. integration.yml and publish-sdk-kotlin.yml are not on main.

  2. Workflow token settings. Under Settings -> Actions -> General -> Workflow permissions, at repo level and at org level:

    • turn off "Allow GitHub Actions to create and approve pull requests". When it is on, a workflow pushed to any branch can ask for pull-requests: write and approve a pull request as github-actions[bot], which meets the approval rule of step 3 (docs).
    • set the default workflow permissions to read. Every workflow here already sets permissions: at the top or on every job, so none of them changes.
  3. Add a branch ruleset on accelerate, with the same options on main's ruleset. The deployment-branch rules below only hold as far as the branches they name are protected, and the nightly runs accelerate's code in integration.

    • restrict deletions; block force pushes;
    • require a pull request before merging, with 1 approval;
    • turn on "Dismiss stale pull request approvals when new commits are pushed" and "Require approval of the most recent reviewable push", so a commit pushed onto someone else's approved pull request needs a new approval;
    • bypass list: repository and organization admins only, on main too.
  4. Add a tag ruleset on v*: limit who may create, update and delete those tags. release.yml runs on a release whose GITHUB_REF is refs/tags/vX.Y.Z, so integration and pypi accept v* tags (steps 7 and 8), and this ruleset is what keeps the path closed.

  5. Create or configure environment release, for the Kotlin jobs only:

    • deployment branches and tags: Branch accelerate, Branch release-kotlin-*-SNAPSHOT;
    • required reviewers: a team of at least two people, with "Prevent self-review" on, so the person who started a run cannot approve it. With one member the rule would block every run.

    Anyone who can push could create release-kotlin-x-SNAPSHOT with an edited publish-sdk-kotlin.yml (its push trigger includes that file) and enter release. The required reviewers close that path with one setting on the environment that guards the secrets, and hold every Kotlin publish on a merge to accelerate until a reviewer approves the run.

  6. Create environment registry-publish, for the npm and NuGet jobs: Branch accelerate only, the same required reviewers as release with "Prevent self-review" on. A separate environment keeps these jobs out of the release-kotlin-*-SNAPSHOT branches that release admits, because neither registry checks the ref.

  7. Create or configure environment integration (the first push of a mem0 job after merge creates it with no rules): Branch main, Branch accelerate, Tag v*. Enter v* as a Tag rule: as a Branch rule it would admit any pushed branch named v-x.

  8. Configure environment pypi: Tag v* only. Then check on PyPI that the trusted publisher of each published package names environment pypi. If it names none, a job in any release.yml on any branch can publish.

  9. Make the npm and NuGet trusted publishers require environment registry-publish: on npm, the trusted publisher of @stream-io/stream-agents for release-sdk-js.yml; on nuget.org, the trusted publishing policy for release-sdk-dotnet.yml. Neither registry checks the ref (npm, NuGet), so the environment is what keeps a job on another branch from publishing. A dry run now also waits for a reviewer.

  10. An org admin removes Vision-Agents from the access list of every organization secret that no workflow here reads. Check with gh api repos/GetStream/Vision-Agents/actions/organization-secrets. The two STREAM_REPO_* secrets below are read; an environment does not limit an organization secret, so keep them on the access list only until step 11 is done, then remove this repo from their lists too.

  11. Move each secret from repo level into its environment, then delete the repo copy:

  • integration: ANTHROPIC_API_KEY, ASSEMBLYAI_API_KEY, AWS_ACCESS_KEY_ID, AWS_BEARER_TOKEN_BEDROCK, AWS_BEDROCK_API_KEY, AWS_SECRET_ACCESS_KEY, CARTESIA_API_KEY, DEEPGRAM_API_KEY, ELEVENLABS_API_KEY, FAL_KEY, FISH_API_KEY, GOOGLE_API_KEY, HF_TOKEN, INWORLD_API_KEY, MISTRAL_API_KEY, NVIDIA_API_KEY, OPENAI_API_KEY, OPENAI_MODEL, OPENROUTER_API_KEY, SARVAM_API_KEY, STREAM_API_KEY, STREAM_API_SECRET, TURBOPUFFER_API_KEY, TWELVELABS_API_KEY, XAI_API_KEY, SLACK_WEBHOOK_URL, MEM0_API_KEY. (TELNYX_API_KEY is read by run_tests.yml but is not set at repo level.)
  • release: SIGNING_KEY, SIGNING_KEY_ID, SIGNING_PASSWORD, STREAM_REPO_ENDPOINT, STREAM_REPO_BUCKET.
  • STREAM_REPO_ACCESS_KEY_ID and STREAM_REPO_SECRET_ACCESS_KEY are organization secrets: put them in release, then remove this repo from the organization secrets' access lists. Organization secrets cannot be read back, so get the values from the owner of that credential, or create a new key.

Once the integration rules exist, a pull-request job that names the environment is refused (ref refs/pull/N/merge) and CI goes red, so a dropped github.event_name == 'push' && guard is caught.

After the move, Run workflow on daily.yml from a branch other than main or accelerate is refused by the integration rules, instead of testing that branch with the keys.

🤖 Generated with Claude Code

Repo-level secrets are readable by any workflow pushed to any branch. Jobs
that need them now name an environment, so that once the secrets live in
environments with deployment-branch rules, only the branches that need them
get them.

- run_tests.yml takes an `environment` input for its test job; daily.yml
  and release.yml pass `integration`, ci.yml passes none.
- integration.yml enters `integration` for the mem0 jobs on push only; a
  pull request gets no MEM0_API_KEY and its mem0 suites skip.
- publish-sdk-kotlin.yml's publish and upload jobs use `release`.

An environment not yet configured has no rules and sees repo secrets, so
nothing changes until the secrets move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@kanat kanat left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed #2019 at 602275e merged onto the current accelerate (03994a6, clean). CI: 53 pass, 4 skipped (Kotlin publish jobs on a PR, CodeRabbit). actionlint on the five files: clean.

Checked and sound:

  • At head, every secrets.* read in .github/ is in a job that names an environment: run_tests.yml:95-120,164 (test, inputs.environment), integration.yml:162-163 (mem0 entries), publish-sdk-kotlin.yml:131-133,172-175 (publish, upload, release). ci.yml:52-55 calls run_tests.yml with no secrets:, so its test job gets none.
  • integration.yml:41: && binds tighter than ||, so the value is integration only for a push of an entry with mem0: true, and '' for any pull request and any entry without mem0. The PR run of integration (internal/memory/mem0) at this head shows MEM0_API_KEY and RUN_MEM0_SUITE empty, and the deployments API lists no deployment for this sha.
  • The environment on the job inside the reusable workflow applies to the called job, and its environment secrets take precedence over the inherited ones.
  • Trigger refs against the planned rules: the schedule runs with ref main, a v* release with refs/tags/v*, a Kotlin snapshot with release-kotlin-X.Y.Z-SNAPSHOT, a Kotlin release with accelerate (merge push). All match. A workflow_dispatch of daily.yml from another branch is refused, as the body says.
  • The secret lists in step 3 and 4 cover every repo-level secret name.

[Should fix] R1.1 The main edits are a precondition for step 3, but they sit outside the numbered steps and no PR into main exists. The schedule runs main's daily.yml (daily.yml:11-18@8e2d3a199), which calls main's run_tests.yml, and v* releases are tagged on main. These jobs read every provider key and name no environment, so after step 3 the nightly and the release integration run lose their keys. Fix: open the main PR now and make it a numbered step before step 3, with its link.

[Should fix] R1.2 The deployment rules only hold as far as the refs they name are protected. The admin list should also have, before step 3: (a) a ruleset on accelerate that requires a pull request and blocks force pushes (the repo's rulesets target the default branch only); (b) a ruleset that limits who may create release-kotlin-* branches, or required reviewers on release. Otherwise anyone who can push can create release-kotlin-x-SNAPSHOT with an edited publish-sdk-kotlin.yml (its push trigger includes that file) and enter release. (c) The v* tag ruleset, which the body mentions only as an aside in step 1, should be a numbered step.

[Should fix] R1.3 Step 4 misses an organization secret: one more is shared with this repo, and no workflow at head reads it. Add it to step 4: remove this repo from its access list.

[Should fix] R1.4 The PR body:

  • In the diagram, push to accelerate -> run_tests (integration) -> provider keys is wrong. A push to accelerate calls run_tests.yml only from ci.yml, with no environment and no secrets. The jobs that enter integration on a push are the mem0 entries of integration.yml.
  • Steps 1-2 say "Create". The first push of a mem0 job after merge creates integration with no rules, so write "create or configure".
  • In step 3, remove "(with new values as they are rotated)".

[Should fix] R1.5 daily.yml:20-21 (inline).

[Nit] R1.6 Step 2 lets main into release, but no workflow on main reads the Kotlin secrets. Remove main from the rule.

[Nit] R1.7 Nothing checks the new environment expressions: dropping github.event_name == 'push' && at integration.yml:41, or turning && into ||, still passes CI. Only the runs listed in the body show that the expressions behave. Ticket.

Not verified: the positive path, a push that runs a mem0 job inside integration. The first push to accelerate after merge will show it as a deployment to integration.

Verdict: request changes, for R1.1-R1.5 (PR body and one comment; the workflow logic is sound).

Comment thread .github/workflows/daily.yml Outdated
# The provider keys and the Slack webhook live in this environment.
environment: integration
# A schedule only fires on the default branch, so it tests accelerate, where the
# work happens; Run workflow on any other branch tests that branch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[Should fix] R1.5 "Run workflow on any other branch tests that branch" stops being true once step 1 sets rules on integration: a dispatch from a branch outside main/accelerate is refused before it reaches a runner. The PR body says so itself. Change the comment to say that only main and accelerate can run it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 318ce01: the comment now says only main and accelerate can run this workflow, and that the environment's branch rules refuse Run workflow on any other branch. The main PR (#2020) carries the same wording.

@kanat kanat left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Delta review of 318ce01 (was 602275e). The code delta is one comment in daily.yml; the rest is the PR body. CI at this head: 53 pass, 4 skipped.

Prior findings

  • R1.1 fixed. #2020 is open on main, it is step 1 with its link, and it holds the edits the body lists (the environment input and environment: ${{ inputs.environment }} in run_tests.yml, environment: integration in daily.yml and release.yml). Its CI is green; it is still a draft, so mark it ready before step 1.
  • R1.2 fixed. Steps 2-4 are the accelerate ruleset, required reviewers on release and the v* tag ruleset. All three come before the environments (5-6) and before any secret moves (8).
  • R1.3 fixed. Step 7 covers the unused organization secret and keeps the two STREAM_REPO_* ones on the list until step 8. gh api .../actions/organization-secrets shows three names for this repo: the two read by publish-sdk-kotlin.yml:170-171 and one that no workflow reads.
  • R1.4 fixed. The diagram no longer has the wrong accelerate -> run_tests line, step 5 and 6 say "create or configure", and the rotation wording is gone.
  • R1.5 fixed, with one inaccuracy: see N1.
  • R1.6 fixed. release is accelerate and release-kotlin-*-SNAPSHOT.
  • R1.7 left as a follow-up, as agreed ("A ticket will cover a check").

Order of the admin steps is safe: #2020 (1), branch and tag protection (2-4), environments with their rules (5-6), org access (7), secrets (8). Step 7 keeps STREAM_REPO_* until step 8, so the Kotlin publish keeps working.

Secret lists. The repo has 32 secrets. Step 8's integration (27) plus release (5) lists equal them exactly (diffed); the extra TELNYX_API_KEY is the parenthetical, correctly marked as not set at repo level. Every secrets.* name read in .github/workflows is in one of the lists or in the org pair.

Public repo. The body has secret names only (no values, ids, or account details) and nothing about incidents. Safe.

[Nit] N1 daily.yml:21-22 (and the same sentence in #2020): "Only main and accelerate can run this workflow" is not quite what step 5 sets. integration also accepts tag v*, and Run workflow can pick a tag. Say "only main, accelerate and v* tags", or drop the "only".

[Nit] N2 Step 3/6: required reviewers on release also gate the Kotlin publish that runs on every merge push to accelerate that touches it, not only the snapshot branches. If that is the intent, one clause in the body saying so helps the admin.

Not verified: the positive path (a mem0 push job entering integration) and the environments themselves, which are admin steps after merge.

Verdict: GO. No blockers; N1 and N2 are optional.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kanat
kanat marked this pull request as ready for review November 14, 2026 01:57

@kanat kanat left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Security review (attacker with push access, not admin) of e54f585 and its pair #2020 (96236d5), with every admin step in the body applied as written. CI on the head: 52 pass, 4 skipped, 1 pending (integration (internal/agent), which does not touch these files). actionlint: clean. The earlier reviews' findings are not repeated here.

Closed by the plan. An environment rule is matched against the run's GITHUB_REF (docs):

  • A workflow pushed to a new branch, workflow_dispatch from that branch, and a call to run_tests.yml with environment: integration from it (local or @accelerate) all run on refs/heads/<branch> and are refused.
  • pull_request runs on refs/pull/N/merge and is refused. pull_request_target runs the base branch's file: on main/accelerate that is only labeler.yml, which checks out nothing and reads no secret. Into the attacker's own branch, it runs on that branch and is refused.
  • workflow_run, repository_dispatch, issue_comment and schedule run only the default branch's files.
  • A tag push outside v* is refused. A v* tag, or a release that would create one, is stopped by step 4's create/update/delete rule.
  • Caches: a PR run writes only its merge-ref scope, so it cannot plant a cache that a push job restores (docs).
  • uv.lock has hashes and only the pypi.org index, and installs use --frozen.
  • The diffs add no environment name an attacker can set: inputs.environment comes only from caller files in the same ref, and integration.yml:41 reads only event_name and the static matrix. No step widens access compared with today.

What is still open is the merge gate. The nightly runs main's daily.yml, which runs run_tests.yml in integration on accelerate's code (daily.yml:23). So whoever can land code on accelerate gets every integration key the next night.

[Should fix] R1.1 Step 2 (accelerate ruleset) says "pull request required" but sets no approval count, and a ruleset allows 0. With 0, the attacker opens a PR and merges it. Fix: in step 2, require 1 approval. Also turn on "Dismiss stale pull request approvals when new commits are pushed" and "Require approval of the most recent reviewable push": without them, a pusher can push a commit onto someone else's approved PR and merge it. Also restrict deletions, and keep the bypass list to admins. Check that main's ruleset has the same options, because daily.yml and release.yml run from main.

[Should fix] R1.2 Add a step before step 8: under Settings → Actions → General → Workflow permissions, make sure "Allow GitHub Actions to create and approve pull requests" is off, at repo and org level. When it is on, a workflow pushed to any branch can ask for pull-requests: write (a permissions: key overrides the default, docs). It can then approve the attacker's own PR as github-actions[bot], which meets a 1-approval rule (changelog). In the same step, set the default token permissions to read.

[Should fix] R1.3 Steps 3 and 6: also turn on "Prevent self-review" on release, and name a small reviewer group. Without that setting, a reviewer who starts a run on release-kotlin-x-SNAPSHOT can approve that run.

[Should fix] R1.4 Step 9 is worded as a remark, but PyPI is an artifact path just like release. A workflow file named release.yml on any branch, with environment: pypi and id-token: write, matches the PyPI trusted publisher, and pypi has no deployment rule. Make step 9 an action: on pypi, allow only tag v*. Also check that the PyPI trusted publisher names environment pypi. If it names none, any job in a release.yml can publish.

[Nit] R1.5 Steps 5, 6 and 9: give the ref type for each rule. main, accelerate and release-kotlin-*-SNAPSHOT are Branch rules, and v* is a Tag rule. If v* is entered as a Branch rule, any pusher can create a branch v-x and enter integration.

[Nit] R1.6 Step 8, STREAM_REPO_*: organization secrets cannot be read back. Say that the values come from the owner of that credential, or from a new key.

Separate work (tickets, not in this PR):

  • [Should fix] T1 release-sdk-js.yml:17-24 (npm) and release-sdk-dotnet.yml:31-36 (NuGet) publish through OIDC from jobs with no environment. Their if: github.ref == 'refs/heads/accelerate' lives in the file that a branch can edit. npm and NuGet policies match repo + workflow filename + an optional environment, and no ref (npm, NuGet). Fix: give each job an environment limited to accelerate, with reviewers, then set that environment on the registry policy.
  • [Nit] T2 main-side hardening that accelerate already has (see #2020).

Org pair (STREAM_REPO_*): steps 7-8 already move it into release and remove repo access. GITHUB_TOKEN in the env jobs here: contents: read, except Kotlin upload (contents: write, inside release). No id-token outside build-core, and no cloud federation.

Verdict: NO-GO, for R1.1-R1.4. All four are PR-body edits to the admin steps. The workflow changes are sound.

Their trusted publishers can then require that environment, so a job outside it
cannot publish.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kanat

kanat commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Replies to the security review (#2019 (review)). Its R1.1-R1.6, T1 and T2 are tracked as S1.1-S1.8.

  • S1.1 (R1.1) Fixed in the body, step 3: accelerate ruleset with 1 approval, "Dismiss stale pull request approvals", "Require approval of the most recent reviewable push", restricted deletions, no force push, bypass for admins only. The step sets the same options on main's ruleset.
  • S1.2 (R1.2) Fixed in the body, new step 2, before any secret moves: "Allow GitHub Actions to create and approve pull requests" off at repo and org level, and default workflow permissions set to read. Every workflow already sets permissions: at the top or on every job, so none of them changes.
  • S1.3 (R1.3) Fixed in the body, step 6: release reviewers are a small team, with "Prevent self-review" on.
  • S1.4 (R1.4) Fixed in the body, step 8, now an action: pypi allows Tag v* only, and the step checks that the PyPI trusted publisher names environment pypi.
  • S1.5 (R1.5) Fixed in the body, steps 6-8: every rule gives its type (Branch main, Branch accelerate, Branch release-kotlin-*-SNAPSHOT, Tag v*). Step 7 says why v* has to be a Tag rule.
  • S1.6 (R1.6) Fixed in the body, step 11: organization secrets cannot be read back, so the STREAM_REPO_* values come from the owner of that credential or from a new key.
  • S1.7 (T1) Fixed in b4f7279: the release jobs of release-sdk-js.yml (npm) and release-sdk-dotnet.yml (NuGet) now run in environment release, and keep their if: guards. Body step 9 makes both registries' trusted publishers require that environment, and the table lists both jobs. Reverting the commit puts both OIDC jobs back outside any environment, where a publisher that requires release refuses them. No other workflow publishes: client-sdks.yml runs flutter pub publish --dry-run only, with no id-token and no secret, and build-core is the only other job with id-token: write. actionlint: clean. The one shellcheck SC2046 warning in release-sdk-js.yml is already on the base.
  • S1.8 (T2) Fixed in ci: run the jobs that read provider keys in an environment (main) #2020 (bc20447).

Step order, checked again: steps 1-9 only narrow access, and every secret stays where it is today until step 11 moves it.

@kanat kanat left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Delta security review of b4f7279 (was e54f585). Verdict: NO-GO until the one Should fix below is in. Everything else is fixed.

Prior findings

  • S1.1 (ruleset: 1 approval, dismiss stale, approval of the latest push, restrict deletions, admin-only bypass, same on main): fixed, step 3.
  • S1.2 (Actions may not approve PRs; default token read; repo and org): fixed, step 2.
  • S1.3 (Prevent self-review on release, small named team): fixed, step 6.
  • S1.4 (pypi rule Tag v*, publisher check): fixed, now step 8.
  • S1.5 (ref type per rule): fixed, steps 6, 7, 8 name Branch or Tag.
  • S1.6 (org secret values are write-only): fixed, last bullet of step 11.
  • S1.7 (environment: release on the npm and NuGet OIDC jobs): code fixed, the if: github.ref == 'refs/heads/accelerate' guards are kept, the registry-publisher step is step 9. Mutation: reverting b4f7279 puts both OIDC jobs back outside any environment (grep -n "environment:" release-sdk-js.yml release-sdk-dotnet.yml finds nothing). The choice of environment leaves a hole, see N1.

New finding

  • N1, Should fix (release-sdk-js.yml:23, release-sdk-dotnet.yml:36, body step 6/9). release admits Branch release-kotlin-*-SNAPSHOT (it has to, for the Kotlin snapshot publish). The npm and NuGet publishers now trust "environment release" and check no ref, so a pusher can create release-kotlin-x-SNAPSHOT, edit release-sdk-js.yml there (drop the if:) and dispatch it. The only gate left is a reviewer who must notice the branch name. The security review (T1) asked for an environment limited to accelerate. Fix: give these two jobs their own environment (for example release-sdk), deployment branch accelerate only, same reviewers with Prevent self-review, and name that environment in steps 6 and 9. The Kotlin jobs keep release.

Attacker model re-run (one member with push, no admin, 11 steps applied)

  • Own branch or PR naming integration, pypi, release: refused by the ref rules (push and dispatch ref is the branch, PR ref is refs/pull/N/merge). v* tags: closed by step 5.
  • Nightly runs accelerate code in integration: gate is step 3 (1 approval from someone else, stale approvals dismissed, no bot approval after step 2).
  • Registry publish from another branch or file: refused by the registry once step 9 is set, except through N1.
  • (a) Step order: no step widens access. 1 and 2 to 9 only add rules or narrow publishers; secrets move last, in 11. Step 4 holds no action of its own ("step 6"), so an admin can skip it by reading in order; fold it into step 6 (Nit).
  • (b) Yes: release reviewers now hold every Kotlin publish and upload on a merge to accelerate, and every npm and NuGet run. Step 4 and step 9 say so. Add to step 6 that the team needs at least two people, since the person who merged cannot approve the run their merge started (Nit).
  • (c) main's release-sdk-js.yml has no environment. Its job is skipped off accelerate by its if. The npm trusted-publisher page lists "Environment name (optional)" and advises environments for approvals, but does not state the mismatch rule in words (NuGet's page does: the claim is validated if the policy sets it). An env-less token cannot match a publisher that names one, so the fixer's argument holds. Not checked on npm's settings page (not readable here): after step 9, a dry run from a throwaway branch should be refused.
  • (e) "Follow-ups" can be dropped, with this reason: once step 7 is applied, a pull-request job that names integration has GITHUB_REF=refs/pull/N/merge, which no rule admits, so the job is refused and CI goes red. Losing github.event_name == 'push' && at integration.yml:41 is then caught by the environment itself, not by a new check. Replace the section with that sentence.

Checks: git diff e54f585e4 b4f727923 touches only the two workflow files (3 lines each). CI: 53 pass, 4 skipped, none failing. #2020 must merge first (step 1).

Comment thread .github/workflows/release-sdk-js.yml Outdated
runs-on: ubuntu-latest
# The npm trusted publisher accepts only a token minted in this environment. A run enters
# it only from the branches its rules name, and only after a reviewer approves it.
environment: release

@kanat kanat Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

N1 (Should fix): environment release admits release-kotlin-*-SNAPSHOT branches, and npm checks no ref. Use a separate environment limited to accelerate for the npm and NuGet jobs (same for release-sdk-dotnet.yml:36).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9a93133: the npm job now uses environment registry-publish, limited to accelerate, with the same required reviewers. release keeps the Kotlin jobs. The PR body steps 5, 6 and 9 say so.

runs-on: ubuntu-latest
# The NuGet trusted publisher accepts only a token minted in this environment. A run enters
# it only from the branches its rules name, and only after a reviewer approves it.
environment: release

@kanat kanat Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

N1: same as release-sdk-js.yml:23.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9a93133: same, the NuGet job uses registry-publish.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@kanat kanat left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Delta security review of 9a93133 (was b4f7279). Verdict: GO. One body-wording nit remains.

Prior findings

  • S2.1 fixed. release-sdk-js.yml and release-sdk-dotnet.yml now name registry-publish; publish-sdk-kotlin.yml (publish, upload) is the only user of release. The table, steps 5, 6 and 9 agree with the code. Planned rule: Branch accelerate only, same reviewers, Prevent self-review. The jobs also keep if: github.ref == 'refs/heads/accelerate', so a release-kotlin-*-SNAPSHOT run can no longer reach the npm or NuGet token.
  • S2.4 fixed: the reviewer step is folded into step 5, team of at least two.
  • S2.5 fixed: the follow-up line is gone; the last paragraph says CI goes red if a pull-request job names the environment.

Attacker model, final state (org member with push access, not admin; all admin steps applied)

  • Repo and org secrets: repo copies deleted (step 11), unread org secrets removed from the access list (step 10). A branch workflow gets only GITHUB_TOKEN.
  • integration: refused for every branch except main and accelerate (both PR plus approval, stale-approval dismissal, no force push) and for tags other than v* (tag ruleset).
  • pypi: v* tags only; tag creation, update and deletion are limited by step 4, so the attacker cannot create a tag or a GitHub release that starts release.yml.
  • npm and NuGet: both registries ignore the ref, but the OIDC token of a job without the environment lacks the environment claim, so the publishers from step 9 refuse it. A job naming registry-publish from another branch is refused before a runner starts. A pull request run (refs/pull/N/merge) is refused by every rule.
  • Kotlin: the one reachable path is a pushed release-kotlin-*-SNAPSHOT branch with an edited workflow; it stops at the required reviewers, and the author cannot approve their own run. That leaves a reviewer approving without reading the branch. The body names this; nothing more to change.
  • labeler.yml uses pull_request_target but only runs actions/labeler; it checks out no pull-request code.
  • Order: each step narrows or leaves access as today. registry-publish (step 6) exists before the publishers require it (step 9); until step 9 the publishers accept what they accept today. Secrets move last.

Nit

  • Body, "After merge": "Steps 1-9 come before any secret moves" should say 1-10, since step 10 also comes before step 11.

CI: all checks pass; the Kotlin jobs are skipped on a pull request, as designed.

@kanat
kanat requested a review from thesyncim November 15, 2026 00:26
@kanat
kanat merged commit 43849c5 into accelerate Nov 15, 2026
57 checks passed
@kanat
kanat deleted the ci/secrets-in-environments branch November 15, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant