Feature: store Google OAuth client_secret in the keyring (parity with the Zoom path)
What
Make gog auth credentials set secure by default: store the Google OAuth client_secret in the keyring (behind the same 99designs/keyring backend that already protects refresh tokens), keep only non-sensitive metadata on disk. The Zoom integration in this repo already implements exactly this pattern — extending it to the Google OAuth path would bring the two flows to parity, eliminate the plaintext exposure surface that the maintainer's own safety guidance flags, and give third-party plugin authors a consistent at-rest crypto story without an opt-in step.
Why
Today's storage shape
For Google OAuth, gog auth credentials set writes a flat {client_id, client_secret} JSON to disk at $XDG_CONFIG_HOME/gogcli/credentials.json (or credentials-<client>.json for named clients), mode 0600, parent dir 0700:
- Write:
config.WriteClientCredentialsFor(viajson.MarshalIndentof the flatClientCredentialsstruct). - Read on every refresh:
tokenSourceForAccountScopesininternal/googleapi/client_auth.goconstructsoauth2.Config{ClientID, ClientSecret, ...}from the on-disk file. - Keyring
Tokenstruct (internal/secrets/store.go) has fields{Client, Subject, Email, Services, Scopes, CreatedAt, RefreshToken}— noClientSecretfield.
So the refresh token is encrypted at rest by the file-backend keyring (when GOG_KEYRING_PASSWORD is set to a real passphrase); the client_secret, by contrast, has only filesystem ACLs (0600 / 0700) as protection.
Precedent already exists in this repo
The Zoom integration at internal/zoom/store.go does precisely what this issue asks for — for Zoom:
clientSecretKeyFmt = "zoom-account/%s/client-secret"
accessTokenKeyFmt = "zoom-account/%s/access-token"
On-disk metadata for Zoom holds only {account_id, client_id, alias, scopes} (no secret). At runtime, LoadCredentials reads client_id from the metadata file and client_secret from the keyring (secrets.GetSecret(clientSecretKey(alias))), then assembles the in-memory Credentials struct.
That pattern works, ships today, and uses the same backend as the existing Google refresh-token storage. Extending it to the Google path is mostly mechanical.
Project-side cost of the current shape
- Plaintext exposure surface. Container image leaks, disk snapshots, debug dumps, and backup pipelines all capture
credentials.jsonverbatim. Same threat model that refresh-token-in-keyring already mitigates — but only half the credential pair is protected. - Empty-passphrase trade-off is asymmetric. When
GOG_KEYRING_PASSWORD=""(the documented headless fallback atfileKeyringPasswordFuncininternal/secrets/store.go), keyring crypto is effectively obfuscation; with a real per-instance passphrase, refresh tokens become genuinely encrypted but theclient_secretnext to them does not. - Third-party plugin authors hit this immediately. Anyone wiring a non-interactive credential-delivery RPC (the natural shape for headless / agentic deployments) has to ship the
client_secretplaintext to disk to use Google OAuth, even when the surrounding plumbing already supports keyring-only storage for refresh tokens. - Inconsistent with peer integration. Zoom already does this; Google should match. Asymmetry forces consumers to learn two storage models.
Why this isn't covered by the existing flag
The --access-token flag (per-invocation) bypasses the entire refresh path, which is a different feature for a different use case (1h-life tokens, no refresh). It doesn't address the at-rest exposure of client_secret for the refresh flow.
This repo's own security posture argues for the change
gogcli already treats secret hygiene as a first-class concern. The same standards that justify the existing protections justify extending them to client_secret:
- The bundled agent skill explicitly forbids leaking the very value this proposal moves to the keyring.
.agents/skills/gog/SKILL.md§ "Safety Rules" says: "Do not print access tokens, refresh tokens, OAuth client secrets, or keyring passwords." If agents must not print the client_secret, leaving it sitting in plaintext on disk is the same surface area inverted — the file gets picked up by image leaks, snapshots, and backup pipelines that the maintainer can't put a "don't print" rule on. auth doctoractively diagnoses the file-keyring password posture (internal/cmd/auth_doctor.go), with distinct hints forGOG_KEYRING_PASSWORDset / empty / unset / no-TTY. That diagnostic infrastructure exists because the maintainer understands the file-backend crypto is only as strong as its passphrase. The same diagnostic doesn't (and can't) cover the on-diskcredentials.json— there's no equivalent knob to check, because the file isn't behind the keyring at all. Movingclient_secretto the keyring brings it under the same diagnostic surface.- The Safety Profiles system exists specifically to harden gogcli against agent / sandbox compromise (
docs/safety-profiles.md): baked binaries with embedded command policies, agent-safe defaults,--enable-commands/--disable-commands/--gmail-no-send/--wrap-untrustedflags. The threat model that justifies all of this — a process running asgogthat should not be able to escalate beyond a narrow scope — is the same threat model that justifies not leaving the OAuth client secret in plaintext next to it. - The Zoom path already implements the proposed pattern (
internal/zoom/store.go). Refresh tokens, access tokens, andclient_secretall live in the keyring; only non-sensitive metadata is on disk. The asymmetry between the Zoom and Google paths is the strongest argument: the maintainer has already decided the right shape; this issue just asks for parity.
Suggested shape
Mirror the Zoom path. Keyring storage becomes the default; on-disk plaintext becomes opt-out via flag. Secure-by-default is the right posture for a value the maintainer already documents as "must not be printed."
# Default: client_secret to keyring, non-sensitive metadata to disk
gog auth credentials set <path|-> --client=<name>
# Opt-out for back-compat with external tooling reading credentials.json directly
gog auth credentials set <path|-> --client=<name> --insecure
Flag name is a suggestion — --insecure signals the opt-out is a deliberate security downgrade, matching the OpenSSH-style convention where security-relaxing flags are explicit about the trade-off. Alternatives: --legacy (back-compat framing), --no-keyring (mechanism-describing). Whichever the maintainer prefers; the load-bearing part is that the default flips, not the flag name.
Storage layout (default mode)
Mirrors Zoom:
- Disk (
$XDG_CONFIG_HOME/gogcli/credentials.jsonorcredentials-<name>.json): non-sensitive metadata only —{client_id}plus any auxiliary fields the diagnostic surface needs (see § "Diagnostic surface" below). Noclient_secret. - Keyring:
client_secretat keyclient/<name>/client-secret(mirrors Zoom'szoom-account/<alias>/client-secret). Per-client namespacing keeps multi-client setups isolated, matching existing refresh-token bucketing (token:<client>:<email>).
Read path
ReadClientCredentialsFor reads client_id from disk, client_secret from keyring. Fallback: if the on-disk file contains both (legacy installs), use them directly without touching the keyring. Migration is automatic — existing installs keep working until the next auth credentials set, which writes the new shape.
Affected code paths
The change is localized. Most of the codebase reads the assembled ClientCredentials{ClientID, ClientSecret} struct via readClientCredentials and is unchanged. Three diagnostic / enumeration surfaces need adjustment:
gog auth credentials list(internal/config/clients.goListClientCredentials) currently enumerates byos.ReadDir'ing the config dir and matchingcredentials*.jsonfilenames. With the secret in the keyring, the disk file still exists (holdingclient_id) so enumeration continues to work — only the listing'sPathfield semantics change ("metadata file path", not "credential file path").gog auth credentials remove(DeleteClientCredentialsFor) currentlyos.Removes the file. Extended to alsosecrets.DeleteSecret(client/<name>/client-secret). Idempotent at both layers.- Diagnostic surface (
gog auth doctor,gog auth list) emitscredentials_pathandcredentials_exists. Add a siblingclient_secret_in_keyring: boolso operators can confirm the secret is where they expect it to be — and soauth doctorcan flag a "no secret found anywhere" failure mode clearly.
Refresh flow, authorization flow, account-client mapping, domain mapping, and service-account flow are untouched.
Scope
- Google OAuth path only (
installed/webenvelopes viaParseGoogleOAuthClientJSON). - Reuse
99designs/keyringvia the existingsecrets.Storeinterface. - No new env vars introduced; no change to
auth import/auth addsemantics; no change to the refresh flow itself. - Service-account JSON (
auth service-account set --key=<path>) is a separate code path and out of scope here — it has its own at-rest exposure but a different threat model and a much larger blob.
Out of scope
- Forced migration of existing installs — existing
credentials.jsonfiles withclient_secretcontinue to work unchanged via the read-path fallback. The new shape applies on the nextauth credentials set. Operators who don't want to re-run the command get the old behavior indefinitely.
Context
- No existing issue, PR, or discussion proposes this — searched for
client_secret keyring,credentials encrypt,OAuth client secret storage,keyring credentials; discussions are disabled on this repo. Filing as a clean new ask. - Relates to (but is independent of) #357 (ADC auth mode merged 2026-03-08) — that added a separate auth mode; this proposal touches storage of the OAuth-client-mode credentials.
References
All references pinned to v0.17.0:
internal/config/credentials.go—ClientCredentialsstruct + on-disk write path (WriteClientCredentialsFor,ReadClientCredentialsFor).internal/cmd/auth_credentials.go—gog auth credentials setcommand entry point.internal/googleapi/client_auth.go—tokenSourceForAccountScopesreads the on-disk file on every refresh.internal/secrets/store.go—Tokenstruct (refresh-token-only),fileKeyringPasswordFunc(headless empty-passphrase mode).internal/cmd/auth_doctor.go— file-keyring-password diagnostics.internal/zoom/store.go— the model implementation: keyring-onlyclient_secretstorage for the Zoom path..agents/skills/gog/SKILL.md§ "Safety Rules" — the in-repo guidance that says OAuth client secrets must not be printed.docs/safety-profiles.md— baked binaries / agent-safety threat model.
Cross-reference: filed #597 "Feature: add cross-process locking around keyring writes". The two are sequenced — #597 should land first as the foundation, then this proposal becomes a consumer of the lock. Implementing #596 in isolation would add another unlocked keyring write path next to the existing refresh-token entries.
Happy to revise either issue if you'd prefer to bundle them or take a different sequencing.
Keeping the OAuth client secret in the keyring would make the setup safer and closer to how other integrations handle secrets.
this seems worth doing for consistency alone.
if gogcli already trusts the keyring for refresh tokens, and the Zoom integration already stores its client secret there, the Google OAuth path being plaintext on disk feels like the odd one out.
the legacy fallback also makes this a pretty low-risk change: existing installs can keep working, while new credential writes move to the safer layout by default.
would be nice to have Google and Zoom follow the same storage model here.
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.
Workflow note: Future ClawSweeper reviews update this same comment in place.
How this review workflow works
- ClawSweeper keeps one durable marker-backed review comment per issue or PR.
- Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
- A fresh review can be triggered by eligible
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch. - PR/issue authors and users with repository write access can comment
@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only. - Maintainers can also comment
@clawsweeper reviewto request a fresh review only. - Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
- Maintainer-only repair and merge flows require explicit commands such as
@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review. - Maintainers can comment
@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.
Summary
Keep open: current main still persists the Google OAuth client_secret in credentials*.json, while the Zoom path already stores its client secret in the keyring. The request is valid security hardening, but it changes the credential storage contract and likely needs maintainer judgment on the default flip, legacy opt-out, diagnostics, and sequencing with https://github.com/openclaw/gogcli/issues/597.
Reproducibility: yes. for the reported storage shape: source inspection shows auth credentials set parses Google OAuth JSON and writes a ClientCredentials struct containing client_secret to credentials*.json. I did not execute the CLI because this review is required to keep the checkout read-only.
Next step Manual maintainer review is needed because the fix changes the credential storage contract and should be coordinated with the open keyring-locking work.
Security Needs attention: The issue raises a real credential-storage hardening concern: Google OAuth client secrets are still persisted in plaintext JSON rather than the existing keyring-backed secret path.
Review details
Best possible solution:
Adopt a single Google OAuth credential contract where new writes keep only non-sensitive client metadata on disk, store client_secret in the keyring, preserve legacy plaintext reads, remove both layers together, and expose diagnostics for missing or keyring-backed secrets after maintainers choose the default/opt-out policy.
Do we have a high-confidence way to reproduce the issue?
Yes for the reported storage shape: source inspection shows auth credentials set parses Google OAuth JSON and writes a ClientCredentials struct containing client_secret to credentials*.json. I did not execute the CLI because this review is required to keep the checkout read-only.
Is this the best way to solve the issue?
Unclear as a final product decision: keyring-backed new writes with legacy plaintext fallback is the narrow maintainable direction, but the default flip, opt-out flag, diagnostics, and sequencing with the keyring-locking issue need maintainer approval before implementation.
Label changes:
- add
P2: This is a concrete security hardening improvement with limited blast radius, not an emergency runtime failure. - add
impact:security: The issue is about reducing at-rest exposure of an OAuth client secret currently stored in a local JSON file. - add
impact:auth-provider: The requested change affects OAuth client credential storage and the refresh/auth path that consumes those credentials. - add
issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label. - add
clawsweeper:source-repro: Current issue advisory state selects this label. - add
clawsweeper:no-new-fix-pr: Current issue advisory state selects this label. - add
clawsweeper:fix-shape-clear: Current issue advisory state selects this label. - add
clawsweeper:needs-maintainer-review: Current issue advisory state selects this label. - add
clawsweeper:needs-product-decision: Current issue advisory state selects this label. - add
clawsweeper:needs-security-review: Current issue advisory state selects this label.
Label justifications:
P2: This is a concrete security hardening improvement with limited blast radius, not an emergency runtime failure.impact:security: The issue is about reducing at-rest exposure of an OAuth client secret currently stored in a local JSON file.impact:auth-provider: The requested change affects OAuth client credential storage and the refresh/auth path that consumes those credentials.
Security concerns:
- [medium] OAuth client secret remains in credentials file —
internal/config/credentials.go:66WriteClientCredentialsForserializesClientSecretintocredentials*.json, so backups, snapshots, or image captures of the config directory can include the Google OAuth client secret even when refresh tokens use the keyring. Confidence: 0.91
Acceptance criteria:
- go test ./internal/config ./internal/cmd ./internal/googleapi ./internal/googleauth ./internal/secrets ./internal/zoom
- make ci
What I checked:
- Current Google credential model includes the secret on disk:
ClientCredentialscontains bothclient_idandclient_secret;WriteClientCredentialsFormarshals that struct and writes it to the credentials file with mode 0600, andReadClientCredentialsForstill requiresClientSecretto be present in that file. (internal/config/credentials.go:15, 8c5c30c4156b) - CLI set path does not touch the keyring:
AuthCredentialsSetCmd.Runreads the input JSON, parses it, and callsconfig.WriteClientCredentialsFor; there is nosecrets.SetSecretcall in the Google credentials set path. (internal/cmd/auth_credentials.go:49, 8c5c30c4156b) - Tests still assert plaintext credential-file round trip:
TestClientCredentials_RoundtripwritesClientCredentials{ClientID, ClientSecret}and reads the same secret back from the file-backed credential path, confirming the current contract under test. (internal/config/credentials_test.go:47, 8c5c30c4156b) - Zoom already uses the proposed keyring split: Zoom metadata stores non-secret fields on disk, while
LoadCredentialsreads the client secret fromsecrets.GetSecret(clientSecretKey(alias))andStoreCredentialswrites it withsecrets.SetSecret. (internal/zoom/store.go:28, 8c5c30c4156b) - Generic keyring secret helpers exist:
internal/secrets/store.goexposesSetSecretandGetSecret, but the current Google OAuth client-credentials path does not use those helpers forclient_secret. (internal/secrets/store.go:323, 8c5c30c4156b) - No closing pull request currently owns this issue: GitHub issue metadata reports no
closedByPullRequestsReferences, and search for the sameclient_secret keyringproblem only found this open credential-handling cluster rather than a merged fix.
Likely related people:
- steipete: Visible local blame for the current credential, secrets, and Zoom files points to Peter Steinberger's v0.18.0 release snapshot, and GitHub metadata shows follow-up/auth hardening commits in nearby auth and Zoom work. (role: recent area contributor and merger; confidence: medium; commits: 7c511d8dd731, d6f8589fe09d, b4f79f64ba84; files:
internal/config/credentials.go,internal/cmd/auth_credentials.go,internal/secrets/store.go) - yamagucci: GitHub metadata for https://github.com/openclaw/gogcli/pull/473 shows authored work on
auth credentials remove, includinginternal/cmd/auth_credentials.goandinternal/config/credentials.go, which would need updates when secrets move out of the metadata file. (role: auth credentials command contributor; confidence: medium; commits: bed062ebcc6c, c100d539636b, 9fb6a56d5be3; files:internal/cmd/auth_credentials.go,internal/config/credentials.go,internal/cmd/execute_auth_credentials_test.go) - mvanhorn: GitHub metadata for https://github.com/openclaw/gogcli/pull/590 shows authored work adding the Zoom integration and
internal/zoom/store.go, which is the closest implemented precedent for metadata-on-disk plus client-secret-in-keyring. (role: Zoom credential-storage feature contributor; confidence: high; commits: 2ba8a6568092, 53889e2497b4; files:internal/zoom/store.go,docs/zoom-auth-setup.md,internal/cmd/zoom_auth.go)
Remaining risk / open question:
- Changing the default storage shape can break external tooling that reads
credentials*.jsonand expectsclient_secret; maintainers need to choose the legacy fallback, opt-out flag, and migration/documentation story. - Adding Google client-secret keyring writes before the keyring-write-locking work in https://github.com/openclaw/gogcli/issues/597 is resolved would expand the number of keyring mutation paths that need concurrency guarantees.
Codex review notes: model gpt-5.5, reasoning high; reviewed against 8c5c30c4156b.
agree, makes sense.
Fixed on main in 1531013.
What landed:
- OAuth client_secret is stored in the keyring by default.
- The credentials JSON keeps only metadata for the secure path.
- Legacy plaintext credentials still read correctly.
- auth credentials set has an explicit insecure mode for plaintext storage.
- Removal deletes both metadata and keyring secret, with regression coverage for keyring failure ordering.
Proof:
- Focused auth/keyring tests passed.
- make ci passed.
- Live CLI smoke verified the secret is not written to the metadata file and is reported as keyring-backed.
- Final autoreview: clean, no accepted/actionable findings.