Skip to content

fix(gmail): keep gmail watch secrets out of process argv - #92527

Closed
jml001 wants to merge 1 commit into
openclaw:mainfrom
jml001:pr/gmail-watch-secrets-argv
Closed

jml001 wants to merge 1 commit into
openclaw:mainfrom
jml001:pr/gmail-watch-secrets-argv

Conversation

@jml001

@jml001 jml001 commented Jun 12, 2026

Copy link
Copy Markdown

Summary

The gmail watcher launched gog watch serve with the push token passed via --token and the hook token embedded in --hook-url, exposing both to any local process via ps/procfs for the lifetime of the watcher. The watcher now writes both secrets to private secret files and passes file paths on argv instead.

Real behavior proof

Behavior addressed: gmail watch push/hook tokens visible in process listings on any multi-process host.
Real environment tested: production single-operator OpenClaw gateway (Ubuntu, Node 22.22), patch live since 2026-06-12.
Exact steps or command run after this patch: ps -ef | grep "gog watch serve" on the live gateway with the gmail hook active.
Evidence after fix: no token material in the watcher argv; tokens resolved from secret files.
Observed result after fix: gmail watch connects and delivers push notifications normally.
What was not tested: Windows/macOS service-manager spawn paths.

Verification

  • Unit tests added in the same commit assert built args carry file paths and never raw tokens: src/hooks/gmail-watcher.test.ts, src/hooks/gmail.test.ts.
  • Running in production on a patched 2026.6.6 build since 2026-06-12.

🤖 Generated with Claude Code

(cherry picked from commit 785d606a365c8cb1b764990f4421f46b42db5d4e)
@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 12, 2026
@clawsweeper

clawsweeper Bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 30, 2026, 8:32 PM ET / 00:32 UTC.

Summary
This PR writes Gmail watcher push and hook tokens to temporary files for the gateway auto-start path and passes new file-path flags to gog gmail watch serve, with unit tests for the argv shape.

PR surface: Source +56, Tests +55. Total +111 across 4 files.

Reproducibility: yes. at source level. Current main and v2026.6.11 build gog gmail watch serve argv with the configured Gmail push and hook tokens, but I did not run a live Gmail watcher in this read-only review.

Review metrics: 2 noteworthy metrics.

  • External gog flags: 2 added. The PR starts passing new gog gmail watch serve flags, so dependency compatibility must be settled before merge.
  • Temporary secret files: 2 created per watcher spawn. The new security boundary depends on lifecycle-safe cleanup for both plaintext token files.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add or release compatible gogcli file-secret flags and gate OpenClaw on that version or capability.
  • Route the foreground Gmail runner through the same secret-safe path and make temporary-file cleanup failure-safe.
  • [P1] Add inspectable redacted proof showing token-free argv and continued Gmail delivery after this exact patch.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body describes a live Ubuntu check, but it does not include inspectable redacted terminal output, logs, screenshots, recordings, or a linked artifact showing token-free argv and continued Gmail delivery after this patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Existing installations can lose Gmail push delivery because this PR invokes gog gmail watch serve flags that gogcli v0.31.1 and current gogcli main do not expose.
  • [P1] The documented openclaw webhooks gmail run path remains on the raw-token argv builder path, so the security fix is one-sided.
  • [P1] The new plaintext token files can survive create/write/invocation-resolution or parent-process failure paths that do not reach the current child error or exit cleanup.
  • [P1] The PR body describes live Ubuntu testing, but no inspectable redacted terminal output, logs, screenshot, recording, or linked artifact shows token-free argv and continued Gmail delivery after this exact patch.

Maintainer options:

  1. Ship and gate gogcli support before switching argv (recommended)
    Add and release --token-file and --hook-token-file in gogcli, then make OpenClaw require or detect that compatible gogcli before emitting those flags.
  2. Keep supported gog flags while narrowing the security fix
    Preserve the current gogcli argv contract until dependency support exists, and land only mitigations that do not stop existing watcher startup.
  3. Pause until the security scope is complete
    Hold or close this branch if maintainers want the secret-argv fix to arrive only with dependency release coordination, foreground-runner coverage, cleanup coverage, and real proof in one replacement PR.

Next step before merge

  • [P1] This should stay human-owned because the blockers span gogcli dependency coordination, security-boundary scope, and contributor real-environment proof rather than a safe one-branch automated repair.

Security
Needs attention: The diff improves one secret-argv path, but concrete dependency, cleanup, and sibling foreground-runner security concerns remain.

Review findings

  • [P1] Gate file-secret flags on a compatible gogcli — src/hooks/gmail.ts:255-262
  • [P2] Clean token files across every startup failure — src/hooks/gmail-watcher.ts:54-55
  • [P2] Protect the foreground Gmail runner too — src/hooks/gmail.ts:258-264
Review details

Best possible solution:

Coordinate and release compatible gogcli file-secret support first, gate OpenClaw on that capability or version, then share a cleanup-safe secret-file handoff across both gateway auto-start and foreground Gmail runner paths with inspectable redacted proof.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level. Current main and v2026.6.11 build gog gmail watch serve argv with the configured Gmail push and hook tokens, but I did not run a live Gmail watcher in this read-only review.

Is this the best way to solve the issue?

No. File-backed secrets are the right direction, but this is not the best mergeable fix until the gogcli contract exists, both runner paths are covered, cleanup is failure-safe, and the contributor adds inspectable proof.

Full review comments:

  • [P1] Gate file-secret flags on a compatible gogcli — src/hooks/gmail.ts:255-262
    buildGogWatchServeArgs now emits --token-file and --hook-token-file, but gogcli v0.31.1 and current gogcli main define only --token, --hook-url, and --hook-token. Existing installs can reject the unknown flags and stop Gmail watcher delivery unless gogcli support ships and OpenClaw gates on a compatible version or capability.
    Confidence: 0.95
  • [P2] Clean token files across every startup failure — src/hooks/gmail-watcher.ts:54-55
    createGogServeSecretFiles writes plaintext token files before a cleanup owner is guaranteed for the whole setup path. If the second write, invocation resolution, or a parent-process failure happens before the child emits error or exit, credentials can remain in the temp directory.
    Confidence: 0.88
  • [P2] Protect the foreground Gmail runner too — src/hooks/gmail.ts:258-264
    The fallback raw-token branch remains reachable because openclaw webhooks gmail run calls this builder without secret files. That documented foreground path can still expose the configured push and hook tokens in child process argv after this PR.
    Confidence: 0.87

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1289abddcb96.

Label changes

Label justifications:

  • P1: The PR affects a live Gmail watcher workflow and a concrete credential exposure in a process boundary.
  • merge-risk: 🚨 compatibility: The diff changes the external gogcli flag contract used by existing installations without a compatible released dependency gate.
  • merge-risk: 🚨 message-delivery: If gog rejects the new file-secret flags, Gmail Pub/Sub push delivery into OpenClaw can stop.
  • merge-risk: 🚨 security-boundary: The patch changes how Gmail hook and push token secrets are transferred to a child process and stored temporarily.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body describes a live Ubuntu check, but it does not include inspectable redacted terminal output, logs, screenshots, recordings, or a linked artifact showing token-free argv and continued Gmail delivery after this patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +56, Tests +55. Total +111 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 70 14 +56
Tests 2 66 11 +55
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 136 25 +111

Security concerns:

  • [medium] Foreground runner still exposes Gmail secrets — src/hooks/gmail.ts:258
    The PR updates the gateway auto-start path only; the documented openclaw webhooks gmail run path still calls the shared serve-arg builder without secret files, leaving configured push and hook tokens in child process argv.
    Confidence: 0.87
  • [medium] Temporary token files can outlive failed startup — src/hooks/gmail-watcher.ts:54
    The new helper writes plaintext token files before cleanup is guaranteed across all create, write, invocation-resolution, spawn, child-event, and parent-shutdown paths.
    Confidence: 0.88

What I checked:

  • Root policy read: Root AGENTS.md was read fully; its dependency-contract, security-boundary, sibling-surface, proof, and compatibility guidance applies because this PR changes external CLI invocation and secret handling. (AGENTS.md:8, 1289abddcb96)
  • Current main still exposes raw watcher tokens: Current main builds gog gmail watch serve argv with --token, cfg.pushToken, --hook-url, --hook-token, and cfg.hookToken, so the reported argv exposure is source-reproducible and not already implemented on main. (src/hooks/gmail.ts:234, 1289abddcb96)
  • Latest release still has raw-token argv: Release v2026.6.11 contains the same raw-token buildGogWatchServeArgs() shape, so this is not already fixed in the latest stable release. (src/hooks/gmail.ts:234, e085fa1a3ffd)
  • PR adds file-secret gog flags: The PR branch appends --token-file and --hook-token-file when secret-file paths are supplied. (src/hooks/gmail.ts:255, 558041b3c009)
  • gogcli dependency lacks the new flags: gogcli v0.31.1 defines --token, --hook-url, and --hook-token for GmailWatchServeCmd, but no --token-file or --hook-token-file; code search for those flag names returned zero matches. (openclaw/gogcli:internal/cmd/gmail_watch_cmds.go:220, 608aa46e7b9c)
  • Foreground runner remains on raw-token builder path: The documented openclaw webhooks gmail run path still calls buildGogWatchServeArgs(cfg) without secret files, so it would continue exposing configured Gmail push and hook tokens in child process argv. (src/hooks/gmail-ops.ts:361, 1289abddcb96)

Likely related people:

  • steipete: GitHub commit history shows this account introduced the Gmail hooks wizard and repeatedly maintained the shared Gmail helper surface that builds watcher args. (role: introduced behavior; confidence: high; commits: 523d9ec3c2e4, 4c3b4f8ad8f8; files: src/hooks/gmail.ts, src/hooks/gmail-ops.ts, src/hooks/gmail.test.ts)
  • eleqtrizit: Merged PR history shows this account changed Gmail watcher startup argument redaction across the same helper and watcher area. (role: recent adjacent contributor; confidence: high; commits: 851294126b30; files: src/hooks/gmail.ts, src/hooks/gmail-watcher.ts, src/hooks/gmail-ops.ts)
  • vincentkoc: Recent GitHub commit history shows this account changed the Gmail serve invocation path for Windows gog command wrapping. (role: recent adjacent contributor; confidence: medium; commits: 5e7bb9cf9b4d; files: src/hooks/gmail.ts, src/hooks/gmail.windows.test.ts)
  • samzong: GitHub commit history shows this account recently worked on Gmail watcher restart and abort handling in the same runtime path. (role: gateway watcher maintainer; confidence: medium; commits: 2fa853dce5ca; files: src/hooks/gmail-watcher.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

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-review comments, 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-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to 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 explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-06-21T20:22:35.926Z sha 558041b :: needs real behavior proof before merge. :: [P1] Gate file-secret flags on a compatible gogcli | [P2] Clean secret files on every setup and stop failure | [P2] Protect the foreground Gmail runner too

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 558041b3c0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/hooks/gmail.ts
cfg.hookToken,
];
if (secretFiles.pushTokenFile) {
args.push("--token-file", secretFiles.pushTokenFile);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep watcher argv compatible with gog serve

When the gateway auto-starts Gmail watching, this branch now passes --token-file (and the paired --hook-token-file just below) to gog gmail watch serve. I checked gogcli's generated command docs for gog gmail settings watch serve (https://gogcli.sh/commands/gog-gmail-settings-watch-serve.html), and the supported flags include --token, --hook-url, and --hook-token, but not these *-file flags; the local setup path also only ensures a gog binary exists, not a minimum version with these new options. On existing installations with the documented/current gog CLI, Gmail watcher startup will fail immediately with an unknown flag instead of serving pushes, so the secret-file handoff needs to be implemented only after verifying/supporting the gog contract (or kept on supported flags).

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 12, 2026
@jml001

jml001 commented Jun 12, 2026

Copy link
Copy Markdown
Author

Withdrawing.

@jml001 jml001 closed this Jun 12, 2026
@jml001
jml001 deleted the pr/gmail-watch-secrets-argv branch June 12, 2026 20:03
@jml001

jml001 commented Jun 12, 2026

Copy link
Copy Markdown
Author

Reopening - the withdrawal was on our side, the patches stand.

@jml001
jml001 restored the pr/gmail-watch-secrets-argv branch June 12, 2026 20:15
@jml001 jml001 reopened this Jun 12, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 12, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 21, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant