Skip to content

Fix Cursor: pass cursor.com's CSRF origin check (v0.2.1) - #10

Merged
devudilip merged 1 commit into
mainfrom
claude/ration-quota-tracker-g3uwc6
Aug 29, 2026
Merged

Fix Cursor: pass cursor.com's CSRF origin check (v0.2.1)#10
devudilip merged 1 commit into
mainfrom
claude/ration-quota-tracker-g3uwc6

Conversation

@devudilip

Copy link
Copy Markdown
Owner

What happened

First live test of the Cursor adapter on a real logged-in account: the session cookie attaches correctly, but cursor.com answers the extension's POSTs with 403 {"error":"Invalid origin for state-changing request"} — extension-initiated requests carry Origin: chrome-extension://…, and Cursor's CSRF guard only accepts its own origin. Claude and Codex use GETs, which is why only Cursor hit this.

The fix

Adapters can now declare originOverride. A declarativeNetRequest session rule sets the Origin header to the provider's own origin on requests matching its API prefix, with two deliberate scopes:

  • initiatorDomains: [chrome.runtime.id] — the rule applies only to requests initiated by this extension. Other pages' requests to cursor.com are untouched, so Cursor's CSRF protection is not weakened for anything else.
  • declarativeNetRequestWithHostAccess — the new permission carries no install warning and acts only on hosts the user has already granted at enable-time.

Rules re-sync on startup/install (session rules don't survive browser restarts) and on every provider toggle or data wipe. Justification text added to docs/store/listing.md (needed for the next store upload) and the privacy policy page.

Verification

  • npm run ci green: 71 tests — new suite covers rule creation/scoping for enabled providers, removal on disable, no-rules for Claude/Codex, and graceful no-op when the API is unavailable.
  • After merge: git pull && npm run build, reload the extension, toggle Cursor off and on — the card should populate. (The live 403 was reproduced and diagnosed from the reporter's service-worker capture; the header rewrite addresses exactly the check in the error message.)

Version 0.2.1.


Generated by Claude Code

First live test on a real account: cookies attach fine, but cursor.com
rejects the extension's POSTs with 403 'Invalid origin for state-changing
request' because extension requests carry a chrome-extension:// Origin.
(Claude and Codex use GETs, which is why only Cursor hit this.)

Adapters can now declare originOverride; a declarativeNetRequest session
rule sets the Origin header to the provider's own origin on requests
matching its API prefix — scoped via initiatorDomains to requests
initiated by THIS extension only, so no other page's traffic is touched
and the provider's CSRF protection stays intact for everyone else. Rules
re-sync on startup/install (session rules don't survive restarts) and on
every provider toggle. Requires declarativeNetRequestWithHostAccess
(no warning prompt; acts only on user-granted hosts); justification
added to the store listing and privacy policy. Version 0.2.1.
@devudilip
devudilip merged commit 4d8faa7 into main Aug 29, 2026
1 check passed
@devudilip
devudilip deleted the claude/ration-quota-tracker-g3uwc6 branch August 29, 2026 17:43
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