Skip to content

Comments

feat(gmail): implement Safe Mode (drafts-only) via --safe flag#314

Open
Ishaan453 wants to merge 1 commit intosteipete:mainfrom
Ishaan453:security/ib/239
Open

feat(gmail): implement Safe Mode (drafts-only) via --safe flag#314
Ishaan453 wants to merge 1 commit intosteipete:mainfrom
Ishaan453:security/ib/239

Conversation

@Ishaan453
Copy link

@Ishaan453 Ishaan453 commented Feb 18, 2026

Description

This PR implements a "Safe Mode" for Gmail interactions, designed to ensure a "Human-in-the-Loop" workflow. When enabled, the CLI can create drafts but is cryptographically restricted from sending emails via the Google API.

Key Changes

New Flag: Added --safe to gog auth add.
Restricted Scopes: Authentication with --safe requests only gmail.insert and gmail.readonly scopes (no gmail.send or gmail.compose).
Security Fix: Patched

internal/googleauth/oauth_flow.go
to support disabling include_granted_scopes. This prevents new tokens from silently inheriting dangerous permissions from previous sessions.
Smart Fallback: Updated gog gmail drafts create to automatically fallback to the messages.insert API if the standard drafts.create permission is missing.
Verification

Authenticate in Safe Mode:

gog auth add <email> --services gmail --safe

Create a Draft (Should Succeed):

gog gmail drafts create --to <email> --subject "Safe Test" --body "Hello"

Attempt to Send (Should Fail):

First, get the draft ID

gog gmail drafts list

Then try to send

gog gmail drafts send <DRAFT_ID>

Expected Result: Google API error (403 insufficientPermissions)

Fixes #239

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restrict Gmail to creating drafts, never send

1 participant