Skip to content

fix(cursor): keep usage cookies on the resolved account - #25243

Merged
nwparker merged 2 commits into
mainfrom
nwparker/cursor-quota-23612-main538-1004
Oct 4, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/cursor-quota-23612-main538-1004

Conversation

@nwparker

@nwparker nwparker commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​400 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​400
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2

ELI5

Cursor quota should belong to the account Orca resolved. Electron's existing cookie jar could replace that account's Cookie and return another account's allowance or an expired-sign-in error.

What Changed

Set credentials: 'omit' on the existing shared dashboard request so Electron uses the supplied selected-account Cookie and ignores response cookies. Both the summary and legacy endpoints use this option. Account discovery, CSRF headers, expiry checks, timeout, failure classification and redirect blocking stay in the existing implementation.

Add a real Electron HTTP/HTTPS regression covering selected-account isolation, empty jars, token replacement, concurrent accounts, response-cookie isolation, both endpoints, failures and blocked redirects. The fixture reuses the supported native probe launcher and records child/fixture diagnostics.

Why

With A in Electron's jar, selecting B previously returned A's 25% allowance; the fix returns B's 75%. One request option solves that demonstrated ownership defect without global cookie writes, account races or a new session lifecycle.

The historic empty-jar 401 / populated-jar 200 report did not reproduce on installed Electron 43.7.5. This PR does not claim a real Cursor token was accepted or that every affected user's original sign-in problem is repaired.

Linked Issue

Refs #23612 — #23612

Credit @Li-Sanze's classification contribution in #23626, retained through merged #24575. @jjongsta and @chengjiaxiao's reports prompted the native session/header comparisons; the account-substitution finding here differs from the reported empty-jar outcome. Keep the original issue open.

Visual Proof

N/A — request transport only; no renderer or interaction changes. Native fixture servers record the synthetic account whose Cookie actually arrived.

Testing

  • I manually tested these changes locally against a real Cursor account
  • Automated tests added/updated

The exact full four-path patch applies without conflict to current main ddefd523e052cc83897937569d322a727f55dd78; local validation copy 4b83be1ab03407bfe1818ccf92f1d73a5307f3af has no unrelated changes. Published PR head remains 2303aef019304b4a6200d51872c5d5c6e2f98956.

On macOS arm64, Electron 43.7.5 / Chromium 150.0.7871.250:

  • Required full pnpm tc, focused new-fixture E2E typecheck, four-path format check, changed-code-quality gate and normal commit lint/format hooks pass on current main.
  • Affected runs: 9 selected suites / 65 tests pass, including actual native transport, Cursor fetcher/auth/token/service, default-session proxy audit/guard, native launch policy and home isolation.
  • Matched actual native controls: fixed B-selection returns B75%; removing only the production omit option in memory returns wrong A25%. Opposite-account controls reproduce the reverse error. Ten jar snapshots remain unchanged with the fix and change without it; empty jars send A in both arms.
  • An injected fixture error exits 1 and saves stage/stack diagnostics. The positive/native removal controls exit 0. All synthetic assertions pass.
  • Native HTTP Basic proxy and HTTPS CONNECT controls behave identically with and without omission: fresh challenges return 407, seeded proxy auth returns 200; origin challenges return 401. This matches pinned Electron fetch/loader source. Fresh proxy challenges are an existing fetch-adapter limitation; cached Basic proxy authentication still works.

Separate accepted independent validation on the pinned main snapshot: 11 suites / 112 tests passed, with node and focused fixture typechecks, changed-code-quality and format checks passing, plus actual HTTP proxy controls. These results overlap the author’s 9-suite / 65-test run and native controls above; do not sum them into a unique-test total or treat the independent HTTP controls as proof of additional platforms.

Published-head CI has 13 successful / 17 skipped checks. The named native Linux job checks out 5c668f88a171c6370759791c0aafb06a28dbcf71, merging this PR head into ea6a6d60774ac2b74bb6692d1798e3ab13b99ae0, and explicitly passes the Cursor credential-independence test. Hosted static/typechecks, all selected unit shards, relay integration, Linux packaging and Windows packaging pass; skips are not executions. This is historical published-head integration evidence, while the newer current-main snapshot has the local proof above.

The earlier f2c Linux exit 133 remains unexplained; successor-head named native acceptance passes without weaker assertions, retries or skips. Full local lint/build/all-tests were not repeated; broader published CI checks cover its explicit integration base.

No provider calls, login, paid-model requests, keychain reads or real credential/config access. Actual Windows native transport, live SSH, authenticated Cursor backend acceptance, other Electron versions and enterprise authentication schemes remain untested. Those gaps do not add a new platform/host/wire mechanism to this request-option change.

Review

The complete four-path independent review was accepted as CLEAR / Low merge risk for published head 2303aef019304b4a6200d51872c5d5c6e2f98956, validated as 4b83be1ab03407bfe1818ccf92f1d73a5307f3af on pinned main ddefd523e052cc83897937569d322a727f55dd78. This covers the production option and both native fixture/launcher-diagnostic paths, rather than only an earlier increment. Keep this PR draft; review acceptance does not authorize merging or issue closure.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer material copied.

Notes

Deliberate tradeoff: exclude automatic origin session authentication and response-cookie persistence; authenticate through the explicitly selected account token. The guarded default session still owns proxy routing. No provider selection, credential refresh, account cache, RPC/schema, SSH routing, UI, folder workspace, Git-provider, Cursor Chat/history or dependency changes.

The original empty-jar issue remains unresolved. This PR fixes a separately reproduced account ownership defect and does not authorize issue/predecessor closure, readiness changes or merging.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A with reason for visual proof
  • Self-reviewed for correctness, security, and performance
  • Cross-platform and SSH/remote impact considered; execution gaps documented
  • Required local full typechecks and focused checks pass; broader lint/typecheck/test/build coverage is supplied by successful published-head CI, with exact base limits above

@nwparker
nwparker marked this pull request as ready for review October 4, 2026 21:10
@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cad30fdf-fdf8-4f81-a747-4889821b772d
📥 Commits

Reviewing files that changed from the base of the PR and between ea6a6d6 and 2303aef.

📒 Files selected for processing (4)
  • src/main/rate-limits/cursor-fetcher.test.ts
  • src/main/rate-limits/cursor-fetcher.ts
  • tests/e2e/cursor-quota-transport.unit.test.ts
  • tests/e2e/helpers/cursor-quota-wire.fixture.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

Dashboard requests now omit Electron session-jar credentials and continue to send the selected account cookie in their headers. A new Electron integration test exercises quota transport over HTTP and HTTPS, including account and cookie combinations, parallel requests, legacy responses, and failure scenarios. It also checks cookie-jar state, request receipts, and cleanup.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 2303a

The change is ready for normal checks. No actionable merge-blocking issue was established, though the new test’s ability to catch a future removal of the credential option remains unverified.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 2303a

The change narrows credential use to the selected account and preserves redirect blocking. No introduced security defect was identified in the reviewed request path. Remaining uncertainty concerns real-provider compatibility and behavior outside the covered Electron transport scenarios.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated ownership issue concerns quota data for accounts available through the application’s selected session and Electron cookie jar. The reviewed change narrows that credential interaction; the supplied evidence does not establish service-wide or cross-tenant authority expansion.

Trust Boundaries and Controls

  • observed — The selected session supplies the request Cookie, and manual redirect handling prevents automatic forwarding to a redirect destination. The fixture preserves these production options when invoking native Electron fetch and asserts zero redirect-target hits.

Resilience and Maintainability Implications

  • observed — Fixture cleanup restores the fetch override and closes its servers before process exit; the parent removes the temporary profile directory. The certificate verifier is confined to the child process. Abrupt termination is not shown to execute JavaScript cleanup, so the evidence supports normal and handled-failure isolation rather than every interruption state.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: keeping Cursor usage cookies tied to the resolved account.
Description check ✅ Passed The description covers the required sections, explains the change and its limits, links the issue, gives visual-proof context, and documents testing and review. Automated tests are marked as updated, …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

✅ No new issues found.

Reviewed changes

  • credentials: 'omit' on the Cursor dashboard request — fetchDashboardJson in src/main/rate-limits/cursor-fetcher.ts now tells Electron to send only the explicitly supplied account Cookie instead of merging the session jar's cookie, so a stale/jar cookie can no longer substitute another account's allowance. Both /api/usage-summary and the legacy /api/usage fallback go through this helper.
  • Unit assertion — src/main/rate-limits/cursor-fetcher.test.ts pins init.credentials === 'omit'.
  • Real-transport regression — tests/e2e/cursor-quota-transport.unit.test.ts and its cursor-quota-wire.fixture.ts build a fixture with vite, launch it under real Electron via resolveElectronProbeLaunch + createElectronHomeIsolation, and record which synthetic account's Cookie reaches a loopback server across account/jar combinations, failure modes, the legacy path, jar mutation, and blocked redirects.

I confirmed the new E2E test is not theatre: removing credentials: 'omit' makes it fail at the jar-A-B arm with used: 25 instead of 75 — the exact reported ownership defect. The fix was restored and the tree left clean. PR-head CI is green (all unit shards, relay integration, package on Linux and Windows, static analysis and typecheck).

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 6c07570 into main Oct 4, 2026
55 checks passed
lurunzi pushed a commit to lurunzi/orca that referenced this pull request Oct 15, 2026
Backport upstream stablyai#25243 so Electron's cookie jar cannot replace the
selected Cursor account's explicit Cookie on usage requests. Include
the upstream native HTTP/HTTPS regression tests and request assertion.

Upstream-commit: 6c07570
Credit: Li-Sanze, jjongsta, and chengjiaxiao for the upstream fix and reports.
Co-authored-by: Codex <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant