Is your Supabase anon key safe in an Android app?

Updated

Short answer: the anon key, or the newer publishable key, is meant to be in your app. Whether that is safe depends entirely on Row Level Security. The service_role key, or the newer secret key, must never be in an app at all.

Your APK is readable by anyone who downloads it, so assume every key in it is public. See how to check your APK for leaked keys.

Which Supabase key is which?

Supabase has two kinds of key, each in a current and a legacy form:

  • Publishable key (sb_publishable_...), or the legacy anon key. Supabase describes it as "safe to expose online", including in a "mobile or desktop app". Requests made with it act as the anon role, or as authenticated once the user signs in.
  • Secret key (sb_secret_...), or the legacy service_role key. "Only use in backend components of your app." Supabase lists mobile apps, "where the key is bundled inside the compiled packages", among the places it must never appear.

Supabase refuses secret keys from browsers by checking the User-Agent. An Android app is not a browser, so that check does not protect you: a secret key in an APK works for whoever extracts it.

What actually protects the data?

Row Level Security. With the publishable key, Postgres decides what each request may read or change, table by table, using the policies you write.

Supabase's documentation is blunt about the two states that matter:

  • "A table in an exposed schema without RLS is readable and writable by any role with a grant on it."
  • "Once RLS is enabled, no data is accessible through the API when using a publishable key, until you create policies."

So RLS off means open to anyone with your project URL and the key from your app. RLS on with no policies means closed, which is safe but breaks your app until you add policies.

How do I check every table?

Two ways, and it is worth doing both.

The Security Advisor, in your project's dashboard, runs Supabase's own checks. The one that matters here is rls_disabled_in_public, which it rates as an error: "Anyone with your project URL can read, edit, and delete all data in this table because Row-Level Security is not enabled."

A query in the SQL editor lists every table in the public schema and whether RLS is on:

select tablename, rowsecurity
from pg_tables
where schemaname = 'public'
order by tablename;

Any row with rowsecurity false is a table your app's key can read and write freely.

What does a good policy look like?

A policy says which rows a role may touch. The pattern Supabase uses in its own examples, letting each signed-in user read only their own profile:

alter table profiles enable row level security;

create policy "Users can view their own profile."
on profiles for select
to authenticated
using ( (select auth.uid()) = user_id );

Write one policy per action you allow (select, insert, update, delete), and allow nothing else.

Which mistakes open the data up anyway?

  • Tables created in SQL. In Postgres, a new table has RLS off until you run alter table ... enable row level security. Migrations and AI-written SQL often leave it out.
  • using (true) for the anon role. Supabase warns that such a policy "grants every unauthenticated visitor read access to every row". Use it only for data meant to be public.
  • Views. A view runs with its owner's rights and ignores the policies on the tables under it, unless it is created with (security_invoker = on). The Security Advisor flags these as security_definer_view.
  • The service_role key in the client to "make it work" when a policy was blocking a request. That turns every policy off for anyone holding your APK.

And if the secret key is already in a build?

Rotate it in the Supabase dashboard first, because every copy of that build still holds the old one. Then move the operation that needed it to your server or an Edge Function, where the secret stays.

This is one of the checks on the Google Play pre-launch checklist. Google's review does not check your database rules, but anyone who downloads your app can.

Sources

Next steps

Still need testers? Get 12 testers for your closed test through a free test-for-test exchange - you test another developer's app, they test yours, and every opt-in is verified.

Common questions

Is it safe to put the Supabase anon key in my Android app?
Yes, if Row Level Security is enabled on every table in an exposed schema, with policies that allow only what each user should reach. The key is public by design; RLS is the lock.
What happens if RLS is off on a table?
Supabase says a table in an exposed schema without RLS is readable and writable by any role with a grant on it. Its Security Advisor puts it more plainly: anyone with your project URL can read, edit and delete all the data in it.
I shipped the service_role key. What now?
Treat it as compromised: rotate it in the Supabase dashboard straight away, then move whatever needed it to a server or Edge Function. Old builds still contain the old key.

Apps currently in closed testing

Real developers running the test described above. Test one, and get testers for your own app back.

Closed testing

In Between is a free card game. Join the group, opt in, install, open it and play a hand. Keep it 14 days. Not available in South Korea. I test your app back the same day.

Games

Available in all countries

Open to testers · 14-day test

Closed testing

# BAYAA — Closed Testing: Instructions for Testers Thank you for participating in the BAYAA (بياع) closed testing program. BAYAA is a Mauritanian marketplace designed to connect customers with shops, restaurants, pharmacies, hotels, and service providers. ## 1. What testers are expected to do - Install BAYAA through the official Google Play closed-testing link. - Keep the app installed throughout the 14-day testing period. - Open and use the app regularly during the testing period. - Create an account and test registration and login. - Browse available shops, products, and services. - Test search and navigation. - Test merchant features if you have a merchant account. - Check WhatsApp contact options where available. - Report bugs, errors, confusing screens, and suggestions. ## 2. What feedback should you provide? Please tell us: - What worked correctly? - What did not work? - Were any pages slow or difficult to use? - Did you experience crashes or unexpected errors? - What features would you like us to improve? Honest feedback is very important. You do not need to give positive feedback if you encounter a problem. ## 3. Important testing rules - Use the app with your own tester account. - Do not share your login credentials. - Do not enter real payment or sensitive personal information. - Do not make fake purchases or transactions. - Do not uninstall the app during the testing period unless instructed. - Keep your Google Play testing enrollment active. ## 4. Reporting problems Send your feedback and screenshots of errors to the BAYAA development team. Thank you for helping us improve BAYAA and prepare it for its official launch in Mauritania. **BAYAA — بياع | Supporting Mauritanian Businesses**

Shopping

Available in all countries

Open to testers · 14-day test

Closed testing

PocketLedger helps you know your money and own your month — without handing your financial life to anyone. Everything stays on your phone. There is no account to create, no bank login, no SMS reading and no internet access at all. PocketLedger works fully offline. TRACK EVERY RUPEE (OR DOLLAR, EURO, POUND) • Add income and expenses in seconds, with category, account, date, merchant and notes • Mark refunds so they reduce your spending instead of counting as income • Search by merchant or note, filter by type, and tap any category to see its transactions for the month • INR, USD, EUR and GBP supported — amounts in different currencies are never mixed or converted SEE YOUR MONTH AT A GLANCE • Net cash flow, total income and total expenses for any month • Spending by category with an interactive chart • Recent transactions and account balances on one screen BUDGETS THAT KEEP YOU HONEST • Set a monthly limit for any category • See what you have spent, what is left, and when you go over ALL YOUR ACCOUNTS • Cash, bank accounts, UPI, credit cards and wallets • Pick from popular banks (SBI, HDFC, ICICI, Axis, Kotak and many more) and UPI apps, or type any name • Live balance for every account NOTHING IS EVER LOST • Every transaction keeps a full version history: see exactly what changed, when • Deleted transactions can be restored • An activity log records every add, edit, delete and setting change PRIVATE BY DESIGN • No sign-up, no ads, no tracking, no analytics • No internet permission — your data physically cannot leave the app • Not backed up to the cloud PocketLedger is a personal budgeting and expense-tracking tool. It does not offer loans, payments, banking or investment services and does not connect to any bank. Made by Technopreneurs Technolabs.

Finance

Available in all countries

Open to testers · 14-day test

May we use analytics and ad measurement? Analytics (Vercel, and Ahrefs on our public pages) count page views without cookies. Ad measurement lets Google's tag on our public pages see which visits came from our Google ads, using a Google cookie. The site works the same either way. Cookie Policy · How Google uses data ·