Skip to content

fix(sandbox): stop exposing the Gmail OAuth token to sandboxed Bash - #1681

Merged
potiuk merged 2 commits into
apache:mainfrom
potiuk:sandbox-no-gmail-token
Oct 17, 2026
Merged

potiuk merged 2 commits into
apache:mainfrom
potiuk:sandbox-no-gmail-token

Conversation

@potiuk

@potiuk potiuk commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Summary

  • The Gmail OAuth refresh token lived in ~/.config/apache-magpie/, which the settings template makes sandbox-readable (framework tools need user.md, the PII map and other state there), and the template also allowed oauth2.googleapis.com / gmail.googleapis.com. Together, any unprompted sandboxed command could use the user's Gmail.
  • The token moves to its own directory, ~/.config/apache-magpie-gmail/, which stays sandbox-denied (plus an agent Read deny). ~/.config/apache-magpie/ stays readable. The Google API hosts leave allowedDomains. A token found only at the old default path is moved automatically (atomic rename, dir 0700, file 0600); an explicitly given path is left alone, and a failed move falls back to a warning.
  • Skills no longer shell out to any oauth-draft-* script (or probe the token with test -f). They call the gmail-plaintext MCP server, which Claude Code runs outside the sandbox: check_auth / create_draft (same to / cc / subject / body / thread_id inputs as the CLI), plus a new read-only tool, thread_message_ids (for security-issue-import). Bulk label changes (oauth-draft-mark-read) are deliberately not exposed as an agent tool: a mailbox-wide mutation stays a command a human runs. The scripts remain for humans.
  • sandbox-lint refuses the token directory in allowRead, the Gemini policy denies it, and isolated-setup-update flags a token left at the old path (or the Google hosts) as a must-fix.

Type of change

  • Skill change (.claude/skills/<name>/) — eval fixtures updated below
  • Tool / bridge contract (tools/<system>/*.md)
  • Python package (tools/*/ with pyproject.toml)
  • Groovy reference impl
  • Cross-cutting (RFC, AGENTS.md, sandbox, privacy-LLM)
  • Documentation (docs/, README.md, CONTRIBUTING.md)
  • Project template (projects/_template/)
  • CI / dev loop (prek, workflows, validators)
  • Other:

Test plan

  • prek run on the changed files passes, except workspace pytest for oauth-api, jira, typed-decision: untouched tools whose tests bind a local port, refused by the local sandbox (EPERM). CI will run them.
  • uv run pytest passes for tools/sandbox-lint, tools/agent-isolation, tools/gmail/oauth-draft (new tests: default path is outside the readable config dir, default beats legacy, legacy is moved with the right modes, an explicit legacy path is left alone, a failed move warns; thread_message_ids, and an assertion that no bulk-modify tool is registered; the security_cc recipe test executes the MCP recipe and checks its arguments against the tool signature)
  • For Groovy bridges touched: command-line invocation tested end-to-end
  • For skill changes: eval suite passes for the affected skill — not run locally (needs an LLM endpoint); step-ghsa-access-tier and step-draft-backend fixtures updated
  • For skill behaviour changes: updated eval fixture included
  • Other:

RFC-AI-0004 compliance

  • Sandbox — removes the Gmail token and the Google API hosts from the default sandbox
  • Write-access discipline — unchanged: drafts only, sent by the human

Linked issues

None found for this; searched issues and PRs before filing.

Notes for reviewers (optional)

~/.config/apache-magpie/ still holds other tool secrets (TypeSafe / JEV keys, anthropic-api.json, the Nexus netrc, the PII map) that this PR leaves readable, as upstream did; moving those is a follow-up. docs/rfcs/RFC-AI-0002.md still lists the Google hosts; left as the historical design record.

🤖 Generated with Claude Code

The template made ~/.config/apache-magpie/ sandbox-readable and allowed
oauth2/gmail.googleapis.com, so any unprompted sandboxed command could
use the user's Gmail token. This contradicts the threat model (assumption
4, scenario X3). Drop all three, make sandbox-lint refuse the token path
in allowRead, and have isolated-setup-update flag the old entries as a
must-fix. Drafting goes through the oauth-draft MCP server, which runs
outside the sandbox.

Generated-by: Claude Opus 5
With the token no longer readable from the sandbox, a skill shelling out
to oauth-draft-create (or probing the token with test -f) always fails.
Call mcp__gmail-plaintext__check_auth / create_draft instead; the tool
takes the same to/cc/subject/body/thread_id inputs. The security_cc
recipe test now exercises the MCP recipe.

Generated-by: Claude Opus 5
@github-actions github-actions Bot added family:security security-* skills family:setup setup-* skills family:tools tools/* family:docs Docs, MISSION.md, READMEs capability:intake Import external signal + sync tracker state capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) contract:mail-archive Tool capability: mailing-list / forum archive reads contract:mail-source Tool capability: inbound-mail ingestion (mbox / IMAP / ...) contract:mail-create Tool capability: outbound mail composition (editable draft; sending is a separate human step) substrate:sandbox Tool substrate: agent isolation, egress control, settings audit labels Oct 17, 2026
@potiuk
potiuk merged commit 93051d5 into apache:main Oct 17, 2026
14 checks passed
potiuk added a commit that referenced this pull request Oct 19, 2026
Hand-sync of tools/spec-loop/specs/ with the functionality that landed
between 43e4c6e and ccb53a3.

Specs changed:
- adapters: Gmail drafting through the gmail-plaintext MCP tools, not the
  CLI (93051d5, #1681); the Jira CLI's explicit --deployment and the
  tracker backends shipped as generated plugin copies (1cf5cee, #1683);
  local-tracker report files and folders created 0600 / 0700 (68ec4a3,
  #1700).
- agent-isolation-sandbox: agent-guard unwrapping env / command and
  refusing env -S (b00d4b5, #1691; 4aea234, #1694); the macOS touch
  overlay shown whether or not activation is granted (0d9c168, #1697);
  the sandbox-lint workflow refusing a tracked .claude/settings.local.json
  (51a610b, #1692) and sandbox-lint refusing the Gmail token path in
  allowRead (93051d5, #1681).
- vetted-command-surface: the spelling guard refusing a quoted ~, the right
  spelling behind env / command, and other spellings of the eval wrapper
  (b00d4b5, #1691).
- adoption-and-setup: the tracker-backend question on every first setup
  and the Jira label mapping and doctor gate (1cf5cee, #1683).
- .last-sync bumped to ccb53a3.

No spec change needed (specs already updated in the commit itself):
ccb53a3, 9a8ec5f, 9955d7d, c9f34cc, 76cc6e8, 1d773a8,
16014a2.

No functional change for the specs: d4b7dc3 (review-body wording),
77e8145 (test timing), 8d606d6 (eval fixtures), a04891f (the
previous sync).

Generated-by: Claude Opus 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capability:intake Import external signal + sync tracker state capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) contract:mail-archive Tool capability: mailing-list / forum archive reads contract:mail-create Tool capability: outbound mail composition (editable draft; sending is a separate human step) contract:mail-source Tool capability: inbound-mail ingestion (mbox / IMAP / ...) family:docs Docs, MISSION.md, READMEs family:security security-* skills family:setup setup-* skills family:tools tools/* substrate:sandbox Tool substrate: agent isolation, egress control, settings audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant