Skip to content

fix(lookup): mise lists a repository's tools with a token scoped to it - #327

Merged
sweepies merged 2 commits into
mainfrom
fix/mise-scoped-token
Nov 14, 2026
Merged

sweepies merged 2 commits into
mainfrom
fix/mise-scoped-token

Conversation

@sweepies

@sweepies sweepies commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

First PR in the mise trust series. Option pass-through, trustedRepositories, centralised code-execution flags and plugin backends come in later PRs.

Problem

mise_token() handed mise the run's whole token. In --all-repos, multi-repo Action runs and patchula serve, that is the installation token, so any repository's mise.toml could name github:org/private-tool and get that private tool's releases listed.

What changes

Token. A mise lookup for a repository gets a token minted with Credentials::scoped_token. The permission set depends on the access:

  • Repository listings get ContentsRead ({"contents":"read","metadata":"read"}), the smallest set that lists the repository's own private releases.
  • Public listings get MetadataRead only. That reads public repositories' releases and tags (GitHub: permissions "are required to access private resources"; "published releases are available to everyone") and no private repository's contents, including the minted repository's own. Without that, a renamed private repository whose mise.toml names its old name could put its own private releases into the shared public listing.

Permissions is a public enum passed to scoped_token. Credentials also answer mints_scoped_tokens() and repository_id(), and actions.lock passes MetadataRead explicitly.

The access is decided in one place, Sources::mise_access(repository, tool), which batch lookups and release notes both use:

  • no repository (a local directory), or credentials that can't mint (PATs, an Action's own token) → MiseAccess::Run, today's behaviour
  • otherwise → the scope rule below.

PR 3 can switch this one function to "trusted → run token, untrusted → scoped". A batch lookup checks that its key's access matches what its repository gives, and fails otherwise. A Public key with no repository to mint for never runs, and nothing falls back to the run token.

Cache sharing (the scope rule, patchula_datasource::mise_access). patchula_mise::github_sources(tool) returns the GitHub repositories a listing may read:

  • github:, ubi:, aqua:, packslip:, and cargo: with a GitHub URL name their repository
  • a shorthand counts every non-plugin backend the registry snapshot lists for it
  • core: and plain npm/cargo/pypi/pipx/gem/conda names → no GitHub repository
  • anything else (go:, http:, spm:, gitlab:, unlisted shorthands…) → unknown. This list fails closed.

From that:

  • Public: the source is known and isn't this repository, or the current repository is public and the source is unknown. Listed once per batch and cached under public. The token comes from the first repository that asked, so it is never the source repository's token.
  • Repository(repo) (name lowercased): the source is this repository, or the source is unknown and the repository is private (or its visibility wasn't read). The listing is cached under <credential scope>:<repository id>, and the catalog view under Repository(<id>). The id is the one the mint resolves, so a new repository that takes a renamed one's name reads neither.
  • Run: today's credential scope. Never served to scoped lookups.
  • Off github.com no token reaches mise, so those listings are public.

To make this work:

  • MiseAccess is the third element of the engine's LookupKey, so batch dedup and the catalog state scope both respect it.
  • Release notes use a notes client made for the repository (with_mise_repository). The notes mise listing and mise tool backend lookup therefore get the same token and listing scope as the proposal's, and the in-memory note-source read for a mise tool is keyed by that access.
  • Work records the repository's visibility, read from model::Repository.private or GraphQL isPrivate.

Tool options in ListingScope: deferred to PR 2. patchula_mise::check still refuses bracketed options, so no listing can depend on options today and the field would always be empty. PR 2 adds the field together with the code that passes options, and bumps mise-ls-remote again (one extra cache miss).

State bumps

These states are bumped on purpose:

  • mise-ls-remote 1→2 (scope shape)
  • lookup-hint 2→3 (key shape)
  • catalog 6→7 (scope gains access)

The parity guard also required bumps for states whose hashed trees this touches (crates/github/src/, crates/engine/src/, crates/mise/src/, crates/notes/src/, crates/datasource/src/): source-head, tag-catalog, tag-object, github-release-head, extract, files, config, config-files, catalog-controls, changelog, notes-adapter, notes-adapter-listing, parsed-postgres-sgml, parsed-go-history, release-notes, not-ours, notes-source-{npm,crates,pypi}. Expect one cold run after upgrading.

Tests

  • mise unit test: github_sources per backend kind.
  • datasource/tests/mise_lookup.rs:
    • the scope rule (public / own repo / unknown + private / unknown + public / non-GitHub backend, lowercased)
    • the permission set per access: ContentsRead for the repository's own listing, MetadataRead for a public one, the installation token without a repository, and the run token when credentials can't mint
    • batch lookups fail closed: a Public key without a via, or a key the via doesn't give, fails without starting mise
    • sharing and keying: a public listing is reused across repositories; a repository listing isn't reused by another repository or by a run-token lookup; case doesn't matter; a new repository under a renamed one's name gets a fresh listing
  • engine:
    • mise_access falls back to Run for a token run, a local directory and non-mise sources; unread visibility counts as private; names are lowercased
    • the catalog test keeps Run, Public, Repository(a) and Repository(b) views of one package separate, each reused for itself, and drops the repository view after a rename (new id)
    • mise_vias picks up dependencies promoted after the first pass. It's a unit test of what the second age_catalogs pass recomputes, not an end-to-end lockfile promotion.
  • github: a ContentsRead mint is cached separately from MetadataRead for the same repository.

Docs

  • internals/github-client.md: scoped permissions.
  • internals/cache.md: the mise listing scope rule.
  • guide/sources.md: which token mise gets, and how listings are shared.
  • renovate/departures.md: a private tool from another repository no longer resolves under an App.

Follow-ups (not in this PR)

Remaining paths where a repository's lookup reads GitHub with the installation token:

  • GitHub releases/tags lookups (e.g. uses: org/private-action, github-releases dependencies) and the release-notes reads of releases, changelogs and tags from a source repository. For example, a public package such as npm:internal-cli whose registry metadata names a private repository can still get that repository's release notes into a PR. This PR moves the notes' mise lookups onto the repository's access but not those GitHub reads.
  • nix flake prefetch (nix flake prefetch gets run_tool_token()).

As a GitHub App, mise got the installation token, so any repository's
mise.toml could list the releases of any private repository the App can
read. mise lookups now get a read-only token (contents and metadata read)
minted for the repository the lookup is for. Credentials that cannot mint
one (personal tokens, an Action's own token) and local directories keep
the run's token.

Listings stay shared across repositories where they are public data: a
tool released from another repository, from a package registry or a core
tool is listed once per batch and cached as public. A tool released from
the repository itself, or of unknown source in a private repository, is
listed and cached for that repository alone. The access is the third
element of the batch lookup key and part of the catalog scope.

Bumps mise-ls-remote, lookup-hint, catalog and the code-versioned states
whose hashed sources this touches.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula eddf349 Commit Preview URL

Branch Preview URL
Nov 14 2026, 09:22 PM

…are the lookup's access

- Public listings mint `metadata: read`, which reads no private releases,
  so a renamed repository whose mise.toml names its old name cannot put
  its own private releases into the shared public listing. A
  repository's own listing keeps `contents: read`.
- `Sources::mise_access` is the one place the access is decided, from the
  repository a lookup is made for. Release notes get a client made for
  the repository, so their mise listing and backend lookup use the same
  token and scope as the proposal's; the note-source read is keyed by it.
- A batch lookup checks its key's access against the repository it is
  made for and fails otherwise: a public key without a repository never
  runs.
- A repository's own listing and catalog view are keyed by the numeric id
  the mint names, so a repository that takes a renamed one's name reads
  none of them. Repository names in the access are lowercased.
sweepies added a commit that referenced this pull request Nov 14, 2026
…d unreproducible layering refused

- A tool whose options name another host gets the same token as any other
  lookup from its repository: under #327 that token reaches no further
  than the repository whose own entry wrote the options. A public key's
  token is minted for a repository that asked for exactly that tool and
  options (options are part of the lookup key), which a test pins.
- Options that point mise at a cloud instance-metadata endpoint are
  refused: a URL whose host is, or resolves to, a link-local address
  (169.254.0.0/16, fe80::/10), fd00:ec2::254, metadata.google.internal or
  metadata. Such endpoints hand out the machine's own credentials. mise
  resolves again and follows redirects, which this does not catch.
- The sandbox gives the s3 backend's AWS SDK no credentials: config and
  credential files in the scratch home, AWS_EC2_METADATA_DISABLED=true.
- mise does not merge a tool's options across configuration files (the
  highest-precedence entry replaces the others whole, checked with the
  pinned mise), so each entry keeps its own; an array lists with its first
  request's options. A task's tool is refused when it or its [tools] entry
  in the task's hierarchy has table options, since mise layers the two by
  version in a way the Count does not reproduce.
- The http/s3 skip reads the parsed options (s3 per platform too), and a
  refused entry fails its lookup rather than look skipped.
- Legacy bracket values TOML would read as non-strings are refused;
  strings holding `"` are written as TOML literal strings.
@sweepies
sweepies merged commit e3800a6 into main Nov 14, 2026
13 checks passed
@sweepies
sweepies deleted the fix/mise-scoped-token branch November 14, 2026 22:58
sweepies added a commit that referenced this pull request Nov 14, 2026
…d unreproducible layering refused

- A tool whose options name another host gets the same token as any other
  lookup from its repository: under #327 that token reaches no further
  than the repository whose own entry wrote the options. A public key's
  token is minted for a repository that asked for exactly that tool and
  options (options are part of the lookup key), which a test pins.
- Options that point mise at a cloud instance-metadata endpoint are
  refused: a URL whose host is, or resolves to, a link-local address
  (169.254.0.0/16, fe80::/10), fd00:ec2::254, metadata.google.internal or
  metadata. Such endpoints hand out the machine's own credentials. mise
  resolves again and follows redirects, which this does not catch.
- The sandbox gives the s3 backend's AWS SDK no credentials: config and
  credential files in the scratch home, AWS_EC2_METADATA_DISABLED=true.
- mise does not merge a tool's options across configuration files (the
  highest-precedence entry replaces the others whole, checked with the
  pinned mise), so each entry keeps its own; an array lists with its first
  request's options. A task's tool is refused when it or its [tools] entry
  in the task's hierarchy has table options, since mise layers the two by
  version in a way the Count does not reproduce.
- The http/s3 skip reads the parsed options (s3 per platform too), and a
  refused entry fails its lookup rather than look skipped.
- Legacy bracket values TOML would read as non-strings are refused;
  strings holding `"` are written as TOML literal strings.
sweepies added a commit that referenced this pull request Nov 14, 2026
…o mise (#329)

* feat(mise): look up tools whose entries carry options, passing them to mise

The Count refused a mise tool whose entry set options (`rust = { version,
profile, components }`, a forgejo tool with `api_url`) or whose name
carried them in brackets (`github:org/tool[bin=tool]`). Now the options
travel with the tool to the pinned mise, which applies them to the listing
exactly as it does when installing.

- Extraction writes the entry's options (every key but `version`) into the
  package in mise's bracket syntax, sorted and canonical; a bracketed name
  is passed as written. An entry with both, or an option the canonical
  form cannot hold, fails its lookup without repeating what it holds.
- `patchula_mise::check` validates options too: no leading `-` in keys or
  string values, no `@`, no control characters, a length limit, and only
  the canonical TOML form or mise's legacy `key=value` form.
- mise sends `MISE_GITHUB_TOKEN` to any host shaped like a GitHub API, so a
  tool whose options hold a `:` (and so may name a host) gets no token;
  its listing is public, keyed apart by its options. Any tool with options
  is one whose source the Count cannot place for the scope rule.
- The `mise-ls-remote` scope carries the options (state version 3).
- http/s3 tools are skipped only when the entry lacks `version_list_url`
  (or `version_prefix`), since those options are now passed.
- A rule's `packages` matches the bare tool name as well.

* fix(mise): options keep the repository's token; metadata endpoints and unreproducible layering refused

- A tool whose options name another host gets the same token as any other
  lookup from its repository: under #327 that token reaches no further
  than the repository whose own entry wrote the options. A public key's
  token is minted for a repository that asked for exactly that tool and
  options (options are part of the lookup key), which a test pins.
- Options that point mise at a cloud instance-metadata endpoint are
  refused: a URL whose host is, or resolves to, a link-local address
  (169.254.0.0/16, fe80::/10), fd00:ec2::254, metadata.google.internal or
  metadata. Such endpoints hand out the machine's own credentials. mise
  resolves again and follows redirects, which this does not catch.
- The sandbox gives the s3 backend's AWS SDK no credentials: config and
  credential files in the scratch home, AWS_EC2_METADATA_DISABLED=true.
- mise does not merge a tool's options across configuration files (the
  highest-precedence entry replaces the others whole, checked with the
  pinned mise), so each entry keeps its own; an array lists with its first
  request's options. A task's tool is refused when it or its [tools] entry
  in the task's hierarchy has table options, since mise layers the two by
  version in a way the Count does not reproduce.
- The http/s3 skip reads the parsed options (s3 per platform too), and a
  refused entry fails its lookup rather than look skipped.
- Legacy bracket values TOML would read as non-strings are refused;
  strings holding `"` are written as TOML literal strings.

* test(mise): a refused selector test no longer reads as a credential URI
@sweepies-ops sweepies-ops Bot mentioned this pull request Nov 14, 2026
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