Skip to content

Publish only from release, and stop reshaping secrets in CI - #3090

Merged
nedtwigg merged 6 commits into
mainfrom
fix/mask-publishing-secrets
Sep 17, 2026
Merged

nedtwigg merged 6 commits into
mainfrom
fix/mask-publishing-secrets

Conversation

@nedtwigg

Copy link
Copy Markdown
Member

Follow-up to the credential exposure described in #3089.

What changed

  • Secrets are no longer reshaped in CI. configure_publishing_secrets.py decoded
    NEXUS_PASS64/GPG_KEY64 and wrote the plaintext to $GITHUB_ENV, which the runner prints in
    the env: header of every later step. GitHub only masks the value it was given, so the decoded
    values were printed in the clear. The script is deleted; each secret is now stored in the exact
    form the build consumes and passed straight to Gradle.
  • Publishing happens only from release. The snapshot publish job is removed from ci.yml
    entirely, and the credentials live in the maven-central environment, whose branch policy allows
    only release.
  • New signing subkey 0xFA5C18CFB74EC7C6, replacing 0x4272C851, whose encrypted copy was
    exposed. The old subkey is not revoked, so existing signatures remain valid.
  • Least-privilege CI tokens. contents: read by default, with checks: write only on the jobs
    that post JUnit results.
  • renovate-changelog.yml injection fixed. github.head_ref and github.base_ref now arrive
    through env vars instead of being spliced into shell commands.
  • CODEOWNERS on the paths that can move secrets or change what ships.

Already done outside this PR

  • The maven-central environment exists, restricted to release, and holds GPG_KEY,
    GPG_PASSPHRASE, NEXUS_USER and NEXUS_PASS.
  • The base64 org secrets are deleted, and the exposed Sonatype token is revoked.
  • The new public subkey is published on keys.openpgp.org and keyserver.ubuntu.com.

After merging

  1. Flip the default token permissions, which cannot happen before this merges or the JUnit
    reporter loses checks: write:
    gh api -X PUT repos/diffplug/spotless/actions/permissions/workflow \
      -f default_workflow_permissions=read -F can_approve_pull_request_reviews=false
    
  2. Release from release to exercise the new signing key.

🤖 Generated with Claude Code

nedtwigg and others added 6 commits September 17, 2026 11:38
configure_publishing_secrets.py base64-decoded NEXUS_PASS64 and GPG_KEY64
and wrote the plaintext to $GITHUB_ENV. GitHub masks the value of a secret
as it was given, so a decoded value is a string it has never seen, and the
runner prints $GITHUB_ENV variables in the env: header of every later step.
That put the Maven Central password and the armored signing subkey into
public logs.

Drop the script and hand each secret straight to Gradle under the name the
publishing plugin reads, so nothing is ever decoded in a workflow step and
every value stays masked. This needs the plaintext secrets NEXUS_PASS and
GPG_KEY; the base64 variants stay for the other diffplug repos, which
decode them inside Gradle.

Publishing also goes back to --no-configuration-cache, to keep the signing
key out of the configuration cache.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The publishing secrets are now reachable only from the maven-central
environment, whose deployment branch policy allows main and release only,
so a push to any other branch can no longer read them.

GITHUB_TOKEN drops to contents:read by default; the five test jobs opt
back into checks:write for the JUnit reporter, and changelog-print and
scheduled-cleanup declare read. Flip the repo's default workflow
permissions to read-only once this merges.

renovate-changelog.yml took github.head_ref and github.base_ref straight
into shell commands. A branch name is attacker-controlled text, so it
moves to env vars. The publish job was not exploitable (checkout of a
fork branch fails first), but the pattern shouldn't stay.

CODEOWNERS covers the paths that can move secrets or change what ships.
It only bites once branch protection requires approvals and code owner
review.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Snapshot publishing on main is gone: the job is removed from ci.yml, so
no workflow outside a release can touch publishing credentials. The
maven-central environment's branch policy now allows only `release`,
which only nedtwigg can push to, so the secrets are unreachable from
main, from any topic branch, and from any fork.

CONTRIBUTING.md no longer advertises snapshots; publishToMavenLocal is
the way to test an unreleased change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Replaces 0x4272C851, whose encrypted copy was exposed in public CI logs.
The old subkey is not revoked, so existing signatures stay valid.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A single code owner cannot approve their own pull request, which would
block every change to these paths.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@nedtwigg
nedtwigg merged commit 13e2296 into main Sep 17, 2026
31 checks passed
@nedtwigg
nedtwigg deleted the fix/mask-publishing-secrets branch September 17, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant