Repository navigation
Description
Summary
High-priority supply-chain hardening is needed for the GitHub Actions to PyPI trust boundary.
A legitimate one-time citry-core==1.4.0 repair demonstrated that a maintainer with repository write access can:
- push a branch containing a modified revision of an already registered publishing workflow;
- manually dispatch that workflow revision because
workflow_dispatchexists on the default branch; - enter the shared
pypienvironment from the branch; and - obtain an ephemeral OIDC credential accepted by PyPI Trusted Publishing.
This did not require a change to main, a new release tag, a stored PyPI token, an environment approval, or a matching deployment-branch rule. A compromised maintainer credential with write/workflow access could use the same trust path, while a maintainer watching mainly main and pull requests might miss the branch and deployment activity.
This is a hardening finding, not evidence that an unauthorized publish or credential compromise occurred.
Evidence captured on 2026-07-28
-
The
pypiGitHub environment reports no protection rules and no deployment branch policy:{ "protection_rules": [], "deployment_branch_policy": null } -
These trusted-publishing workflows all currently combine
workflow_dispatch,environment: pypi, andid-token: write:.github/workflows/py--citry--publish.yml.github/workflows/py--citry-core--publish.yml.github/workflows/py--pygments-citry--publish.yml
-
Each checked-in publish step currently has a tag condition. That condition is useful for normal runs but is not an independent security boundary because a branch revision of the same trusted workflow file can alter it.
-
No repository rulesets currently protect the release-tag namespaces.
-
Authorized proof: branch
release/citry-core-1.4.0-pyemscripten, commit924b993fb6c622cf275237da9a11ff38c31eaf51, workflow run 30396856106. The branch-only job enteredpypiand published successfully without approval.
The prerequisite is meaningful: this is not available to an unauthenticated visitor or an ordinary fork pull request. The threat is takeover or misuse of a credential/account that can push a repository branch and dispatch Actions workflows. The concern is that this access can be escalated into package publication without a reviewed default-branch change or release-tag workflow.
Why the current layers are insufficient
PyPI Trusted Publishing authorizes a GitHub repository, workflow filename, and optional environment. It does not inherently require the workflow to come from main or from a release tag. GitHub allows a manually dispatched workflow to select another branch with --ref when the workflow is dispatchable on the default branch.
Repository-local if: expressions cannot defend against a malicious rewrite of the same workflow on another repository branch. The strongest control needs to live outside the branch-controlled YAML, primarily in GitHub environment deployment policies and protected tag rules.
References:
- GitHub: manually running a workflow from another branch
- GitHub: environment reviewers and deployment branch/tag policies
- PyPI: configuring a GitHub Trusted Publisher
- PyPI: Trusted Publishing security model
Immediate containment
- Restrict the
pypienvironment to selected tag patterns only, covering the intended package namespaces:citry-core@*citry@*pygments-citry@*
- Do not allow ordinary branches or pull-request refs to deploy to
pypi. - Add at least one required reviewer to
pypi. - Enable Prevent self-review.
- Disable administrator bypass for the environment if the repository's operating model permits it.
- Verify that each PyPI project's Trusted Publisher configuration requires the exact workflow filename and the
pypienvironment. - Review recent Actions deployments, package upload histories, branches, tags, collaborators, deploy keys, GitHub Apps, and active PAT/session access for unexpected activity. Record the audit result here. No current evidence requires package deletion or token rotation solely because of this finding.
Workflow and repository hardening
- Remove
workflow_dispatchfrom workflows that can publish, or split manual build/test workflows from tag-only publish workflows. - Ensure manual verification workflows have no
pypienvironment, noid-token: write, and no release-levelcontents: write. - Keep the actual publisher minimal and tag-only. Build/test jobs should pass an exact artifact inventory to one narrowly permissioned publishing job.
- Add tag rulesets for the three package tag namespaces. Restrict tag creation, update, and deletion to the intended release role/process.
- Consider required approval for every PyPI deployment even when triggered by a protected tag. A compromised release-capable account should not be sufficient by itself.
- Add a repository check that flags future combinations of
workflow_dispatch,environment: pypi, and publishing permissions/actions. This is defense in depth for reviewed changes, not a substitute for environment policy. - Document the security boundary, manual-repair procedure, approval path, and audit steps in
docs/codebase.md. - Replace or retire the one-off repair branch after it is no longer needed for audit, according to the agreed retention policy.
Acceptance criteria
- A workflow dispatched from an ordinary repository branch cannot enter
pypior obtain an OIDC token for that environment, even if the branch modifies a registered publishing workflow file. - Normal protected release tags can publish
citry-core,citry, andpygments-citryafter the configured approval. - Manual build/test workflows continue to work without publishing permissions.
- PyPI publisher identities, GitHub environment configuration, tag rulesets, and required reviewers are independently verified and recorded.
- The release documentation and automated workflow-policy checks cover this regression.
Activity
JuroOravec commentedon Jul 28, 2026
Applied the immediately actionable GitHub-side controls on 2026-07-28:
pypinow uses selected deployment refs with tag-only policies forcitry-core@*,citry@*, andpygments-citry@*; it has no allowed branch or pull-request patterns.JuroOravec, rather than the general write/admin roles.This preserves the existing manual tag release flow and blocks other current or future collaborators from creating, moving, or deleting release tags. It does not defend against compromise of the sole bypass account itself; a separate release identity or second-person approval is still required for that threat.
JuroOravec commentedon Sep 10, 2026
The technical remediation is complete. The release process uses qualified artifacts published from
main, with separate controls for publishing credentials, tag creation and generated-site updates. The remaining item before closing this issue is the owner's private-account audit confirmation.pypi,vscode-marketplaces, andrelease-maintenance) allow only the exactmainbranch. Legacy tag allowances have been removed.mainhas separate rulesets for PRs and required checks.JuroOravechas a PR-only bypass of the checks ruleset, allowing selected PRs to merge without waiting for checks. That exception does not bypass the PR requirement or resolved review conversations, and does not permit direct pushes. The dedicated release App is the only bypass actor for the PR ruleset. Its branch bypass is not path-scoped; the trusted workflow restricts generated-site writes to the documented paths. A separate rule prevents deletion and force pushes without bypass.22759193covers all six package tag namespaces and grants creation only to release App4895716. Separate ruleset22759196blocks tag updates and deletion with no bypass actors.docs/codebase.mddocuments the boundary and recovery procedure.The accessible audit found only the expected maintainer collaborator, no deploy keys, and the expected installed Apps. Public PyPI provenance for 44 files across all five Python projects identifies the intended repository, package workflow and
pypienvironment. This checks the identities used for those publications; it does not enumerate private PyPI publisher settings or unused upload tokens, nor inspect private maintainer sessions/PATs. No unexpected activity was identified in the inspected records.Independent PR/deployment approval is deferred to #112, at the maintainer's request, until a second trusted maintainer is available. Administrator control over repository settings remains a stated trust boundary. The original repair branch is retained as audit evidence.
Keep this issue open pending the owner's confirmation of the private PyPI publisher, upload-token and maintainer session/PAT audit. The public provenance checks above do not substitute for that confirmation. Independent approvals remain outside this issue's closure criteria and are tracked in #112.
JuroOravec commentedon Sep 10, 2026
The maintainer has now confirmed the remaining private-account audit: all five PyPI Trusted Publisher configurations are correct, unnecessary PyPI API tokens were removed and none remain, and GitHub personal access was reviewed and cleaned up with all retained access recognized.
Together with the recorded environment rejection test, protected main/tag rules, successful release recovery and documentation, this completes the current-process remediation and audit. Closing this issue. Independent approval requirements when the team grows remain tracked separately in #112.