critical · M1 · MASVS-AUTH-1 · PTKD-BACKEND-SUPABASE-ADMIN-IN-APP

    App code calls Supabase admin APIs, so the service-role key ships in the app

    The mobile app's own code calls supabase.auth.admin (deleteUser, listUsers, createUser, updateUserById...). These calls only work with the service-role key, which skips every Row Level Security policy, so the key has to be in the app, where anyone can extract it from the bundle.

    How it is exploited

    A 'Delete my account' button calls `supabase.auth.admin.deleteUser(user.id)` straight from the app, so the client was created with the service-role key. Anyone unzips the app, finds the key in the JavaScript bundle and reads or deletes every row of every table.

    Why it matters

    Full read and write access to the whole database and all users.

    How to fix it

    1. Create an Edge Function (e.g. delete-account) that calls getUser and then deleteUser(user.id) with the service-role key.
    2. Call it from the app with `supabase.functions.invoke('delete-account')`.
    3. Rotate the service-role key in the Supabase dashboard.

    Does your app have this?

    PTKD checks your build or your source project for PTKD-BACKEND-SUPABASE-ADMIN-IN-APP and every other check in this knowledge base.

    Scan your app

    References

    Related checks (M1)