---
title: "Publish your packages without stored · Agent Wranglers"
url: https://agentwranglers.se/playbook/adversarial-testing/supply-chain-and-setup/trusted-publishing
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Publish your packages without stored tokens

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

For AI agents: [llms.txt](https://agentwranglers.se/llms.txt) is a short guide that sends you to the rules your problem needs, and [rules.json](https://agentwranglers.se/playbook/adversarial-testing/rules.json) holds every rule of this playbook as JSON.

- Level: Recommended
- Chapter: [Supply chain and setup](https://agentwranglers.se/playbook/adversarial-testing/supply-chain-and-setup)
- Rule: Publish your own packages only from the build server through trusted publishing, with two-factor login on every maintainer account. Keep no long-lived publish token anywhere.
- How: Skip this rule when you publish no packages. Registries such as npm and PyPI accept a short-lived OIDC token from a named build workflow instead of a stored token. Then set the package to require two-factor login and refuse tokens, as npm's settings allow. In 2025, a worm stole publish tokens from developer machines and pushed infected versions of other packages. Maintainers use phishing-resistant factors, as [Offer two-factor login](https://agentwranglers.se/playbook/adversarial-testing/access-and-accounts/two-factor-login) describes.
- Check: Search the build settings, the secrets store and each maintainer's `~/.npmrc` and `~/.pypirc` for publish tokens. None is found. A publish attempt with a classic token is refused by the registry.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### YAML example

```yaml
# .github/workflows/release.yml
permissions:
  contents: read
  id-token: write
jobs:
  publish:
    runs-on: ubuntu-latest
    environment: release
    steps:
      - uses: actions/checkout@<full-commit-hash>
      - run: npm ci && npm publish
```

## Sources

- [npm Docs on trusted publishing](https://docs.npmjs.com/trusted-publishers)
- [CISA alert on the npm supply chain compromise](https://www.cisa.gov/news-events/alerts/2025/09/23/widespread-supply-chain-compromise-impacting-npm-ecosystem)

## Related rules

- [Build releases only in CI and verify them before deploy](https://agentwranglers.se/playbook/engineering/build-test-and-deploy/build-in-ci-and-verify) in Engineering
- [Offer two-factor login](https://agentwranglers.se/playbook/adversarial-testing/access-and-accounts/two-factor-login) in Security testing

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/adversarial-testing/supply-chain-and-setup/trusted-publishing">Agent Wranglers security testing playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Remove DNS records you no longer use](https://agentwranglers.se/playbook/adversarial-testing/supply-chain-and-setup/dangling-dns)
- Next: [Treat a machine that installed a bad package as breached](https://agentwranglers.se/playbook/adversarial-testing/supply-chain-and-setup/compromised-package-response)
- [Supply chain and setup](https://agentwranglers.se/playbook/adversarial-testing/supply-chain-and-setup)
