Skip to content

Bound OpenAI Codex auth JSON responses - #55254

Open
ooiuuii wants to merge 1 commit into
NousResearch:mainfrom
ooiuuii:fix/codex-auth-json-cap
Open

Bound OpenAI Codex auth JSON responses#55254
ooiuuii wants to merge 1 commit into
NousResearch:mainfrom
ooiuuii:fix/codex-auth-json-cap

Conversation

@ooiuuii

@ooiuuii ooiuuii commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a streamed bounded JSON reader for OpenAI Codex device-code auth responses
  • route CLI device-code creation, auth polling, and token exchange through the bounded reader
  • route the dashboard Codex full-login worker through the same bounded reader
  • preserve existing 429/non-200 status handling while capping successful JSON bodies at 1 MiB
  • add regression tests for oversized JSON at all three CLI stages plus the dashboard entry point

Fixes #55253.

Validation

  • PYTHONPATH=$PWD C:\Users\Administrator\Documents\Codex\2026-06-29\hermes-main-latest-scan\.venv\Scripts\python.exe -m pytest tests\hermes_cli\test_auth_codex_provider.py tests\hermes_cli\test_web_oauth_dispatch.py -q --basetemp .pytest-tmp-codex-auth-json-web -> 61 passed
  • PYTHONPATH=$PWD C:\Users\Administrator\Documents\Codex\2026-06-29\hermes-main-latest-scan\.venv\Scripts\python.exe -m ruff check hermes_cli\auth.py hermes_cli\web_server.py tests\hermes_cli\test_auth_codex_provider.py tests\hermes_cli\test_web_oauth_dispatch.py -> passed
  • git diff --check -> passed

Notes

This is separate from #54750, which bounds hermes_cli.copilot_auth. This PR covers the openai-codex device-code flow in both hermes_cli.auth and the dashboard login worker in hermes_cli.web_server.

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard area/auth Authentication, OAuth, credential pools provider/openai OpenAI / Codex Responses API P3 Low — cosmetic, nice to have labels Jun 29, 2026
@ooiuuii
ooiuuii force-pushed the fix/codex-auth-json-cap branch from 114d21b to a3ed1a1 Compare June 29, 2026 23:18

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review Summary

Verdict: LGTM

Good security hardening — bounds OpenAI Codex auth JSON response reads to prevent memory exhaustion. The _read_codex_auth_json_response helper with iter_bytes and max_bytes check follows the established pattern. Clean dataclass extraction for the response type.

Security: Limits auth JSON responses to prevent oversized upstream responses.
Code Quality: Well-structured with proper error codes and AuthError wrapping.


Reviewed by Hermes Agent

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review Summary

Verdict: LGTM

Adds streamed bounded JSON reader for OpenAI Codex device-code auth responses. Routes CLI device-code creation, auth polling, and token exchange through the bounded reader.

  • Clean streaming pattern with size enforcement
  • Well-scoped: 4 files, 256 additions

Reviewed 4 files, 256 additions. Approved.

@teknium1 teknium1 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.

Thanks for the focused hardening work. The device-code and dashboard premise still holds on current main: those flows eagerly use post() followed by .json() in hermes_cli/auth.py:7284-7439 and hermes_cli/web_server.py:9277-9345.

Problems

  • refresh_codex_oauth_pure() is another Codex OAuth token-endpoint path, but remains unbounded at hermes_cli/auth.py:3450; it parses non-200 and successful JSON at :3489 and :3531.
  • The dashboard context has changed since the PR base. Current hermes_cli/web_server.py:9283 passes start failures to _codex_device_code_start_error(), which reads resp.json()/resp.text at :9203-9226. The submitted wrapper retains neither a non-200 payload nor those response methods, so salvage must preserve the current dashboard-specific authorization guidance.

Suggested changes

  • Cover the refresh-token response path with the same bounded-reader approach while retaining its 429 and structured-error behavior.
  • Integrate the dashboard change with the current bounded error-detail path and retain the existing device-authorization guidance test.

Automated hermes-sweeper review.

Comment thread hermes_cli/web_server.py
)
issuer = "https://auth.openai.com"

# Step 1: request device code
with httpx.Client(timeout=httpx.Timeout(15.0)) as client:
resp = client.post(
resp = _post_codex_auth_json(

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.

When salvaging this onto current main, preserve the non-200 response detail consumed by _codex_device_code_start_error() (hermes_cli/web_server.py:9203-9248). Current main invokes that helper for this response, while _CodexAuthJsonResponse retains only status, headers, and a 200-only payload.

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
@ooiuuii
ooiuuii force-pushed the fix/codex-auth-json-cap branch from a3ed1a1 to ca6e551 Compare August 12, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have provider/openai OpenAI / Codex Responses API sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bound OpenAI Codex auth JSON responses

4 participants