Supabase · Lovable · Next.js
Private Supabase files: test the bucket, the policy and the signed URL
A private bucket does not secure a careless signing endpoint. Test Storage policies, tenant ownership and signed-link sharing with two synthetic accounts.
Three checks, not one switch
Start with a synthetic report owned by account A in workspace A. Account B belongs to a different workspace. Write down which operations each account should be allowed to perform before changing any policies.
A private bucket removes the ordinary public-download path. Storage policies then govern permitted API operations. Your application's signing route is another entry point: if it uses a privileged service client, the application must enforce its own ownership and role checks before issuing a URL.
Test the signer with the other customer's object
Give B the known object path from the synthetic fixture and ask your own signing endpoint for it. The intended outcome is a denial, not a signed link. Also test a missing session and a removed workspace member. Use only systems and accounts you are authorized to test.
Do not fix a failed ownership check by making the bucket public. Trace the requested object to authoritative ownership data. A folder name supplied by the browser is not a trustworthy ownership assertion.
Use the caller's permissions where the design permits it
A user-scoped Storage client can rely on applicable SELECT policies to decide whether signing is allowed. A service-role client bypasses those policies. Keep the distinction explicit in code review; replacing one client with the other changes the security boundary.
// userStorage is a request-scoped client for the authenticated caller.
// objectPath comes from the authorized document record, not an unchecked form.
const { data, error } = await userStorage.storage
.from('private-reports')
.createSignedUrl(objectPath, 60);
if (error || !data) throw new Error('Download unavailable');
// Return data.signedUrl only to the authorized requester.
// Never log it or put it in analytics.A signed link is a capability, not a fresh login check
Copy A's issued link into a signed-out test browser. If it works, that can be the intended capability-based design: possession of the link authorizes access for its lifetime. Do not claim that a private bucket makes such a copied link account-bound.
Choose the shortest practical lifetime and keep signed URLs out of logs, analytics, chat transcripts and permanent exports. For resources that require a fresh permission decision on every request, consider an authenticated download path or an application proxy that rechecks authorization.
Keep an allow-and-deny test record
- A accesses A's synthetic report: allowed.
- B requests A's path through authenticated download: denied.
- B or a signed-out caller asks the application's signer for A's report: denied.
- A uses a valid issued bearer link while signed out: document the intentional behavior.
- An expired link is rejected; a removed member cannot mint a new link.
- A legitimate upload and replacement still follow the intended INSERT, SELECT and UPDATE policies.
Plan for a leaked link
Supabase documents that individual signed URLs cannot be revoked independently. Object removal, relocation or project URL-signing-key changes have different blast radii and recovery consequences. Test the chosen recovery procedure on a disposable object in isolation before treating it as an incident response plan.
Keep a redacted record of expected and observed behavior. Do not put a real customer's document, signed link or credentials in a public issue or an initial review enquiry.
Questions
Does getPublicUrl make a private object public?
Generating a URL is not a permission check or a change to bucket visibility. Check whether the target bucket and delivery endpoint actually allow the request.
Can I revoke one signed download link?
Supabase's current downloads documentation says individual signed URLs cannot be revoked independently. Plan the object or signing-key recovery procedure and its impact before an incident.
Does the RLS simulator check my file downloads?
No. The simulator is a local educational aid for supported SQL patterns. It does not inspect your live Storage setup, signing endpoint or issued links. Those require authorized end-to-end tests.
Sources and further reading
Updated 22 November 2026 · by Psychevus