auth export masks secrets by default with no warning; consumers fail later with invalid_client

Aberta Para iniciantes
#983 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
64/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
rust
Domínio
cli, security

Direção de pesquisa

Comece no módulo de comando auth do Rust por trás de gws auth export e encontre onde a flag --unmasked decide se client_secret é mascarado antes da impressão; é nesse ramo que deve ficar um aviso em stderr ou um marcador _masked. Leia o caminho de exportação junto com a seção headless/CI do README para que o aviso corresponda ao fluxo de trabalho documentado, depois verifique os testes CLI existentes para auth export para adicionar um caso que verifique que a saída mascarada emite aviso. Pronto significa que exportações mascaradas são distinguíveis (aviso em stderr ou marcador) enquanto a saída de --unmasked permanece silenciosa; o detalhe de auth status --format json é uma mudança separada e menor na mesma árvore de comandos.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Summary

gws auth export without --unmasked prints credential-shaped JSON and exits 0, with nothing in the output, the exit code, or stderr indicating that the client_secret is masked. Anything that consumes that output — a script, an agent, a human setting up a headless box — accepts the shape and then fails later, inside a different library, with an error that points at credential corruption instead of at the export step.

Environment

  • gws 0.22.5 on Linux
  • OAuth2 desktop client, keyring backend, encrypted credentials store
  • Consumer: google.oauth2.credentials.Credentials.from_authorized_user_info(...) from google-auth

Reproduction

  1. gws auth login interactively; confirm gws auth status reports token_valid: true and that real API calls succeed (they did — gmail users getProfile, calendar calendarList list).
  2. gws auth export → prints JSON with keys type, client_id, client_secret, refresh_token. Exit code 0.
  3. Feed that JSON to google-auth and refresh:
RefreshError: ('invalid_client: The provided client secret is invalid.',
               {'error': 'invalid_client',
                'error_description': 'The provided client secret is invalid.'})

I read that as "the stored client secret is corrupt" and went looking for credential damage — while gws itself kept working fine against the same store, which made export look broken rather than under-promising.

The actual answer was in gws auth export --help:

--unmasked  Show secrets without masking

and in the README's Headless / CI flow, which uses gws auth export --unmasked > credentials.json. Masking by default is the right call; failing silently about it is the problem.

Why it matters

  • Masked output is structurally indistinguishable from a real credential file, so consumers cannot detect it.
  • The failure surfaces later, in another process, with a message that misattributes the cause (invalid_client suggests a bad secret for that client_id, not an intentionally masked value).
  • The CLI knows exactly which flag was missing but never says so.

Suggested fixes

Any one of these would have avoided the detour:

  1. When emitting masked output, warn on stderr: warning: client_secret is masked and this output is not usable as credentials — re-run with --unmasked.
  2. Add a marker field to the JSON when masking, e.g. "_masked": true, so consumers can detect it programmatically.
  3. Consider a non-zero exit (or a --force) when masked output is written while stdout is redirected to a file, since that is the exact shape of the documented copy-to-another-machine workflow.

Related nit (same investigation)

gws auth status --format json fails with error: unexpected argument '--format' (exit 3), even though the default auth status output is already JSON. Every other command surface accepts --format, so scripts that pass it uniformly trip over this one subcommand.

Linguagem predominante
Rust
Estrelas
32.3k
Forks
2k
Merge médio
16h 3min
PRs com merge (30d)
1

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de googleworkspace/cli

Todas as issues de googleworkspace/cli

Issues semelhantes

Mais issues de Rust

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.