What Firebase Studio generates and where the trust boundary is
Firebase's documentation says the App Prototyping agent builds web apps with Next.js. It can provision a Firebase project and a Gemini API key for AI features, add Cloud Firestore and Firebase Authentication when you ask, and publish to Firebase App Hosting. When you ask it to add Firestore, the documentation says it writes and deploys Firestore database rules for you. Open your workspace and confirm which of these your project actually has.
That gives the app two kinds of code. Browser code uses the Firebase client SDK and a public config, and whatever it can do is limited only by Security Rules. Server code, such as Next.js route handlers, server actions and AI flows, holds secrets like the Gemini key and must check the caller itself. Rules the agent wrote for you are still rules you have to read.
The same documentation warns that Gemini can generate output that seems plausible but is factually incorrect, and tells you to validate all output and not to use untested generated code in production.
The review checklist
| Area | What to verify | How to test on your own project | Pass condition |
|---|---|---|---|
| Firestore rules | Rules tie each document to the signed-in user and none allows everything. | Read firestore.rules or the Rules tab, then run the logged-out request below. | No rule reads allow read, write: if true, and the logged-out request is denied. |
| Signed-in is not enough | Rules check ownership, not only that someone is signed in. | Create two test accounts and try to read the first user's document as the second. | The second user is denied. |
| Gemini and other keys | Secret keys are read only by server code and never carry a public prefix. | Open the env file in your workspace and search the code for where each key is used. | No secret uses the NEXT_PUBLIC_ prefix and no client component imports it. |
| App Hosting configuration | Secrets are stored as secrets, and plain values in apphosting.yaml are safe to publish. | Read apphosting.yaml in the repository and the environment settings in the console. | Sensitive values are referenced as secrets, not written as plain values in a committed file. |
| Server actions and routes | Each server entry point checks the caller before acting. | Call each route with curl and no session. Read each server action for an auth check at the top. | Private routes refuse, and every action verifies the user itself. |
| AI endpoints | Endpoints that spend your Gemini quota cannot be called freely by strangers. | Call the AI route from outside the app, repeatedly, with no session. | Anonymous calls are refused or limited, and billing alerts are set on the project. |
| Repository history | No env file or key was ever committed. | Search git history with the commands below. | No hits, or every hit has been rotated. |
| Life after the sunset | You know where the code, the rules and the keys will live. | Read the migration guide and list every secret that must be re-created elsewhere. | A written plan exists and the checklist is scheduled to be repeated after the move. |
Probe Firestore from outside
Firebase's documentation on insecure rules names the patterns that expose data, including rules that allow all reads and writes and rules that only check that a user is signed in. Read your rules for those first. Then make the request a stranger would make, against your own project, with no credentials. A permission error is the pass result. A list of documents means the collection is public.
export PROJECT_ID="your-project-id"
curl -s "https://firestore.googleapis.com/v1/projects/$PROJECT_ID/databases/(default)/documents/YOUR_COLLECTION?pageSize=5"Keys, env files and App Hosting
The Firebase web config, including its API key, is meant to be public. Firebase's documentation says those keys identify the project and that authorisation comes from Security Rules, App Check and IAM. The Gemini API key is different: it is a credential that spends your quota, and it belongs only in server code. Next.js inlines any variable that starts with NEXT_PUBLIC_ into the browser bundle, so that prefix must never appear on a secret.
For App Hosting, the documentation describes an env list in apphosting.yaml where each variable has either a plain value or a reference to a secret in Cloud Secret Manager, created with the firebase apphosting:secrets:set command. It also lets you limit a variable to build time or run time. The example shows the intended split. Because apphosting.yaml is normally committed, a plain value there is as public as your repository.
env:
- variable: NEXT_PUBLIC_FIREBASE_PROJECT_ID
value: your-project-id
- variable: GEMINI_API_KEY
secret: geminiApiKey
availability:
- RUNTIME
firebase apphosting:secrets:set geminiApiKey
grep -rn "NEXT_PUBLIC_" .env* apphosting.yaml
git log --all -p -S"GEMINI_API_KEY" | head -50Server actions, routes and AI flows
The Next.js documentation says a server action is reachable by a direct POST request, not only through your interface, and that you should verify authentication and authorisation inside each one. Route handlers deserve the same treatment as public API endpoints. In a Firebase project, that usually means verifying the user's ID token on the server with the Admin SDK before doing any work. Remember that the Admin SDK bypasses Security Rules, so server code that uses it must do its own ownership checks.
An AI feature is also a cost surface. If a stranger can call the route that talks to Gemini, they can spend your quota. Require a signed-in user, limit how often one user can call it, and set a budget alert on the Google Cloud project.
Common mistakes with this workflow
- Assuming rules are safe because the agent wrote and deployed them. Read them.
- Accepting a rule that only checks the user is signed in. Any account can then read everything.
- Giving the Gemini key a NEXT_PUBLIC_ name so a client component can use it.
- Writing a secret as a plain value in apphosting.yaml and committing it.
- Leaving the AI endpoint open to anonymous calls with no limit.
- Testing with the account that owns the data, so cross-user reads are never tried.
- Ignoring the sunset notice until the workspace is gone, then rebuilding config from memory.
Keep it working
Re-read the rules and repeat the logged-out request after every change the agent makes to data access. Repeat the whole list after migrating the project. Pass condition: logged-out requests are denied, the second user cannot read the first user's documents, no secret carries a public prefix or sits in a committed file, and the AI route refuses strangers.
Frequently asked questions
Is Firebase Studio shutting down?
Yes, according to Firebase's documentation. It states that Firebase Studio is sunsetting on March 22, 2027 and that new workspace creation and sign-up were disabled from June 22, 2026. It also says apps already deployed to Firebase will continue to run. Check the current notice and migration guide for dates and options.
Are apps built with Firebase Studio secure?
Not by default. They are as secure as their Security Rules and server code. Firebase's documentation says the agent writes and deploys Firestore rules for you, and also tells you to validate all generated output and not use untested generated code in production. Read the rules and test them from outside.
Is the Firebase API key in my front end a leak?
No. Firebase's documentation says these keys identify your project and are not used to authorise access to data. What protects data is Security Rules, App Check and IAM. The Gemini API key is a different kind of key and must stay on the server.
Where should the Gemini API key go?
In server-only configuration. For App Hosting, Firebase documents storing sensitive values in Cloud Secret Manager and referencing them from apphosting.yaml. Never give it a NEXT_PUBLIC_ name, because Next.js inlines those variables into browser code.
Do I need to redo this checklist after migrating away from Firebase Studio?
Yes. A new workspace or host means new env files, new secret storage and possibly new deploy settings. The deployed Firebase services keep running, but repeat the key, rules and endpoint checks once the project has moved.