fix(security): scope dashboard cache per-user (cross-account metrics bleed)#9
Merged
Merged
Conversation
… accounts) useSourceState persisted the live source-state (arb/trade/pipeline/pumpfun metrics) to a SINGLE global localStorage key 'b1dz:source-state' and hydrated from it on load. On a shared browser, switching accounts showed the previous account's metrics on /dashboard, /console, and /dashboard/projections — and an empty account never overwrote them. (Settings has no localStorage, which is why it looked clean.) - Scope the cache key per user id: 'b1dz:source-state:<userId>'. - Start empty (no synchronous hydrate from a global key) so first paint never shows another account's data; resolve the user, then hydrate that user's cache. - Purge the legacy global key on load to clear already-leaked blobs from browsers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug you hit
/dashboard,/console, and/dashboard/projectionsshowed another account'smetrics after switching accounts in the same browser.
Root cause (client-side, not the DB)
Verified the backend is clean: RLS policies are correct (
user_id = auth.uid()),the
source_staterows contain only each user's own{enabled, daemon}(no keys,positions, or cross-account data), and the runtime cache is keyed per user.
The leak was in
useSourceState(): it persisted the live source-state to asingle global
localStoragekeyb1dz:source-stateand hydrated from it onload. Switching accounts on one browser showed the previous account's cached
metrics, and an empty account never overwrote them. Settings has no localStorage
— which is why settings looked clean but the dashboards didn't.
Fix
b1dz:source-state:<userId>.shows another account's data; resolve the user, then hydrate that user's cache.
Part of the multi-tenant security pass (follow-up to #5).
🤖 Generated with Claude Code