openclaw - 💡(How to fix) Fix Bug: OAuth token exchange silently proceeds without client_secret + hardcoded redirect port [1 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#54299Fetched 2026-04-08 01:29:20
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

Two OAuth-related issues:

Error Message

  1. Throw error or log warning when clientSecret is missing (if confidential client mode is intended)

Root Cause

Two OAuth-related issues:

Code Example

if (clientSecret) body.set("client_secret", clientSecret);
RAW_BUFFERClick to expand / collapse

Summary

Two OAuth-related issues:

1. Silent client_secret omission (dist/oauth.token-BMfn_2Ia.js:15)

The OAuth token exchange conditionally includes client_secret:

if (clientSecret) body.set("client_secret", clientSecret);

This allows the OAuth flow to silently proceed without a client secret, downgrading from confidential to public client type without warning.

2. Hardcoded redirect port (dist/oauth.shared-DO38OCyK.js:4)

OAuth redirect URI is hardcoded to http://localhost:8085/oauth2callback. Fails if port is already occupied.

Impact

  1. An attacker who unsets GOOGLE_CLIENT_SECRET forces public client mode with weaker token security
  2. OAuth flow fails when port 8085 is occupied by another service

Suggested Fix

  1. Throw error or log warning when clientSecret is missing (if confidential client mode is intended)
  2. Make redirect port configurable via env var, or use dynamic port with server.listen(0)

extent analysis

Fix Plan

To address the OAuth-related issues, we will implement the following fixes:

  • Enforce Client Secret: Modify the code to throw an error or log a warning when clientSecret is missing.
  • Dynamic Redirect Port: Make the redirect port configurable via an environment variable or use a dynamic port.

Step-by-Step Solution

Enforce Client Secret

if (!clientSecret) {
  throw new Error("Client secret is required for confidential client mode");
}
body.set("client_secret", clientSecret);

Dynamic Redirect Port

const redirectPort = process.env.OAUTH_REDIRECT_PORT || 8085;
const redirectUri = `http://localhost:${redirectPort}/oauth2callback`;

Alternatively, use a dynamic port with server.listen(0):

const server = app.listen(0, () => {
  const port = server.address().port;
  const redirectUri = `http://localhost:${port}/oauth2callback`;
  // ...
});

Verification

To verify the fixes, test the OAuth flow with and without a client secret set. Additionally, test the redirect port configuration by setting the OAUTH_REDIRECT_PORT environment variable to a different value.

Extra Tips

  • Consider logging a warning or throwing an error when the client secret is missing to prevent accidental downgrades to public client mode.
  • Use environment variables to configure sensitive values like client secrets and redirect ports.
  • Implement additional security measures, such as validating the redirect URI and handling errors during the OAuth flow.

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

openclaw - 💡(How to fix) Fix Bug: OAuth token exchange silently proceeds without client_secret + hardcoded redirect port [1 participants]