fix: require authentication before wallet and wallet-set creation - #25
Open
memosr wants to merge 1 commit into
Open
fix: require authentication before wallet and wallet-set creation#25memosr wants to merge 1 commit into
memosr wants to merge 1 commit into
Conversation
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.
Problem
Two endpoints either skip authentication entirely or run privileged Circle SDK calls before the auth check, allowing unauthenticated callers to abuse the app's Circle developer account.
app/api/wallet-set/route.ts(POST)The handler has no Supabase import and no
getUser()call at all. Any unauthenticated HTTP client can create wallet sets in the app's Circle developer account.app/api/wallet/route.ts(POST)circleDeveloperSdk.createWallets()is called at line ~46, before the only auth check at line ~66. The auth check also lives inside an innertry/catchexplicitly labeled "do not block wallet creation if this fails," so even a failure there doesn't gate the SDK call.Impact
transfer,payout,deposit,compliance) correctly callssupabase.auth.getUser()at the top and returns 401 before touching any external API. These two are the outliers.Fix
Move the auth check to the top of each handler, matching the existing pattern used by
app/api/wallet/transfer/route.tsandapp/api/gateway/deposit/route.ts:In
wallet/route.ts, the redundant innercreateClient() / getUser()block (which only set theuserIdon the inserted DB record) was also removed — the outersupabaseanduserare reused instead.Impact