Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Security] Credentials are not device-bound — copying ~/.config/gws grants full account access on any machine #338

t3cknic1an started this conversation in Ideas
Discussion options

Summary

The credential store at ~/.config/gws/ (including credentials.json and the associated keyring-derived encryption key) can be copied to any other machine and used to authenticate with full OAuth scope access. This bypasses device-based access controls that organizations rely on — such as Google Workspace's [Context-Aware Access](https://support.google.com/a/answer/9275380) and [device trust policies](https://support.google.com/a/answer/7587183) — which are designed to ensure data can only be accessed from managed, enrolled devices.


Steps to Reproduce

  1. Authenticate on Machine A: gws auth login
  2. Copy ~/.config/gws/ to Machine B (unmanaged/personal device)
  3. Run gws drive files list on Machine B — succeeds without re-authentication

Expected Behavior

Credentials should be bound to the originating device. If the credential store is detected on a different device, the CLI should invalidate the session and force re-authentication.


Impact

  • Organizational device trust policies (e.g. Google BeyondCorp / Context-Aware Access) can be circumvented entirely at the CLI layer
  • Refresh tokens — which are long-lived — remain valid indefinitely after being exfiltrated, even if the device is de-enrolled from MDM
  • This is a meaningful risk for enterprise users where gws is deployed with broad OAuth scopes (drive, gmail, admin, etc.)

Proposed Fix

Bind credentials to the device by incorporating a stable, machine-unique identifier into the encryption key derivation. On first auth, derive and store a device fingerprint. On each subsequent use, verify the fingerprint matches before decrypting credentials.

The re-auth error message should be explicit and actionable, e.g.:

Error: Credentials were created on a different device and cannot be used here.
Run `gws auth login` to authenticate on this machine.

Additional Context

  • The README's [Headless / CI export flow](https://github.com/googleworkspace/cli#headless--ci-export-flow) (gws auth export) explicitly documents copying credentials between machines, which is a valid use case. Any fix should preserve this workflow with an explicit opt-in flag (e.g. --portable) while making device-bound credentials the secure default.
  • Related: Google's own OAuth 2.0 documentation recommends that refresh tokens be stored in secure, device-local storage.
You must be logged in to vote

Replies: 2 comments 2 replies

Comment options

I think this might be only for windows?

You must be logged in to vote
2 replies
Comment options

My testing was performed macOS > macOS. I have not tested it with Windows yet.

Comment options

#345 fixes this

Comment options

This does not seemed to be fixed. It is still writing the data to ~/.config/gws/ When copied I can still access resources unrestricted from an unauthorized machine. When I remove credentials.enc and token_cache.json it does not find anything in Keyring to auth with on the authorized machine. Seems like it is still not relying on the keychain to authenticate.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
Converted from issue

This discussion was converted from issue #328 on March 09, 2026 18:34.

AltStyle によって変換されたページ (->オリジナル) /