Skip to content

gh auth login --with-token accepts a token without the advertised workflow scope #14754

Open

Description

@aner-dev

Summary

gh auth login --with-token advertises a minimum scope set that it does not
enforce: the flow prints "The minimum required scopes are 'repo', 'read:org',
'workflow'", but the login completes successfully with a token that carries no
workflow scope.

Environment

  • gh 2.102.0 (2026-09-30)
  • Linux x86_64
  • Classic PAT (not fine-grained)

Reproduction

  1. Create a classic personal access token with the scopes repo, read:org
    and read:project. Do not grant workflow.
  2. Run gh auth login --hostname github.com --with-token and paste the token
    at the prompt.
  3. The login completes without an error.
  4. Run gh auth status. It reports:
    - Token scopes: 'read:org', 'read:project', 'repo'

Expected

Either the pasted token is rejected because it lacks the advertised
workflow scope, or the hint lists only the scopes that are actually
required.

Actual

The token is accepted, and the advertised workflow scope is never checked.
The stored credential works for API calls while lacking a scope the flow
claimed to require.

Additional Context

  • The hint is printed by the paste-token flow. The browser (OAuth) flow
    requests a different scope set, so the two flows do not agree on what
    "minimum" means.
  • Not verified whether the missing check is intentional, or whether the hint
    is simply a copy of the OAuth scope set.
  • Relevant to any setup that treats the printed scopes as an enforced
    contract rather than a suggestion.

Activity

  1. cli-triage commented on Oct 19, 2026

    @cli-triage

    Thanks for the detailed report. I traced this through the current source (commit ed40e856) and your diagnosis checks out as a real discrepancy, not just a hypothesis.

    • The --with-token flow in login.go line 75 advertises repo, read:org, and gist as the minimum required scopes.
    • The interactive paste-token path in login_flow.go lines 165-169 builds its own minimumScopes sentence (repo, read:org, plus any additionalScopes, which can include workflow — see git_credential.go line 36).
    • Both paths call HasMinimumScopes → HeaderHasMinimumScopes in oauth_scopes.go lines 72-92, which only ever checks for repo and read:org/write:org/admin:org. It never checks workflow or gist.

    So the hint text and the enforcement function are simply out of sync: whatever scopes are printed to the user beyond repo/read:org (gist, workflow, admin:public_key) are never actually validated. This matches your reproduction exactly. I don't see an existing duplicate issue for this specific scope-validation gap. Suggesting bug, gh-auth, and priority-3 (narrow, workaround available, no data loss) — a maintainer should decide whether to extend HeaderHasMinimumScopes to cover all advertised scopes or trim the advertised scope list to match what's enforced.

    Generated by Issue Triage (skills-driven) for #14754 · copilot · auto · 66.5 AIC · ⊞ 9.7K · ◷

  2. added
    bug
    gh-auth
    priority-3
    on Oct 20, 2026
  3. removed
    needs-triage
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggh-authpriority-3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions