openclaw - 💡(How to fix) Fix Security: Unauthorized OAuth credential extraction from Gemini CLI installation [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#54289Fetched 2026-04-08 01:29:34
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
1
Timeline (top)
commented ×1

extractGeminiCliCredentials() searches the filesystem for Google Gemini CLI installations, locates oauth2.js source files, and extracts OAuth client ID and secret using hardcoded regex patterns. These credentials are cached globally and used as fallback in resolveOAuthClientConfig() when environment variables are not set — all without explicit user consent.

// Regex patterns used to extract credentials
/(\d+-[a-z0-9]+\.apps\.googleusercontent\.com)/
/(GOCSPX-[A-Za-z0-9_-]+)/

Root Cause

extractGeminiCliCredentials() searches the filesystem for Google Gemini CLI installations, locates oauth2.js source files, and extracts OAuth client ID and secret using hardcoded regex patterns. These credentials are cached globally and used as fallback in resolveOAuthClientConfig() when environment variables are not set — all without explicit user consent.

// Regex patterns used to extract credentials
/(\d+-[a-z0-9]+\.apps\.googleusercontent\.com)/
/(GOCSPX-[A-Za-z0-9_-]+)/

Code Example

// Regex patterns used to extract credentials
/(\d+-[a-z0-9]+\.apps\.googleusercontent\.com)/
/(GOCSPX-[A-Za-z0-9_-]+)/
RAW_BUFFERClick to expand / collapse

Summary

extractGeminiCliCredentials() searches the filesystem for Google Gemini CLI installations, locates oauth2.js source files, and extracts OAuth client ID and secret using hardcoded regex patterns. These credentials are cached globally and used as fallback in resolveOAuthClientConfig() when environment variables are not set — all without explicit user consent.

// Regex patterns used to extract credentials
/(\d+-[a-z0-9]+\.apps\.googleusercontent\.com)/
/(GOCSPX-[A-Za-z0-9_-]+)/

Impact

  • Unauthorized credential harvesting from another application
  • Extracted OAuth secrets could forge authentication tokens or impersonate users on Google Cloud services
  • Violates principle of least privilege
  • Cached in cachedGeminiCliCredentials for session lifetime

Reproduction

  1. Install Google Gemini CLI on the system
  2. Run OpenClaw without setting GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET
  3. OpenClaw automatically extracts and uses Gemini CLI OAuth credentials from its source files

Location

dist/oauth.credentials-CklT1CJA.js:28-56, 107-116

Suggested Fix

Remove automatic credential extraction from external tools. Require explicit configuration of OAuth credentials via environment variables or config files only. At minimum, display a warning and require user confirmation.

extent analysis

Fix Plan

To address the issue, we will:

  • Remove the automatic credential extraction from external tools
  • Require explicit configuration of OAuth credentials via environment variables or config files
  • Display a warning and require user confirmation when using OAuth credentials

Code Changes

We will update the extractGeminiCliCredentials() function to remove the hardcoded regex patterns and instead throw an error if the credentials are not provided via environment variables or config files.

// Remove the regex patterns and throw an error if credentials are not provided
function extractGeminiCliCredentials() {
  if (!process.env.GOOGLE_CLIENT_ID || !process.env.GOOGLE_CLIENT_SECRET) {
    throw new Error('OAuth credentials not provided. Please set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET environment variables or configure via a config file.');
  }
  // Return the credentials from environment variables or config files
  return {
    clientId: process.env.GOOGLE_CLIENT_ID,
    clientSecret: process.env.GOOGLE_CLIENT_SECRET,
  };
}

Configuration Changes

We will add a warning message to inform the user that OAuth credentials are required and must be provided explicitly.

// Display a warning message to the user
console.warn('OAuth credentials are required and must be provided explicitly via environment variables or config files.');

Verification

To verify the fix, we will:

  • Run the application without setting the GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET environment variables
  • Verify that the application throws an error and displays a warning message
  • Set the environment variables or configure via a config file and verify that the application uses the provided credentials correctly

Extra Tips

  • Always prioritize explicit user consent when handling sensitive information like OAuth credentials
  • Use secure methods to store and manage credentials, such as encrypted config files or secure environment variable storage
  • Regularly review and update dependencies to ensure the latest security patches and best practices are applied.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING