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

Aperta Adatta ai principianti
#983 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
64/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
cli, security

Direzione di ricerca

Inizia nel modulo dei comandi auth di Rust dietro gws auth export e trova dove il flag --unmasked decide se client_secret viene mascherato prima della stampa; è in quel ramo che va un avviso su stderr o un marcatore _masked. Leggi il percorso di export insieme alla sezione headless/CI del README affinché l’avviso corrisponda al workflow documentato, poi controlla i test CLI esistenti per auth export per aggiungere un caso che verifichi che l’output mascherato avvisa. Fatto significa che gli export mascherati sono distinguibili (avviso su stderr o marcatore) mentre l’output di --unmasked resta silenzioso; la minuzia su auth status --format json è una modifica separata e più piccola nello stesso albero dei comandi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Rust
Stelle
32.3k
Fork
2k
Merge medio
16h 3m
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di googleworkspace/cli

Tutte le issue di googleworkspace/cli

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.