Skip to content

[WRONG BRANCH] Bound retained Cursor blob ID keys - #178

Closed
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-memory-exhaustion-vulnerability-in-cursor
Closed

[WRONG BRANCH] Bound retained Cursor blob ID keys#178
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-memory-exhaustion-vulnerability-in-cursor

Conversation

@luvs01

@luvs01 luvs01 commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Star lidge-jun/opencodex? Yes / No

Motivation

  • Prevent upstream-controlled Cursor blob IDs from exhausting process memory by being materialized as unbounded hex Map keys that are excluded from blob payload accounting.
  • Restore accurate retained-store accounting so the app-owned memory snapshot and eviction logic include both payload and key retention.

Description

  • Replace raw-hex passthrough for oversized blob IDs with domain-separated keys that hash long IDs (IDs <= 64 bytes keep an h: hex passthrough; larger IDs become d: + SHA-256 hex) to bound retained key length.
  • Track retained key bytes in a new blobKeyBytes counter and include key bytes in all relevant accounting paths, including insertion, deletion, eviction, snapshot, and metrics.
  • Classify key bytes together with their entry for pinned/evictable calculations so zero-byte payloads remain selectable for eviction.
  • Add regression tests that exercise passthrough vs digest boundary, multi‑MiB IDs, collision separation, aggregate key-byte bounds, replacement/eviction behavior, the entry ceiling, and zero-payload eviction.

Testing

  • Ran bun test tests/cursor-blob.test.ts where the Cursor-focused tests passed (59 passed, 0 failed).
  • Ran bun run typecheck and bun run privacy:scan, both succeeded.
  • Ran broader bun run test; Cursor tests passed but the full-suite run encountered unrelated environment-sensitive timeouts in some provider/model-discovery and combo-management tests (these failures are not related to the Cursor KV fix).

Codex Task

Summary by CodeRabbit

  • Bug Fixes

    • Improved cursor blob storage memory accounting to include retained key data.
    • Fixed storage limits, eviction behavior, deletion tracking, and metrics for more accurate capacity management.
    • Prevented oversized blob identifiers from generating unnecessarily large storage keys.
  • Reliability

    • Improved handling of replacements, resets, zero-size payloads, and maximum-entry limits.
    • Added safeguards to ensure storage behavior remains predictable at identifier size boundaries.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

⚠️ Wrong target branch

This pull request currently targets main, but pull requests must target one of dev.

@luvs01 Please retarget this PR to dev. All contributions go to dev; main receives only release promotions. See our Contributing guide for details. Thanks! 🙏

Its title has been prefixed with [WRONG BRANCH].

This pull request is being kept as a draft automatically. Once every issue above is resolved, it will be marked ready for review again.

@github-actions github-actions Bot changed the title Bound retained Cursor blob ID keys [WRONG BRANCH] Bound retained Cursor blob ID keys Aug 8, 2026
@github-actions
github-actions Bot marked this pull request as draft August 8, 2026 15:57
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fc1d0f74-1be9-4154-805c-e7cd4755ea9d

📥 Commits

Reviewing files that changed from the base of the PR and between 8a9c0ef and 6b34416.

📒 Files selected for processing (2)
  • src/adapters/cursor/native-exec.ts
  • tests/cursor-blob.test.ts

📝 Walkthrough

Walkthrough

Cursor blob storage now tracks retained key-string memory separately from payload memory. Large blob IDs use bounded SHA-256 keys. Metrics, snapshots, deletion, eviction, reset behavior, and tests now include key-byte accounting.

Changes

Cursor blob memory accounting

Layer / File(s) Summary
Bounded keys and blob accounting
src/adapters/cursor/native-exec.ts
Blob IDs up to 64 bytes use prefixed hex keys. Larger IDs use prefixed SHA-256 keys. Blob insertion, deletion, pinning, and eviction include retained key-string bytes.
Metrics and retained-store state
src/adapters/cursor/native-exec.ts
CursorBlobMetrics exposes keyBytes. Retained-store snapshots include payload and key bytes. Test resets clear key-byte accounting.
Accounting and key-boundary validation
tests/cursor-blob.test.ts
Tests update retained-byte expectations and cover payload metrics, key formats, the 64-byte boundary, bounded digest keys, domain separation, replacement, eviction, reset, capacity, and zero-payload entries.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: lidge-jun, wibias

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: bounding retained Cursor blob ID keys.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-memory-exhaustion-vulnerability-in-cursor

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

@luvs01 luvs01 closed this Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant