Users get premium without paying: how to fix it
Free users get paid features when they can write their own plan or is_premium column. Remove the write permission from the browser. Set the plan only from a verified Stripe webhook on your server. A row-level policy does not protect single columns. You must use a column grant, a trigger, or a separate table.
This guide shows how to confirm the problem, how to close it in order, and how to find users who already upgraded themselves.
What does “premium without paying” mean?
It means that a signed-in user changed a field that controls access to paid features. The user did not pay. The user opened the browser console and sent one request.
The usual setup is simple. The app has a profiles table. The table has a plan column or an is_premium column. The app shows paid features when the value is pro or true. A Stripe webhook updates the column after a payment.
The problem is the policy on that table. An AI coding tool often writes a policy like this one:
create policy "users update own profile"
on public.profiles for update to authenticated
using (auth.uid() = id);
This policy says that a user can update the own row. It does not say which columns. The user can update display_name. The user can also update plan.
The Supabase documentation on Row Level Security describes a policy as a filter on rows. It says: “Think of a policy as adding a WHERE clause to every query.” A WHERE clause selects rows. It does not select columns.
This is the same root cause as the admin role problem. Read the guide on users who make themselves admin for the role version. This guide covers money and plans. The general name for the weakness is mass assignment. The app accepts fields that the user must not set.
These are the usual causes:
- A plan column on the profile row. The user can update the row, so the user can update the plan.
- A client-side check only. The app reads
is_premiumin the browser and trusts the value. - A success page that grants access. The app sets the plan when the user opens
/success. A user can open that page without a payment. - An unverified webhook. The handler accepts any POST request. The Stripe webhook guide covers this case.
- A trial flag that the client sets. The user can extend the trial or turn it on again.
How do I confirm that users can upgrade themselves?
Test with a normal free account. Do not use your admin account. Use a test project if you can.
- Sign in to your app as a free user.
- Open the browser DevTools and select the Network tab.
- Update the profile once, for example the display name. Find the request.
- Copy the project URL, the anon key, and the user access token from the request headers.
- Send a request that sets the plan. Replace the values in capital letters.
curl -i -X PATCH "https://PROJECT.supabase.co/rest/v1/profiles?id=eq.USER_ID" \
-H "apikey: ANON_KEY" \
-H "Authorization: Bearer USER_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-H "Prefer: return=representation" \
-d '{"plan":"pro"}'
A 200 response with the changed row means that the problem exists. A 403 response or an error about a column means that the write is blocked. Then try other names: is_premium, tier, subscription_status, credits, and trial_ends_at.
You can also use the Supabase client in the browser console of your app:
await supabase.from("profiles").update({ plan: "pro" }).eq("id", user.id)
- Reload the app. If the paid features open, the app trusts the column.
Warning: Run these tests only on your own test account. A request that works changes real data. Set the value back after the test.
A response that returns the changed row is a failure. Start the fix now.
How do I fix it now?
Do these steps in order. Step 1 stops new abuse at once. Steps 2 to 4 build the correct design.
Caution: The fix removes the ability of the browser to write the plan. If your own code writes the plan from the browser, that code stops working. This is correct. Move that code to the server.
- Block the write. Use a column grant or a trigger. See the next sections.
- Reset the plan of the wrong users. Use the query in the section on checks. Do this after step 1, or the user can set the plan again.
- Move the plan to a table that only the server writes.
- Set the plan only from a verified Stripe webhook.
- Check the other columns. Look at every column that gives value: credits, limits, trial dates, and feature flags.
How do I block the write with a column grant?
Postgres can limit UPDATE to named columns. The browser role is authenticated. Remove the table-wide permission first. Then grant only the safe columns.
revoke update on public.profiles from anon, authenticated;
grant update (display_name, avatar_url) on public.profiles
to authenticated;
The order matters. A column-level revoke does not work when the role has a table-wide grant. The first line removes the table-wide grant. The second line adds back the columns that users can edit.
Test again with the curl command from the confirm section. The response must be an error such as permission denied for table profiles.
The Supabase column-level security guide explains the same method. The row policy stays in place. The grant adds the column limit.
Caution: New columns that you add later do not get a grant. This is safe by default. The user cannot write a new column until you grant it.
How do I block the write with a trigger?
Use a trigger when you must keep a table-wide grant. The trigger refuses a change to the plan when the caller is a browser role.
create or replace function public.block_plan_change()
returns trigger
language plpgsql
set search_path = ''
as $$
begin
if current_user in ('anon', 'authenticated')
and (new.plan is distinct from old.plan
or new.is_premium is distinct from old.is_premium) then
raise exception 'plan is read-only';
end if;
return new;
end;
$$;
create trigger profiles_block_plan_change
before update on public.profiles
for each row execute function public.block_plan_change();
The server uses the service_role key. That key connects as a different role. The trigger lets the server change the plan.
Do not use only a policy WITH CHECK clause for this task. The clause sees the new row. It does not see the old row. You cannot compare the two values in a simple way. A column grant or a trigger is simpler.
How do I move the plan to a table that only the server writes?
Do not keep the plan next to user-editable data. Use one table for the plan. Let the browser read it. Let only the server write it.
create table public.subscriptions (
user_id uuid primary key references auth.users (id) on delete cascade,
plan text not null default 'free',
status text not null default 'none',
stripe_customer_id text unique,
stripe_subscription_id text unique,
current_period_end timestamptz,
updated_at timestamptz not null default now()
);
alter table public.subscriptions enable row level security;
revoke insert, update, delete on public.subscriptions
from anon, authenticated;
create policy "users read own subscription"
on public.subscriptions for select to authenticated
using ((select auth.uid()) = user_id);
The table has a select policy only. A user can read the own row. No policy allows insert, update, or delete, and the grants are removed. The browser cannot change the table.
Then remove the plan from the profile table, or stop the app from reading it:
alter table public.profiles drop column plan;
Update the app to read subscriptions.plan. Check the data first. Run the drop only after you reset the wrong values.
This design also helps with the Supabase RLS guide advice. Each table has one owner of the writes. A table with one writer is easy to review.
How do I set the plan only from a Stripe webhook?
The server must set the plan after Stripe confirms the payment. Stripe sends a webhook event to your server. The handler verifies the signature, then writes the plan with the service_role key.
Do not set the plan from the success page. Do not set it from a request that the browser sends. Both paths accept a claim from the user.
This example uses a Next.js route handler:
// app/api/stripe/webhook/route.ts
import Stripe from "stripe";
import { createClient } from "@supabase/supabase-js";
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
const admin = createClient(
process.env.SUPABASE_URL!,
process.env.SUPABASE_SERVICE_ROLE_KEY!
);
export async function POST(req: Request) {
const body = await req.text();
const signature = req.headers.get("stripe-signature");
if (!signature) return new Response("No signature", { status: 400 });
let event: Stripe.Event;
try {
event = stripe.webhooks.constructEvent(
body,
signature,
process.env.STRIPE_WEBHOOK_SECRET!
);
} catch {
return new Response("Bad signature", { status: 400 });
}
if (event.type === "checkout.session.completed") {
const session = event.data.object as Stripe.Checkout.Session;
const userId = session.client_reference_id;
if (userId && session.payment_status === "paid") {
await admin.from("subscriptions").upsert({
user_id: userId,
plan: "pro",
status: "active",
stripe_customer_id: session.customer as string,
updated_at: new Date().toISOString(),
});
}
}
return new Response("ok");
}
Set client_reference_id to the user id when your server creates the Checkout Session. Do not take the id from the browser at the time of the webhook.
Read the guide on unverified Stripe webhooks for the full list of checks. A handler without a signature check gives the same result as an open column. The pattern guide on Stripe webhooks and paid trust shows the other points where an app trusts the wrong data.
Handle more events than checkout.session.completed. A subscription can end, fail, or change. Listen for customer.subscription.updated, customer.subscription.deleted, and invoice.payment_failed. Update status and current_period_end from each event. Without these events, a user who cancels keeps paid access.
How must the app check access?
Check the plan on the server, for each paid action. The page can hide a button, but the API must refuse the request.
const { data } = await supabase
.from("subscriptions")
.select("plan, status, current_period_end")
.eq("user_id", user.id)
.single();
const paid =
data?.plan === "pro" &&
data.status === "active" &&
new Date(data.current_period_end) > new Date();
if (!paid) return new Response("Upgrade required", { status: 402 });
Use the same check for paid AI calls and exports. An attacker can call those routes without your page.
How do I check if someone already upgraded themselves?
Find users with a paid plan and no real payment. Use your database and your Stripe account together.
- List paid rows with no Stripe customer. This query works for the old
profilesdesign:
select id, email, plan, updated_at
from public.profiles
where plan <> 'free'
and stripe_customer_id is null
order by updated_at desc;
- List active subscriptions in Stripe. Use the Stripe CLI or the Dashboard.
stripe subscriptions list --status active --limit 100
- Compare the two lists. A paid user in your database with no active subscription in Stripe is a suspect. Check for free trials, gift codes, and manual grants that you gave on purpose.
- Check the timing. Look for rows where
updated_atis far from any Stripe event. A real upgrade has a payment time close to the plan change. - Read the API logs. In the Supabase dashboard, open Logs and search for
PATCHrequests to/rest/v1/profiles. A normal user who sends a PATCH with a plan value is a sign of abuse. - Check the usage. Look for accounts that used paid features, such as many AI calls, with no payment record.
- Reset the wrong rows. Set the plan to
free. Do this after you close the write path.
Decide what to do with the users. Some users found the bug by chance. Others used it on purpose. Tell the users that the plan was changed. Offer a way to pay.
If you cannot see old requests, you cannot prove how many users did this. Keep a log from now on. Add an audit_log table that records each plan change from the webhook.
How do I stop this problem in the future?
Use these controls so that a new column does not open the same hole.
- Use deny by default. Grant
UPDATEonly on named columns. Never grant it on the whole table toauthenticated. - Keep money fields in a server-only table. Plans, credits, and limits belong there.
- Set the plan only from a verified webhook. Add a test that sends an unsigned event and expects a
400response. - Write a test for your policies. Sign in as a free user. Try to update
plan,is_premium,credits, androle. The test must expect an error for each one. - Review code from AI tools. Search for
update({and.from("profiles")in browser code. Ask which fields the user can send. - Check the access on the server. Do not trust a flag in
localStorageor in the page. - Scan the live app after each release. A test of the running app finds a column that your review missed.
The guide on SaaS privilege escalation explains more cases of users who raise their own rights.
When should I get help?
Get help in these cases:
- Many users have paid features and you cannot match them to payments.
- The logs show that the same user sent many writes to plan fields.
- You use
service_rolein the browser to write the plan. This key bypasses all row policies. Rotate it and move the code to the server. - The app has many tables with money fields and you cannot review all of them.
- You find signs that someone also changed data of other users.
After the fix, repeat the curl test from the confirm section. The write must fail. Then run a real test payment in Stripe test mode. The plan must change only after the webhook arrives.
Common questions
Why can a free user change is_premium if I enabled RLS?
Is it enough to hide the upgrade button?
Where must the plan live?
Who must set the plan after a payment?
How do I find users who upgraded themselves?
Test your paywall writes
A VibeEval scan signs in as a normal user and tests if the app or the API accepts a write to a plan, tier, or premium field on the profile.
14-day free trial · Cancel anytime