keyring_backend: keyring writes encryption key to disk (~/.config/gws/.encryption_key) on every invocation
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 55/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Pouca atividade
- Stack de tecnologia
- rust
- Domínio
- authentication, cli, security
Direção de pesquisa
Start by reproducing the behavior with gws auth status and inspect the CLI startup or auth-resolution path that recreates ~/.config/gws/.encryption_key. Trace how the selected keyring backend is handled. Done means keyring mode no longer writes the encryption key to disk while authentication and CLI commands continue to work.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Summary
gws auth status reports keyring_backend: "keyring", but the CLI re-creates ~/.config/gws/.encryption_key on every invocation regardless of backend setting. The on-disk file contains a 44-byte base64-encoded 32-byte AES key — verified to match the keyring-stored key byte-for-byte. The "keyring backend" reporting is misleading: the key material exists in both locations.
For users in regulated environments who selected the keyring backend specifically to keep encryption keys off disk, this defeats the purpose of the setting.
Environment
- OS: Windows 11 Pro (10.0.22631)
- gws CLI:
@googleworkspace/[email protected](gws 0.16.0) - Node: v24.13.0
- npm: 11.11.1
- Keyring backend: Windows Credential Manager (default for Windows)
- Auth: OAuth Desktop client, External + Testing publishing status
Steps to reproduce
# 1. Confirm keyring backend is active gws auth status | grep keyring_backend # Output: "keyring_backend": "keyring"# 2. Capture current key bytes
ORIG=$(cat ~/.config/gws/.encryption_key)# 3. Delete the on-disk key
rm ~/.config/gws/.encryption_key
# File gone# 4. Run any gws command (status, login, drive, gmail, ANY)
gws auth status > /dev/null
# 5. Verify file is back, identical content
NEW=$(cat/.config/gws/.encryption_key)
[ "$ORIG" = "$NEW" ] && echo "SAME KEY" || echo "DIFFERENT"
# Output: SAME KEY
The file is recreated within the lifetime of the next gws process call — no idle timer, no background daemon. It's a synchronous side-effect of CLI startup or auth-resolution code.
Expected behavior
When keyring_backend: "keyring" is the active backend (and GOOGLE_WORKSPACE_CLI_KEYRING_BACKEND is unset or set to keyring), the encryption key should live only in the OS keyring. No copy on disk.
A user who wants the file backend can opt in via GOOGLE_WORKSPACE_CLI_KEYRING_BACKEND=file per the README. That opt-in path should be the only path that writes the key to disk.
Actual behavior
The CLI co-writes the encryption key to /.config/gws/.encryption_key (perms 666 on Windows / 0644 on POSIX) on every invocation, regardless of the keyring backend setting. The file is base64-encoded AES-256 key material — 44 bytes for a 32-byte key.
Security implications
- Defeats keyring-backend opt-in. The OS keyring offers per-user encryption-at-rest with OS-level access control (DPAPI on Windows, libsecret on Linux, Keychain on macOS). Co-writing to plain disk negates that protection — any process with file-system read on the user account gets the key.
- Misleading API surface.
gws auth statusreportskeyring_backend: "keyring"even though the key is on disk. Users (and security auditors reading status output) are misled about where the key lives. - Co-locates with encrypted blob. Because
credentials.encand.encryption_keysit in the same directory, an attacker with file read access has both the ciphertext and the key — encryption-at-rest reduces to no encryption.
Workarounds tried
| Approach | Result |
|---|---|
| rm ~/.config/gws/.encryption_key | Re-created on next gws call |
| chmod 000 ~/.config/gws/.encryption_key | (untested — likely breaks the CLI rather than enforcing keyring-only) |
| GOOGLE_WORKSPACE_CLI_KEYRING_BACKEND=keyring gws ... | No effect — keyring is already the default; file still written |
| Junction/symlink the file to /dev/null equivalent | (untested — Windows symlinks to NUL don't work cleanly) |
There's no documented opt-out for the on-disk file write.
Suggested fix
Add a true keyring-only mode that does not write .encryption_key to disk. Two reasonable shapes:
Default behavior change (preferred): when
keyring_backend == "keyring", do NOT write.encryption_key. The file is only created whenGOOGLE_WORKSPACE_CLI_KEYRING_BACKEND=fileis set explicitly. This matches the README's documented contract: "Credentials are encrypted at rest (AES-256-GCM) with the key stored in your OS keyring (or~/.config/gws/.encryption_keywhenGOOGLE_WORKSPACE_CLI_KEYRING_BACKEND=file)."New env var
GOOGLE_WORKSPACE_CLI_KEY_ON_DISK=falsefor users who want strict keyring-only and are willing to opt in.
Either fix should be paired with a gws auth status field that accurately reports both:
keyring_backend: "keyring" | "file"key_on_disk: true | false(or path)
So security reviewers can audit the actual storage location, not the intended one.
Why this matters
We had a security audit at our org flag the OAuth client gws registers as broad. During remediation, we instructed a user to delete the "stale" .encryption_key file (we initially believed it was residual from a prior file-backend session). The empirical test in step 1 revealed it isn't stale — it's actively maintained, contradicting the CLI's own status reporting. We've documented this as a known constraint in our internal audit, but a fix here would let users in regulated environments accurately attest where their encryption key lives.
Happy to send a PR if there's a maintainer-approved direction.
Repro artifact
The byte-equality check between pre-delete and post-recreation file contents confirms this is the same key, not a newly generated one — i.e., the on-disk file is a deterministic copy of the keyring entry, not an independent secret.
beforeDel.equals(afterRecreate) === true
(Verified on @googleworkspace/[email protected] as of 2026-05-06.)
- Linguagem predominante
- Rust
- Estrelas
- 32.3k
- Forks
- 2k
- Merge médio
- 16h 3min
- PRs com merge (30d)
- 1
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de googleworkspace/cli
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
googleworkspace/cli#984 ·
Mantenedores costumam responder em até 1 dia
-
auth export masks secrets by default with no warning; consumers fail later with invalid_clientAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
googleworkspace/cli#983 ·
Mantenedores costumam responder em até 1 dia
-
Replace gemini with agyAberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 82/100
googleworkspace/cli#958 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
googleworkspace/cli#921 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
googleworkspace/cli#920 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de googleworkspace/cli
Issues semelhantes
-
benchmark-review
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 63/100
Mantenedores costumam responder em até 1 dia
-
area:filesystem bug need-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Captions panel does not offer to show an existing transcriptTalvez já em andamento @thedavidweng assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
CapSoftware/Cap#4276 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
libracoder/kiri#364 ·
Mantenedores costumam responder em até 1 dia