Repository navigation
feat(openai): add codex device-code auth and fix login options in menu - #69557
Conversation
eff06c2 to
aedf7db
Compare
Greptile SummaryThis PR adds a
Confidence Score: 4/5Safe to merge after confirming the CHANGELOG beta-section removal is intentional and the orphaned fixes are accounted for. All new device-code logic is well-implemented with proper error handling, PKCE, and timeouts; tests cover the happy path and failure cases. The only blocking concern before merge is the CHANGELOG edit that deletes 4 documented bug fixes and orphans another fixes block. CHANGELOG.md — verify the beta.2 and beta.1 section removals are intentional and that the 4 deleted fixes are tracked elsewhere.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aedf7dbee3
ℹ️ 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".
🔒 Aisle Security AnalysisWe found 4 potential security issue(s) in this PR:
1. 🟡 Unbounded `response.text()` reads from auth server can cause memory/CPU exhaustion (device-code flow)
DescriptionIn the device-code login implementation, error and success responses are always read using
Vulnerable code (example instance): const bodyText = await response.text();RecommendationImplement a bounded body reader and truncate/abort when the response exceeds a reasonable limit (e.g., 64KB) before converting to text. Example (bounded read): async function readTextWithLimit(res: Response, limitBytes = 64 * 1024): Promise<string> {
const reader = res.body?.getReader();
if (!reader) return "";
const chunks: Uint8Array[] = [];
let total = 0;
while (true) {
const { value, done } = await reader.read();
if (done) break;
if (!value) continue;
total += value.byteLength;
if (total > limitBytes) {
throw new Error(`Response body too large (>${limitBytes} bytes)`);
}
chunks.push(value);
}
return new TextDecoder().decode(Buffer.concat(chunks));
}
// usage
const bodyText = await readTextWithLimit(response);Alternatively, check 2. 🟡 Server response body reflected into errors during OpenAI Codex device-code flow (potential secret/code leakage to logs)
DescriptionThe device-code login flow builds While control/ANSI characters are stripped, the error formatter does not truncate or strictly whitelist fields, and the global redaction patterns do not cover device-code specific sensitive fields like Vulnerable code paths:
RecommendationAvoid reflecting arbitrary response bodies into thrown/logged error messages. Recommended mitigations (use one or combine):
const body = parseJsonObject(params.bodyText);
const safe = trimNonEmptyString(body?.error) ?? "request_failed";
return `${params.prefix}: HTTP ${params.status} ${sanitizeDeviceCodeErrorText(safe)}`;
3. 🟡 Terminal escape/ANSI injection via unsanitized device-code values displayed to user
DescriptionThe device-code login flow prints
Impact depends on the terminal/UI, but can include:
Vulnerable code: `URL: ${verificationUrl}`,
... `Code: ${userCode}`
...
ctx.runtime.log(`\nOpen this URL...\n\n${verificationUrl}\n`);RecommendationNeutralize control characters before rendering untrusted strings to terminals/UI. Options:
function assertSafeUserCode(code: string): string {
if (!/^[A-Z0-9-]+$/.test(code)) {
throw new Error("Unexpected device user code format");
}
return code;
}
const safeUrl = sanitizeDeviceCodeErrorText(verificationUrl);
const safeCode = ctx.isRemote ? "[shown on the local device only]" : sanitizeDeviceCodeErrorText(userCode);
await ctx.prompter.note(`URL: ${safeUrl}\nCode: ${safeCode}`, ...);
ctx.runtime.log(`Open: ${safeUrl}`);Also consider rejecting/stripping newlines specifically to prevent log forging ( 4. 🔵 Incomplete output neutralization: bidi/unicode control characters can spoof CLI/log output in reflected device-code errors
DescriptionDevice-code error messages include text derived from remote HTTP responses (
Relevant code: return value
.replace(osc8Regex, "")
.replace(ansiCsiRegex, "")
.replace(controlCharsRegex, " ")
.replace(/\s+/g, " ")
.trim();Bidi controls are not in the C0/C1 ranges and therefore pass through unchanged. RecommendationExtend sanitization to strip Unicode bidi and other non-printing formatting characters before including network-provided text in errors/logs. Example: const bidiAndFormatControls = /[\u200E\u200F\u202A-\u202E\u2066-\u2069\u061C\u200B-\u200D\uFEFF]/g;
function sanitizeDeviceCodeErrorText(value: string): string {
// existing ESC/control stripping...
return value
.replace(osc8Regex, "")
.replace(ansiCsiRegex, "")
.replace(controlCharsRegex, " ")
.replace(bidiAndFormatControls, "")
.replace(/\s+/g, " ")
.trim();
}Additionally consider truncating sanitized output to a maximum length to avoid excessive log/terminal output even when bounded reads are in place. Analyzed PR: #69557 at commit Last updated on: 2026-04-22T07:49:05Z |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33d4e77eef
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33d993a403
ℹ️ 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".
| if (typeof value === "string" && /^\d+$/.test(value.trim())) { | ||
| return Number.parseInt(value.trim(), 10) * 1000; | ||
| } |
There was a problem hiding this comment.
Reject non-positive string token lifetimes
normalizeTokenLifetimeMs treats numeric expires_in values as valid only when they are > 0, but string values like "0" are currently accepted and converted to 0ms. If the token endpoint serializes expires_in as a string (the same flow already handles string-typed timing fields), this marks the credential expired immediately (Date.now() + 0) and can force unnecessary refresh/failure paths instead of falling back to JWT exp.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b0576ba8f
ℹ️ 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".
| const fetchFn = params.fetchFn ?? fetch; | ||
|
|
||
| params.onProgress?.("Requesting device code…"); | ||
| const deviceCode = await requestOpenAICodexDeviceCode(fetchFn); |
There was a problem hiding this comment.
Bootstrap proxy dispatcher before device-code network calls
This flow defaults to global fetch without calling ensureGlobalUndiciEnvProxyDispatcher, unlike the existing Codex browser OAuth path (src/plugins/provider-openai-codex-oauth.ts). In environments that require HTTPS_PROXY/HTTP_PROXY, device-code login can fail to reach auth.openai.com even though browser OAuth works, so users behind corporate proxies lose the new auth method entirely.
Useful? React with 👍 / 👎.
| email: identity.email, | ||
| profileName: identity.profileName, |
There was a problem hiding this comment.
Derive a stable profile key for device-code credentials
The device-code path passes through identity.profileName directly; when the token lacks email/user-subject claims, buildOauthProviderAuthResult falls back to openai-codex:default. The new tests model tokens that only include chatgpt_account_id, so pairing a second ChatGPT account can silently overwrite the first account’s default Codex profile instead of creating a distinct profile.
Useful? React with 👍 / 👎.
3b0576b to
4918ed6
Compare
|
Merged via squash.
Thanks @vincentkoc! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4918ed69f1
ℹ️ 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".
| const codeLine = ctx.isRemote | ||
| ? "Code: [shown on the local device only]" | ||
| : `Code: ${userCode}`; |
There was a problem hiding this comment.
Surface device pairing code in remote auth flow
When ctx.isRemote is true, this branch replaces the real userCode with a placeholder, and the remote log path later prints only the URL. Because the verification URL is a fixed page (.../codex/device) rather than a code-bearing link, remote/SSH users never see the code they must enter, so device-code login cannot complete in the callback-hostile environments this feature is meant to support.
Useful? React with 👍 / 👎.
openclaw#69557) Merged via squash. Prepared head SHA: 4918ed6 Co-authored-by: vincentkoc <[email protected]> Co-authored-by: BunsDev <[email protected]> Reviewed-by: @BunsDev
openclaw#69557) Merged via squash. Prepared head SHA: 4918ed6 Co-authored-by: vincentkoc <[email protected]> Co-authored-by: BunsDev <[email protected]> Reviewed-by: @BunsDev
openclaw#69557) Merged via squash. Prepared head SHA: 4918ed6 Co-authored-by: vincentkoc <[email protected]> Co-authored-by: BunsDev <[email protected]> Reviewed-by: @BunsDev
openclaw#69557) Merged via squash. Prepared head SHA: 4918ed6 Co-authored-by: vincentkoc <[email protected]> Co-authored-by: BunsDev <[email protected]> Reviewed-by: @BunsDev
openclaw#69557) Merged via squash. Prepared head SHA: 4918ed6 Co-authored-by: vincentkoc <[email protected]> Co-authored-by: BunsDev <[email protected]> Reviewed-by: @BunsDev
openclaw#69557) Merged via squash. Prepared head SHA: 4918ed6 Co-authored-by: vincentkoc <[email protected]> Co-authored-by: BunsDev <[email protected]> Reviewed-by: @BunsDev
openclaw#69557) Merged via squash. Prepared head SHA: 4918ed6 Co-authored-by: vincentkoc <[email protected]> Co-authored-by: BunsDev <[email protected]> Reviewed-by: @BunsDev
openclaw#69557) Merged via squash. Prepared head SHA: 4918ed6 Co-authored-by: vincentkoc <[email protected]> Co-authored-by: BunsDev <[email protected]> Reviewed-by: @BunsDev
openclaw#69557) Merged via squash. Prepared head SHA: 4918ed6 Co-authored-by: vincentkoc <[email protected]> Co-authored-by: BunsDev <[email protected]> Reviewed-by: @BunsDev
what changed
device-codeauth path for the bundledopenai-codexprovider~/GIT/_Perso/codex, including OpenAI device-code polling and token exchange/backend-api/codexbase URLwhy
impact
openai-codexvalidation
pnpm test:extension openaipnpm build(fails in unrelatedruntime-postbuildDiscord runtime-deps staging:discord-api-typesresolves as^0.38.47instead of an exact installed version)