iOS app premium unlocked without paying: how to fix it
If your iOS app unlocks premium with a client isPremium flag, a user can patch or fake that flag. Check purchases on your server and refuse paid content and paid API calls there. The app can still show or hide screens. The server must decide who gets the paid data.
This guide shows what an attacker can change and how to check purchases on the server. It also shows how to find users who used paid features without a purchase.
What does “premium unlocked without paying” mean?
It means that a user gets paid features with no valid purchase. The user did not break Apple. The user changed what your app believes.
A typical generated app works like this. The app asks RevenueCat or StoreKit if the user has an active entitlement. The app stores the answer in a variable such as isPremium. The app shows paid screens when the value is true. The app calls your AI backend or your database with no further check.
The user controls the phone. A patched copy of the app, a hooked function, or a proxy on the network can change the answer. The paid screens open. The paid calls also go out. If the server answers them, the user got premium for free.
The RevenueCat documentation on Trusted Entitlements states the problem in plain words. It says that the user is in control of the client device. A user can run a man-in-the-middle attack to “grant themselves entitlements without actually paying you.”
The web version of this problem is a writable plan column. Read the guide on users who get premium without paying for that case. A mobile app has the same rule. The side that the user controls must not decide who is paid.
These are the usual ways to bypass an iOS paywall:
- A client flag. The app trusts a local boolean. A tool changes the boolean at run time.
- A cached entitlement. The app stores the last answer on the device. The user edits it or never lets it expire.
- An unsigned response. A proxy changes the answer from the purchase service, and the app accepts it.
- A patched binary. The user removes the check from the app code.
- A server that trusts the app. The backend answers every call that has a valid session, with no plan check.
- A client-written plan. The app writes
is_premiumto your database. The guide on users who make themselves admin explains why this fails.
How do I confirm that my app can be bypassed?
Test as a free user. Use a test account and a test device.
- Sign in to the app as a free user. Do not buy anything.
- Find the requests that paid features send. Use a proxy such as Charles or mitmproxy on your own device, or read the code of the app.
- Note the URL, the method, and the headers of one paid request. Examples are an AI chat call, an export, or a premium data call.
- Repeat the request with
curl. Use the session token of the free user.
curl -i -X POST https://api.your-app.example/v1/generate \
-H "Authorization: Bearer FREE_USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"prompt":"hello"}'
-
Read the answer. A correct server returns
402or403for a free user. A200answer with paid content means that the server does not check the plan. -
Check where the plan is stored. Search your database for
is_premium,plan, andtier. Try to update the value with the free user token. The web guide shows the test for Supabase. -
Check the app code. Search for
isPremium,entitlements, andisActive. For each match, ask what happens on the server if the value is false.
If the server answers a free user, or the free user can write the plan, start the fix now.
Warning: Test only your own app and your own accounts. Do not test an app that you do not own.
How do I fix it now?
Do these steps in order. Step 1 closes the paid API calls. They cost you money and they are the easiest target.
Caution: The fix makes the server refuse some calls that worked before. Old app versions that send no user token stop working. Ship an app update and a clear message.
- Gate the paid server calls. The server must look up the plan of the user on each paid call.
- Store the plan in a server table. Only a verified webhook writes it.
- Use the same user id in RevenueCat and in your backend.
- Turn on Trusted Entitlements in the app.
- Keep the keys out of the app. Read the guide on API keys in an iOS app.
- Close open AI proxies. Read the guide on an open AI proxy.
- Find users with paid usage and no purchase.
How do I use one user id in the app and on the server?
RevenueCat tracks a customer by an app user id. If you do not set one, the SDK creates an anonymous id. Your server cannot link an anonymous id to a signed-in user with certainty.
After sign-in, tell RevenueCat the id of your user. Use the id from your auth system, for example the Supabase user id:
import RevenueCat
func didSignIn(userId: String) async throws {
let result = try await Purchases.shared.logIn(userId)
// result.customerInfo holds the entitlements of this user.
}
The webhook then carries the same id that your database uses. The server can match a purchase to a user with no guess.
How do I check purchases on the server?
Use RevenueCat webhooks to fill a server table. Use the RevenueCat REST API when you need a live check. Both run on your server, where the user cannot change them.
How do I store the plan in a server table?
Create a table that the browser and the app cannot write. This design is the same as in the web guide:
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',
expires_at 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 app can read the own row to show the right screens. No client role can write. Only the server, with the service_role key, writes.
How do I receive RevenueCat webhooks?
In the RevenueCat dashboard, add a webhook URL. Set an authorization header value. RevenueCat sends this value in the Authorization header with each event. Your function must check it before it does any work.
This example is a Supabase Edge Function. Turn off the JWT check for it, because RevenueCat sends no Supabase JWT. The shared header value is then the only door. Keep it long and random.
# supabase/config.toml
[functions.revenuecat-webhook]
verify_jwt = false
// supabase/functions/revenuecat-webhook/index.ts
import { createClient } from "npm:@supabase/supabase-js@2";
const admin = createClient(
Deno.env.get("SUPABASE_URL")!,
Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!
);
Deno.serve(async (req) => {
if (req.headers.get("authorization") !== Deno.env.get("RC_WEBHOOK_AUTH")) {
return new Response("Unauthorized", { status: 401 });
}
const { event } = await req.json();
const active = ["INITIAL_PURCHASE", "RENEWAL", "UNCANCELLATION",
"PRODUCT_CHANGE"].includes(event.type);
const ended = ["EXPIRATION"].includes(event.type);
if (!active && !ended) return new Response("ignored");
const { error } = await admin.from("subscriptions").upsert({
user_id: event.app_user_id,
plan: active ? "pro" : "free",
status: active ? "active" : "expired",
expires_at: event.expiration_at_ms
? new Date(event.expiration_at_ms).toISOString()
: null,
updated_at: new Date().toISOString(),
});
if (error) return new Response("error", { status: 500 });
return new Response("ok");
});
Check the event types in the RevenueCat docs before you ship. A cancel event means that the user turned off renewal, but the user still has access until the period ends. The EXPIRATION event ends access.
Do not trust the body alone. The shared header value is a weak check. For a stronger design, treat the webhook as a signal and fetch the state from RevenueCat. The next section shows how.
Caution: An app_user_id that starts with $RCAnonymousID is an anonymous user. Your table has no row for it. Ignore these events, or you write bad rows.
How do I check the state with the REST API?
The RevenueCat REST API returns the state of one customer. Use your RevenueCat secret API key. Run this call only on your server.
curl https://api.revenuecat.com/v1/subscribers/USER_ID \
-H "Authorization: Bearer $REVENUECAT_SECRET_KEY" \
-H "Content-Type: application/json"
Read the entitlements object in the answer. An entitlement is active when its expires_date is in the future, or when it is null for a lifetime purchase.
Use this call in the webhook after the header check. Fetch the customer by the app_user_id, then write the plan from that answer. A forged event then cannot grant a plan that RevenueCat does not know.
Warning: Do not put the secret API key in the app. The public SDK key is made for the app. The secret key is not. Any user can read a key in an app binary.
How do I gate paid content and AI calls on the server?
Check the user and the plan on each paid request. Do it in the same function that does the paid work.
// Supabase Edge Function for a paid AI call
const token = req.headers.get("authorization")?.replace("Bearer ", "");
const { data: { user } } = await admin.auth.getUser(token);
if (!user) return new Response("Unauthorized", { status: 401 });
const { data: sub } = await admin
.from("subscriptions")
.select("plan, status, expires_at")
.eq("user_id", user.id)
.maybeSingle();
const paid =
sub?.plan === "pro" &&
sub.status === "active" &&
(!sub.expires_at || new Date(sub.expires_at) > new Date());
if (!paid) return new Response("Upgrade required", { status: 402 });
// Call the AI provider here.
The function calls getUser with the token. This asks the Supabase Auth server to verify the token. The function reads the plan from your table, not from the request body.
Add a limit for paid users too. A paid user can still run up your bill. The guide on apps used as a free ChatGPT explains how.
Apply the same rule to paid content. Do not ship paid content inside the app. If a file is in the app bundle, a user can extract it. Serve paid files from a private storage bucket with a short signed URL, and issue the URL only after the plan check.
How do I turn on Trusted Entitlements?
Trusted Entitlements add a signature to the data that RevenueCat sends to the app. The SDK checks the signature. It protects against a man-in-the-middle proxy that fakes a response.
The RevenueCat documentation lists these facts:
- It needs iOS SDK 4.25.0 or newer.
- From iOS SDK 5.15.0, the feature is on by default in informational mode.
- In informational mode, the SDK reports the result. It does not block anything. Your app decides what to do.
- The verification result is in
customerInfo.entitlements.verification. The values arenotRequested,verified,verifiedOnDevice, andfailed.
Set the mode when you configure the SDK:
Purchases.configure(
with: Configuration.Builder(withAPIKey: "appl_PUBLIC_SDK_KEY")
.with(entitlementVerificationMode: .informational)
.build()
)
Then act on the result:
func isPremium(_ info: CustomerInfo) -> Bool {
guard info.entitlements["pro"]?.isActive == true else { return false }
return info.entitlements.verification == .verified
}
If you switch from disabled to informational, the cache can still hold unverified data. The documentation advises you to call Purchases.invalidateCustomerInfoCache() in this case.
Caution: Trusted Entitlements do not stop a patched app. A patched app can ignore the result. They also do not protect your server. Server checks are the real protection. Use Trusted Entitlements as one more layer.
How do I find users with paid usage and no purchase?
Compare your usage records with your subscription table. A user who used paid features with no active plan got in by a bypass or by a gap in your server.
select u.user_id, count(*) as paid_calls, max(u.created_at) as last_call
from public.ai_usage u
left join public.subscriptions s on s.user_id = u.user_id
where u.tier = 'pro'
and (s.plan is distinct from 'pro' or s.status <> 'active')
group by u.user_id
order by paid_calls desc;
Change the table and column names to match your schema. If you do not log usage, start now. Add a row for each paid call, with the user id and the time.
Then follow these steps:
- Compare with RevenueCat. Open the customer list in the RevenueCat dashboard. Check the top users from the query above.
- Check the plan table for edits. Look for rows with no matching webhook event.
- Look at the cost. Read the bill of your AI provider. A spike with no matching revenue is a sign.
- Check the API logs. Look for paid endpoints that answered
200for users with the free plan. - Rotate secrets that were in the app. Treat any key in the binary as public.
- Decide what to do with the users. Some users did this by mistake, for example after a refund. Others did it on purpose.
Refunds and expired subscriptions also cause gaps. Handle the EXPIRATION event so that the plan ends on time.
How do I stop this problem in the future?
- Treat the app as untrusted. Any value that the app sends can be false.
- Check the plan on the server for each paid action. Add the check to the shared code of all paid routes.
- Write the plan only from a webhook. Never write it from the app.
- Use one user id everywhere. Call
logInafter sign-in. - Keep secret keys on the server. The web guide on Stripe webhooks shows how to verify a payment event. The pattern guide on Stripe webhooks and paid trust lists the same trust errors.
- Write a test. Call each paid route with a free user token. Expect
402or403. - Review code from AI tools. Search for
isPremiumand ask which server check backs each use. - Scan the live API after each release.
When should I get help?
Get help in these cases:
- Many free users have paid usage and your bill grew.
- A secret API key was in the app binary, and you do not know who read it.
- You have many paid routes and you cannot tell which ones check the plan.
- Your app sells content that you must protect, such as courses or files.
- You see signs that users also read the data of other users.
After the fix, repeat the curl test from the confirm section. A free user must get 402 or 403 on every paid route. Then buy the product in the App Store sandbox. The plan must change only after the webhook arrives.
Common questions
Can I stop all paywall bypass on the device?
Do Trusted Entitlements stop a patched app?
Is the RevenueCat public SDK key a secret?
Where must the premium flag live?
What do I check on each paid request?
Test your paid API calls
A VibeEval scan tests the web API behind your app. It checks if paid endpoints answer a free account or a request with no proof of purchase.
14-day free trial · Cancel anytime