Skip to content

fix(security): stop serving and restoring deleted bundle cache - #3100

Open
riderx wants to merge 7 commits into
mainfrom
fix/security-ghsa-26x3-deleted-cache
Open

fix(security): stop serving and restoring deleted bundle cache#3100
riderx wants to merge 7 commits into
mainfrom
fix/security-ghsa-26x3-deleted-cache

Conversation

@riderx

@riderx riderx commented Aug 16, 2026

Copy link
Copy Markdown
Member

Summary (AI generated)

  • File serve now 404s cache hits for deleted bundles (deleted / deleted_at or a deleted cache marker) and does not write those objects back to R2.
  • Version delete in on_version_update purges the same files Cache API keys and sets a deleted marker the serve path honors.
  • Fixes GHSA-26x3-6mr7-989p: deleted bundles could keep being downloaded from edge cache and restored into R2.

Motivation (AI generated)

Soft-deleted versions were moved to R2 trash without invalidating the files worker cache. A later cache hit could still serve the zip and put it back into R2, so deleted bundles stayed available.

Business Impact (AI generated)

Customers who delete a bundle can rely on that version becoming undownloadable. This closes a security hole where deleted release artifacts remained reachable and could be resurrected.

Test Plan (AI generated)

  • Unit test: cached deleted version returns 404 and does not call R2 put
  • Unit test: deleted cache marker 404s without a database lookup
  • Unit test: deleteIt calls purgeFileReadCache for the version r2_path
  • Existing files cache/bandwidth/R2 unit tests still pass

Generated with AI

Made with Cursor


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

On-demand reviews are free for the next 26 days. After that, they cost $0.25 per reviewed file.

Or wait 52 minutes for your next included review.

View limit details

Limit details: You’ve used the included review currently available. Your 62 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: dc1457bb-8e67-4bfc-93c2-da49eff059b3

📥 Commits

Reviewing files that changed from the base of the PR and between 3633ef8 and c903b42.

📒 Files selected for processing (9)
  • cloudflare_workers/files/index.ts
  • supabase/functions/_backend/files/file_read_cache.ts
  • supabase/functions/_backend/files/files.ts
  • supabase/functions/_backend/triggers/on_version_update.ts
  • tests/files-app-read-guard.unit.test.ts
  • tests/files-bandwidth.unit.test.ts
  • tests/files-deleted-cache.unit.test.ts
  • tests/files-r2-error.test.ts
  • tests/on-version-update-cleanup.unit.test.ts

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

@codspeed-hq

codspeed-hq Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing fix/security-ghsa-26x3-deleted-cache (c903b42) with main (3633ef8)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@TorichanCapgo
TorichanCapgo marked this pull request as ready for review August 24, 2026 14:39
@TorichanCapgo

Copy link
Copy Markdown
Contributor

Ready for Martin review/merge when CI is green. Please do not include advisory identifiers in follow-up commits.

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread supabase/functions/_backend/files/file_read_cache.ts
Comment thread supabase/functions/_backend/files/file_read_cache.ts Outdated
Comment thread supabase/functions/_backend/files/files.ts
Comment thread supabase/functions/_backend/files/files.ts
Comment thread cloudflare_workers/files/index.ts Outdated
Comment thread supabase/functions/_backend/triggers/on_version_update.ts Outdated
Comment thread tests/files-deleted-cache.unit.test.ts
Comment thread tests/files-r2-error.test.ts Outdated
@TorichanCapgo

Copy link
Copy Markdown
Contributor

Triage 2026-08-25: previous “ready for Martin” comment is withdrawn.

This PR is not fully ready per AGENTS.md: automatic review has not APPROVED (CodeRabbit was rate-limited or only commented). CI must be green on the latest head and AI review fully clear before any human ping.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

@TorichanCapgo I will review pull request #3100.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

riderx and others added 5 commits August 25, 2026 15:55
Deleted versions stayed downloadable from the files edge cache and
could be written back to R2. Purge that cache on delete and 404
cache hits for deleted or marked bundles.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
@cursor

cursor Bot commented Aug 25, 2026

Copy link
Copy Markdown

@coderabbitai review

@cursor
cursor Bot force-pushed the fix/security-ghsa-26x3-deleted-cache branch from 826c2fe to 4077f6d Compare August 25, 2026 15:57
@cursor
cursor Bot deployed to deepsec-pr August 25, 2026 15:57 Active
@cursor

cursor Bot commented Aug 25, 2026

Copy link
Copy Markdown

@coderabbitai review

Unit test fix: files-bandwidth.unit.test.ts now mocks getPgClient with a non-deleted version lookup (same pattern as files-r2-error / files-deleted-cache), so the new isAttachmentVersionDeleted guard no longer 404s bandwidth tests.

Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
@cursor
cursor Bot deployed to deepsec-pr August 25, 2026 16:13 Active
@cursor

cursor Bot commented Aug 25, 2026

Copy link
Copy Markdown

@coderabbitai full review

Latest head 3b646acf2 fixes files-bandwidth.unit.test.ts pg mocks for the deleted-version guard; unit tests pass locally.

Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
@cursor

cursor Bot commented Aug 25, 2026

Copy link
Copy Markdown

@coderabbitai review

All 8 review threads resolved. Latest head 3b646acf2 adds pg client mocks to bandwidth unit tests for the deleted-bundle guard. Unit tests pass locally.

@cursor
cursor Bot deployed to deepsec-pr August 25, 2026 18:11 Active
@sonarqubecloud

Copy link
Copy Markdown

@cursor

cursor Bot commented Aug 25, 2026

Copy link
Copy Markdown

@coderabbitai full review

@cursor

cursor Bot commented Aug 25, 2026

Copy link
Copy Markdown

@coderabbitai review

Latest head c903b4206 — all 76 CI checks green, 0 open threads. Please approve.

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.

3 participants